2009-03-19 [長年日記]
_ [Emacs] anything-c-source-other-windows
Emacsでwindows.elを使っていて、これの別windowへの移動をanythingから使えると便利だと思い作ってみた。まだ、あまり使っていないので問題があるかもしれないが。
(setq anything-c-source-other-windows '((name . "Other windows") (candidates . (lambda () (let ((i 1) (l (list)) (form (format "[w%%c] %%-%ds [%%s]" win:names-maxl))) (while (< i win:max-configs) (if (aref win:configs i) (add-to-list 'l (format form (+ win:base-key i) (if (aref win:configs i) (format "%s" (aref win:names-prefix i)) "") (aref win:names i) ))) (setq i (1+ i))) (sort l 'string<)))) (action . (("Switch to Other Window" . (lambda (arg) (if (string-match "^\\[w\\(.\\)\\]" arg) (let ((num (string-to-number (match-string 1 arg)))) (win:switch-window num))))))) ))
[ツッコミを入れる]
2009-03-21 [長年日記]
_ [Linux] anything-c-source-other-windows その2
windows.elのwindowをanythingから選択するソースを次のように変更した。これでほとんど不満はない。
(defun win-switch-to-window1() (interactive) (let ((last-command-char ?1)) (call-interactively 'win-switch-to-window))) (defun win-switch-to-window2() (interactive) (let ((last-command-char ?2)) (call-interactively 'win-switch-to-window))) (defun win-switch-to-window3() (interactive) (let ((last-command-char ?3)) (call-interactively 'win-switch-to-window))) (defun win-switch-to-window4() (interactive) (let ((last-command-char ?4)) (call-interactively 'win-switch-to-window))) (defun win-switch-to-window5() (interactive) (let ((last-command-char ?5)) (call-interactively 'win-switch-to-window))) (defun win-switch-to-window6() (interactive) (let ((last-command-char ?6)) (call-interactively 'win-switch-to-window))) (defun win-switch-to-window7() (interactive) (let ((last-command-char ?7)) (call-interactively 'win-switch-to-window))) (defun win-switch-to-window8() (interactive) (let ((last-command-char ?8)) (call-interactively 'win-switch-to-window))) (defun win-switch-to-window9() (interactive) (let ((last-command-char ?9)) (call-interactively 'win-switch-to-window))) (setq anything-c-source-other-windows '((name . "Other Windows") (candidates . (lambda () (win:store-config win:current-config) (let ((i 1) (l (list)) (form (format "[w%%c]%%s %%-%ds [%%s]" win:names-maxl))) (while (< i win:max-configs) (add-to-list 'l (if (aref win:configs i) (format form (+ win:base-key i) (cond ((= i win:current-config) "*") ((= i win:last-config) "+") (t " ")) (format "%s" (aref win:names-prefix i)) (aref win:names i)) (format form (+ win:base-key i) " " "" ""))) (setq i (1+ i))) (sort l 'string<)))) (action . (("Switch to Other Window" . (lambda (arg) (if (string-match "^\\[w\\(.\\)\\]" arg) (let ((num (string-to-number (match-string 1 arg)))) (call-interactively (intern (format "win-switch-to-window%d" num))) )))))) ))
anythingでまだ作られていないwindowを選択したときに、新しいwindowを作成できるように、win-switch-to-window1などの関数を作った。関数を作らないですむ、うまい方法があれば良いのだが、私には分からない。
[追記] win-switch-to-window1などの関数を作ったのは、one-key.elの設定で使うためなので、anythingのsourceを作るには必要ない。私は使わないので、ここに書くことはしないけれど。
本日のツッコミ(全2件) [ツッコミを入れる]
2009-03-25 [長年日記]
_ [Emacs] anything-c-source-buffersのanything-c-buffer-list
anything関連のファイルをバージョンアップしたときに、なぜかanything-c-source-buffersの選択肢の先頭が現在のバッファになるようになった。それを直そうとソースを見ると、現在のバッファが一番最後になるように順番を変更する操作を行っているが、うまく動いていない。その操作は、バッファのリストの先頭を最後に入れ替える操作だが、リストの先頭のバッファが現在のバッファと違うようで、望む動作になっていない。そこで、anything-c-buffer-listを次のように変更すると望む動作になる。
(defun anything-c-buffer-list () "Return the list of names of buffers with boring buffers filtered out. Boring buffers is specified by `anything-c-boring-buffer-regexp'. The first buffer in the list will be the last recently used buffer that is not the current buffer." (let ((buffers (mapcar 'buffer-name (buffer-list))) (current-buf-name (buffer-name anything-current-buffer))) (append (remove current-buf-name buffers) (list current-buf-name))))
[ツッコミを入れる]
_ AYU [はぁ、素晴しすぎです。早速、情報源としてマイ dot.emacs に登録させていただきました。 ]
_ tk [喜んでもらえてよかったです。]