persistent-actionで一時メッセージを表示してみるテスト

範囲内で文字を書き換えてスクロールのように見せる - asdfではanything.elのヘッダを常に見せようと格闘しているようだ。けど、むしろ新しいoverlayを導入してそこに一時メッセージを表示させたほうがいい気がする。

(defvar anything-c-source-persistent-action-overlay-test
  '((name . "test")
    (candidates . (lambda () (loop for i from 1 to 30 collect (int-to-string i))))
    (persistent-action . anything-c-source-persistent-action-overlay-test-doit)
    (cleanup . anything-c-source-persistent-action-overlay-test-delete-overlay)))
(defvar anything-persistent-action-overlay nil)
(defun anything-c-source-persistent-action-overlay-test-delete-overlay ()
  (and anything-persistent-action-overlay
       (delete-overlay anything-persistent-action-overlay)))
(defun anything-c-source-persistent-action-overlay-test-doit (cand)
  (with-anything-window
    (anything-c-source-persistent-action-overlay-test-delete-overlay)
    (save-excursion
      (goto-char (window-start))
      (setq anything-persistent-action-overlay
            (make-overlay (point-at-bol) (1+ (point-at-eol))))
      (overlay-put anything-persistent-action-overlay 'face 'highlight)
      (overlay-put anything-persistent-action-overlay 'display
                   (concat "<<<<" cand ">>>>" "\n"
                           "((((" cand "))))"
                           "\n")))
  (message cand)))
;; (anything 'anything-c-source-persistent-action-overlay-test)

これは数字の候補でpersistent-actionを実行すると画面上部にメッセージを表示する実験的なコード。overlayが乗っている候補の上にカーソルが行くと見えなくなるから、anything-move-selectionも書き換える必要がある。さらに、move-overlayを使うべき。まあとりあえずさっと書いてみた。

anything-c-source-buffers2は気に入ったので設定に加えておいた^^