Customized.
[bpt/emacs.git] / lisp / buff-menu.el
index 5bbafd1..2b187a2 100644 (file)
@@ -17,8 +17,9 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
@@ -71,6 +72,7 @@
   (define-key Buffer-menu-mode-map "2" 'Buffer-menu-2-window)
   (define-key Buffer-menu-mode-map "1" 'Buffer-menu-1-window)
   (define-key Buffer-menu-mode-map "f" 'Buffer-menu-this-window)
+  (define-key Buffer-menu-mode-map "e" 'Buffer-menu-this-window)
   (define-key Buffer-menu-mode-map "\C-m" 'Buffer-menu-this-window)
   (define-key Buffer-menu-mode-map "o" 'Buffer-menu-other-window)
   (define-key Buffer-menu-mode-map "\C-o" 'Buffer-menu-switch-other-window)
@@ -90,7 +92,8 @@
   (define-key Buffer-menu-mode-map "m" 'Buffer-menu-mark)
   (define-key Buffer-menu-mode-map "t" 'Buffer-menu-visit-tags-table)
   (define-key Buffer-menu-mode-map "%" 'Buffer-menu-toggle-read-only)
-  (define-key Buffer-menu-mode-map "g" 'revert-buffer)
+  (define-key Buffer-menu-mode-map "b" 'Buffer-menu-bury)
+  (define-key Buffer-menu-mode-map "g" 'Buffer-menu-revert)
   (define-key Buffer-menu-mode-map [mouse-2] 'Buffer-menu-mouse-select)
 )
 
@@ -122,7 +125,9 @@ Letters do not insert themselves; instead, they are commands.
 \\[Buffer-menu-unmark] -- remove all kinds of marks from current line.
   With prefix argument, also move up one line.
 \\[Buffer-menu-backup-unmark] -- back up a line and remove marks.
-\\[Buffer-menu-toggle-read-only] -- toggle read-only status of buffer on this line."
+\\[Buffer-menu-toggle-read-only] -- toggle read-only status of buffer on this line.
+\\[Buffer-menu-revert] -- update the list of buffers.
+\\[Buffer-menu-bury] -- bury the buffer listed on this line."
   (kill-all-local-variables)
   (use-local-map Buffer-menu-mode-map)
   (setq major-mode 'Buffer-menu-mode)
@@ -133,6 +138,11 @@ Letters do not insert themselves; instead, they are commands.
   (setq buffer-read-only t)
   (run-hooks 'buffer-menu-mode-hook))
 
+(defun Buffer-menu-revert ()
+  "Update the list of buffers."
+  (interactive)
+  (revert-buffer))
+
 (defun Buffer-menu-revert-function (ignore1 ignore2)
   (list-buffers))
 \f
@@ -141,7 +151,7 @@ Letters do not insert themselves; instead, they are commands.
   (let* ((where (save-excursion
                  (beginning-of-line)
                  (+ (point) Buffer-menu-buffer-column)))
-        (name (get-text-property where 'buffer-name)))
+        (name (and (not (eobp)) (get-text-property where 'buffer-name))))
     (if name
        (or (get-buffer name)
            (if error-if-non-existent-p
@@ -418,6 +428,21 @@ The current window remains selected."
             (delete-char 1)
             (insert char))))))
 
+(defun Buffer-menu-bury ()
+  "Bury the buffer listed on this line."
+  (interactive)
+  (beginning-of-line)
+  (if (looking-at " [-M]")             ;header lines
+      (ding)
+    (save-excursion
+      (beginning-of-line)
+      (bury-buffer (Buffer-menu-buffer t))
+      (let ((line (buffer-substring (point) (progn (forward-line 1) (point))))
+            (buffer-read-only nil))
+        (delete-region (point) (progn (forward-line -1) (point)))
+        (goto-char (point-max))
+        (insert line))
+      (message "Buried buffer moved to the end"))))
 \f
 
 (define-key ctl-x-map "\C-b" 'list-buffers)
@@ -507,11 +532,12 @@ The R column contains a % for buffers that are read-only."
              ;; This way we avoid problems with unusual buffer names.
              (setq this-buffer-line-start
                    (+ this-buffer-line-start Buffer-menu-buffer-column))
-             (put-text-property this-buffer-line-start (point)
-                                'buffer-name name)
-             (put-text-property this-buffer-line-start (point)
-                                'mouse-face 'highlight)
-             (indent-to 17 2)
+             (let ((name-end (point)))
+               (indent-to 17 2)
+               (put-text-property this-buffer-line-start name-end
+                                  'buffer-name name)
+               (put-text-property this-buffer-line-start name-end
+                                  'mouse-face 'highlight))
              (let (size
                    mode
                    (excess (- (current-column) 17)))