X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/3af36712d152c38a31fd377115f33eeaddbb2495..84eb0351d8be4811897c8cf62a69757ff5d14001:/lisp/bs.el diff --git a/lisp/bs.el b/lisp/bs.el index d4d22d786d..1f90304f1d 100644 --- a/lisp/bs.el +++ b/lisp/bs.el @@ -1,7 +1,6 @@ ;;; 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 ;; Maintainer: Olaf Sylvester ;; Keywords: convenience @@ -43,14 +42,10 @@ ;;; Quick Installation und Customization: -;; Use +;; To display the bs menu, do ;; M-x bs-show -;; for buffer selection or optional bind a key to main function `bs-show' -;; (global-set-key "\C-x\C-b" 'bs-show) ;; or another key -;; -;; For customization use -;; M-x bs-customize - +;; To customize its behavior, do +;; M-x bs-customize ;;; More Commentary: @@ -195,7 +190,7 @@ return a string representing the column's value." '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.") @@ -575,10 +570,11 @@ a special function. SORT-DESCRIPTION is an element of `bs-sort-functions'." "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 () @@ -664,6 +660,7 @@ to show always. 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)) @@ -696,8 +693,9 @@ Refresh whole Buffer Selection Menu." (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)) @@ -1008,7 +1006,9 @@ If on top of buffer list go to last 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) @@ -1147,7 +1147,7 @@ and move point to current 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) @@ -1324,13 +1324,12 @@ ALL-BUFFERS is the list of buffers appearing in Buffer Selection Menu." (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")) @@ -1464,8 +1463,22 @@ name of buffer configuration." (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