«前の日記(2009-03-19) 最新 次の日記(2009-03-25)» 編集

ソフトウェアと本の覚え書き

2005|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|

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件) [ツッコミを入れる]
_ AYU (2009-04-16 11:26)

はぁ、素晴しすぎです。早速、情報源としてマイ dot.emacs に登録させていただきました。

_ tk (2009-04-16 22:28)

喜んでもらえてよかったです。