;;; bs.el --- menu for selecting and displaying buffers
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2011 Free Software Foundation, Inc.
;; Author: Olaf Sylvester <Olaf.Sylvester@netsurf.de>
;; Maintainer: Olaf Sylvester <Olaf.Sylvester@netsurf.de>
;; Keywords: convenience
'font-lock-constant-face
'font-lock-comment-face))
;; Dired-Buffers
- '("^..\\(.*Dired by .*\\)$" 1 font-lock-function-name-face)
+ '("^..\\(.*Dired .*\\)$" 1 font-lock-function-name-face)
;; the star for modified buffers
'("^.\\(\\*\\) +[^\\*]" 1 font-lock-comment-face))
"Default font lock expressions for Buffer Selection Menu.")
"Redisplay whole Buffer Selection Menu.
If KEEP-LINE-P is non-nil the point will stay on current line.
SORT-DESCRIPTION is an element of `bs-sort-functions'."
- (let ((line (1+ (count-lines 1 (point)))))
+ (let ((line (count-lines 1 (point))))
(bs-show-in-buffer (bs-buffer-list nil sort-description))
(when keep-line-p
- (goto-line line))
+ (goto-char (point-min))
+ (forward-line line))
(beginning-of-line)))
(defun bs--goto-current-buffer ()
font-lock-global-modes '(not bs-mode)
font-lock-defaults '(bs-mode-font-lock-keywords t)
font-lock-verbose nil)
+ (set (make-local-variable 'revert-buffer-function) 'bs-refresh)
(add-hook 'window-size-change-functions 'bs--track-window-changes)
(add-hook 'kill-buffer-hook 'bs--remove-hooks nil t)
(add-hook 'change-major-mode-hook 'bs--remove-hooks nil t))
(call-interactively 'bs-set-configuration)
(bs--redisplay t))
-(defun bs-refresh ()
- "Refresh whole Buffer Selection Menu."
+(defun bs-refresh (&rest ignored)
+ "Refresh whole Buffer Selection Menu.
+Arguments are IGNORED (for `revert-buffer')."
(interactive)
(bs--redisplay t))
"Save buffer on current line."
(interactive)
(with-current-buffer (bs--current-buffer)
- (save-buffer)
- (bs--update-current-line))
+ (save-buffer))
+ (bs--update-current-line))
(defun bs-visit-tags-table ()
"Visit the tags table in the buffer on this line.
"Move cursor vertically down one line.
If at end of buffer list go to first line."
(if (eq (line-end-position) (point-max))
- (goto-line (1+ bs-header-lines-length))
+ (progn
+ (goto-char (point-min))
+ (forward-line bs-header-lines-length))
(forward-line 1)))
(defun bs-visits-non-file (buffer)
(dolist (buffer list)
(bs--insert-one-entry buffer)
(insert "\n"))
- (delete-backward-char 1)
+ (delete-char -1)
(bs--set-window-height)
(bs--goto-current-buffer)
(font-lock-fontify-buffer)
(defun bs--get-file-name (start-buffer all-buffers)
"Return string for column 'File' in Buffer Selection Menu.
This is the variable `buffer-file-name' of current buffer.
-If current mode is `dired-mode' or `shell-mode' it returns the
-default directory.
+If not visiting a file, `list-buffers-directory' is returned instead.
START-BUFFER is the buffer where we started buffer selection.
ALL-BUFFERS is the list of buffers appearing in Buffer Selection Menu."
- (propertize (if (member major-mode '(shell-mode dired-mode))
- default-directory
- (or buffer-file-name ""))
+ (propertize (or buffer-file-name
+ (bound-and-true-p list-buffers-directory)
+ "")
'mouse-face 'highlight
'help-echo "mouse-2: select this buffer, mouse-3: select in other frame"))
(setq bs--marked-buffers nil)
(bs--show-with-configuration (bs--configuration-name-for-prefix-arg arg)))
+;; ----------------------------------------------------------------------
+;; Cleanup
+;; ----------------------------------------------------------------------
+
+(defun bs-unload-function ()
+ "Unload the Buffer Selection library."
+ (let ((bs-buf (get-buffer "*buffer-selection*")))
+ (when bs-buf
+ (with-current-buffer bs-buf
+ (when (eq major-mode 'bs-mode)
+ (bs-kill)
+ (kill-buffer bs-buf)))))
+ ;; continue standard unloading
+ nil)
+
;; Now provide feature bs
(provide 'bs)
-;; arch-tag: c0d9ab34-bf06-4368-ae9d-af88878e6802
;;; bs.el ends here