top  Index  Search  Changes  RSS  Login

SwitchBuffer

howm-mode なバッファだけを切りかえる -- 2ch3:605

;; 605 さんのコード. navi2ch を元にしているそう.
;; 「もちろん、GNU General Public License です」とのこと.

(defun howm-current-buffer ()
  "BUFFER-LIST の一番最初の `howm-mode' の buffer を返す。"
  (let ((list (buffer-list)))
    (catch 'loop
      (while list
        (when (save-excursion
                (set-buffer (car list))
                howm-mode)
          (throw 'loop (car list)))
        (setq list (cdr list)))
      nil)))

(defun howm-forward-buffer ()
  "次の howm buffer に切り替える。"
  (interactive)
  (let (buf)
    (dolist (x (buffer-list))
      (when (with-current-buffer x
              howm-mode)
        (setq buf x)))
    (if buf (switch-to-buffer buf)
    nil)))

(defun howm-backward-buffer ()
  "前の howm buffer に切り替える。"
  (interactive)
  (let ((orig (current-buffer))
        buf)
    (when (setq buf (howm-current-buffer))
      (bury-buffer buf))
    (setq buf (howm-current-buffer))
    (if buf (switch-to-buffer buf)
      (switch-to-buffer orig)
      nil)))
;; 別解 1
(require 'cl)
(defun my-list-howm-buffers ()
  "howm-mode なバッファを howm で一覧"
  (interactive)
  (let ((bufs (remove-if-not (lambda (b)
                               (with-current-buffer b howm-mode))
                             (buffer-list))))
    (howm-view-directory (howm-make-folder:pages
                          (mapcar #'howm-make-page:buf bufs)))))
;; 別解 2
(require 'cl)
(defun my-iswitchb-howm ()
  "howm-mode なバッファだけを iswitchb で切りかえ"
  (interactive)
  (let ((iswitchb-make-buflist-hook
         (list (lambda ()
                 (setq iswitchb-temp-buflist
                       (remove-if-not (lambda (b)
                                        (with-current-buffer b howm-mode))
                                      iswitchb-temp-buflist))))))
    (iswitchb-buffer)))

関連(?): ToggleBuffer, iswitchb


(Please LogIn to post comments.)

Last modified:2008/11/25 01:19:18
Keyword(s):
References:[アイデア]