この前のEmacs ユーザーの方に質問です。これは便利!(以下略)で ac-mode を使いはじめてみた。従来からインストールはしてあったのだけど、全然使ったことなかった。さすがに、C-i が取られちゃうと、indent が大変なので、key bind を変えたりしていたら、一個バグを見付けてしまった。
一ヶ所だけある meassage() に "%任意の文字" が渡るとエラーになる。適当に princ() にしてしまったのよ。
もう一点、日本語の後にすぐ ascii がつながっているときの ac-dabbrev-completion() はちょっとだめだな。あとで、考えてみよう。
(defun url-complete ()
(interactive)
(save-excursion
(let ((begin (point))
(buf (get-buffer url-complete--buffer))
(url-regexp (concat "[" ac-mode-url-char "]+"))
match-url match-region comp w3m)
(when (and (< (skip-chars-backward ac-mode-url-char) 0)
(or (looking-at "https?:")
(looking-at "ftp:"))
(file-exists-p ac-mode-url-file))
(re-search-forward url-regexp begin t)
(setq match-url (match-string 0))
(setq match-data
(list (match-string 0) (match-beginning 0) (match-end 0)
(ac-point-at-eow url-regexp)))
(set-buffer url-complete--buffer)
(erase-buffer)
(call-process "look" nil url-complete--buffer nil match-url
(expand-file-name ac-mode-url-file))
(and (or (featurep 'w3m) (require 'w3m))
(boundp 'w3m-input-url-history)
(not w3m-input-url-history)
(w3m-arrived-setup))
(setq w3m (boundp 'w3m-input-url-history))
(let* ((line1 (progn (goto-char (point-min))
(when (re-search-forward "^.+$" nil t)
(list (match-string 0)))))
(line2 (progn (goto-char (point-max))
(when (re-search-backward "^.+$" nil t)
(list (match-string 0)))))
(comp (when (and line1 line2)
(try-completion match-url (list line1 line2))))
(w3mcomp (when w3m
(try-completion match-url w3m-input-url-history)))
(w3mall (when w3m
(all-completions match-url w3m-input-url-history nil 'nospace))))
(cond ((and (stringp comp) (string-lessp match-url comp))
(list match-data comp))
((and (stringp w3mcomp) (string-lessp match-url w3mcomp))
(list match-data w3mcomp))
(t
(cons match-data (nconc (split-string (buffer-string))
w3mall)))))))))
今までの urls.txt が優先で、その後に w3m の history が出てくる。urls.txt は空でも良いので用意しておかないとだめ。
現在使っている complete 関係の関数と key bind は
とあいなりました。他にもあるかも。普段は最初の三つぐらいしか使わないような気がするけど、url-complete() 改造版は結構便利かもです。
こんなのあるんですね。ちなみに「ハテナ」はブックマークはしています。<br>]http://b.hatena.ne.jp/mitsugusakamoto/