]> code.delx.au - gnu-emacs/blobdiff - lisp/buff-menu.el
Fix rmail mime search bug when entity is a string.
[gnu-emacs] / lisp / buff-menu.el
index 34b1c245e080acfe9870164af213d23c402e4fbd..95f309e33b93265f551afc72747d0186f05534b0 100644 (file)
@@ -1,10 +1,11 @@
 ;;; buff-menu.el --- buffer menu main function and support functions -*- coding:utf-8 -*-
 
-;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1993-1995, 2000-2011
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: convenience
+;; Package: emacs
 
 ;; This file is part of GNU Emacs.
 
@@ -111,9 +112,15 @@ A nil value means sort by visited order (the default).")
 This variable determines whether reverting the buffer lists only
 file buffers.  It affects both manual reverting and reverting by
 Auto Revert Mode.")
-
 (make-variable-buffer-local 'Buffer-menu-files-only)
 
+(defvar Buffer-menu--buffers nil
+  "If non-nil, list of buffers shown in the current buffer-menu.
+This variable determines whether reverting the buffer lists only
+these buffers.  It affects both manual reverting and reverting by
+Auto Revert Mode.")
+(make-variable-buffer-local 'Buffer-menu--buffers)
+
 (defvar Info-current-file) ;; from info.el
 (defvar Info-current-node) ;; from info.el
 
@@ -151,19 +158,19 @@ Auto Revert Mode.")
     (define-key map [follow-link] 'mouse-face)
     (define-key map (kbd "M-s a C-s")   'Buffer-menu-isearch-buffers)
     (define-key map (kbd "M-s a M-C-s") 'Buffer-menu-isearch-buffers-regexp)
-    (define-key map [menu-bar Buffer-menu-mode] (cons "Buffer Menu" menu-map))
+    (define-key map [menu-bar Buffer-menu-mode] (cons (purecopy "Buffer-Menu") menu-map))
     (define-key menu-map [quit]
       `(menu-item ,(purecopy "Quit") quit-window
-                :help ,(purecopy "Mark buffer on this line to be deleted by x command")))
+                :help ,(purecopy "Remove the buffer menu from the display")))
     (define-key menu-map [rev]
       `(menu-item ,(purecopy "Refresh") revert-buffer
                 :help ,(purecopy "Refresh the *Buffer List* buffer contents")))
-    (define-key menu-map [s0] '("--"))
+    (define-key menu-map [s0] menu-bar-separator)
     (define-key menu-map [tf]
       `(menu-item ,(purecopy "Show only file buffers") Buffer-menu-toggle-files-only
                  :button (:toggle . Buffer-menu-files-only)
                  :help ,(purecopy "Toggle whether the current buffer-menu displays only file buffers")))
-    (define-key menu-map [s1] '("--"))
+    (define-key menu-map [s1] menu-bar-separator)
     ;; FIXME: The "Select" entries could use better names...
     (define-key menu-map [sel]
       `(menu-item ,(purecopy "Select marked") Buffer-menu-select
@@ -180,14 +187,14 @@ Auto Revert Mode.")
     (define-key menu-map [tw]
       `(menu-item ,(purecopy "Select in current window") Buffer-menu-this-window
                 :help ,(purecopy "Select this line's buffer in this window")))
-    (define-key menu-map [s2] '("--"))
+    (define-key menu-map [s2] menu-bar-separator)
     (define-key menu-map [is]
       `(menu-item ,(purecopy "Regexp Isearch marked buffers") Buffer-menu-isearch-buffers-regexp
                 :help ,(purecopy "Search for a regexp through all marked buffers using Isearch")))
     (define-key menu-map [ir]
       `(menu-item ,(purecopy "Isearch marked buffers") Buffer-menu-isearch-buffers
                 :help ,(purecopy "Search for a string through all marked buffers using Isearch")))
-    (define-key menu-map [s3] '("--"))
+    (define-key menu-map [s3] menu-bar-separator)
     (define-key menu-map [by]
       `(menu-item ,(purecopy "Bury") Buffer-menu-bury
                 :help ,(purecopy "Bury the buffer listed on this line")))
@@ -197,7 +204,7 @@ Auto Revert Mode.")
     (define-key menu-map [ex]
       `(menu-item ,(purecopy "Execute") Buffer-menu-execute
                 :help ,(purecopy "Save and/or delete buffers marked with s or k commands")))
-    (define-key menu-map [s4] '("--"))
+    (define-key menu-map [s4] menu-bar-separator)
     (define-key menu-map [delb]
       `(menu-item ,(purecopy "Mark for delete and move backwards") Buffer-menu-delete-backwards
                 :help ,(purecopy "Mark buffer on this line to be deleted by x command and move up one line")))
@@ -257,21 +264,21 @@ Letters do not insert themselves; instead, they are commands.
   (set (make-local-variable 'revert-buffer-function)
        'Buffer-menu-revert-function)
   (set (make-local-variable 'buffer-stale-function)
-       #'(lambda (&optional noconfirm) 'fast))
+       (lambda (&optional _noconfirm) 'fast))
   (setq truncate-lines t)
   (setq buffer-read-only t))
 
 (define-obsolete-variable-alias 'buffer-menu-mode-hook
   'Buffer-menu-mode-hook "23.1")
 
-(defun Buffer-menu-revert-function (ignore1 ignore2)
+(defun Buffer-menu-revert-function (_ignore1 _ignore2)
   (or (eq buffer-undo-list t)
       (setq buffer-undo-list nil))
   ;; We can not use save-excursion here.  The buffer gets erased.
   (let ((opoint (point))
        (eobp (eobp))
        (ocol (current-column))
-       (oline (progn (move-to-column 4)
+       (oline (progn (move-to-column Buffer-menu-buffer-column)
                      (get-text-property (point) 'buffer)))
        (prop (point-min))
        ;; do not make undo records for the reversion.
@@ -281,7 +288,7 @@ Letters do not insert themselves; instead, they are commands.
     ;; interactively current buffer is correctly identified with a `.'
     ;; by `list-buffers-noselect'.
     (with-current-buffer (window-buffer)
-      (list-buffers-noselect Buffer-menu-files-only))
+      (list-buffers-noselect Buffer-menu-files-only Buffer-menu--buffers))
     (if oline
        (while (setq prop (next-single-property-change prop 'buffer))
          (when (eq (get-text-property prop 'buffer) oline)
@@ -302,9 +309,7 @@ negative ARG, display other buffers as well."
 \f
 (defun Buffer-menu-buffer (error-if-non-existent-p)
   "Return buffer described by this line of buffer menu."
-  (let* ((where (save-excursion
-                 (beginning-of-line)
-                 (+ (point) Buffer-menu-buffer-column)))
+  (let* ((where (+ (line-beginning-position) Buffer-menu-buffer-column))
         (name (and (not (eobp)) (get-text-property where 'buffer-name)))
         (buf (and (not (eobp)) (get-text-property where 'buffer))))
     (if name
@@ -678,12 +683,15 @@ For more information, see the function `buffer-menu'."
     (setq name (copy-sequence name)))
   (add-text-properties 0 (length name) name-props name)
   (add-text-properties 0 (length size) size-props size)
-  (concat name
-         (make-string (- Buffer-menu-buffer+size-width
-                         (string-width name)
-                         (string-width size))
-                      ?\s)
-         size))
+  (let ((name+space-width (- Buffer-menu-buffer+size-width
+                            (string-width size))))
+    (concat name
+           (propertize (make-string (- name+space-width (string-width name))
+                                    ?\s)
+                       'display `(space :align-to
+                                        ,(+ Buffer-menu-buffer-column
+                                            name+space-width)))
+           size)))
 
 (defun Buffer-menu-sort (column)
   "Sort the buffer menu by COLUMN."
@@ -697,7 +705,11 @@ For more information, see the function `buffer-menu'."
     (save-excursion
       (Buffer-menu-beginning)
       (while (not (eobp))
-       (when (buffer-live-p (setq buf (get-text-property (+ (point) 4) 'buffer)))
+       (when (buffer-live-p
+              (setq buf (get-text-property
+                         (+ (point)
+                            Buffer-menu-buffer-column)
+                         'buffer)))
          (setq m1 (char-after)
                m1 (if (memq m1 '(?> ?D)) m1)
                m2 (char-after (+ (point) 2))
@@ -709,7 +721,9 @@ For more information, see the function `buffer-menu'."
     (save-excursion
       (Buffer-menu-beginning)
       (while (not (eobp))
-       (when (setq buf (assq (get-text-property (+ (point) 4) 'buffer) l))
+       (when (setq buf (assq (get-text-property (+ (point)
+                                                   Buffer-menu-buffer-column)
+                                                'buffer) l))
          (setq m1 (cadr buf)
                m2 (cadr (cdr buf)))
          (when m1
@@ -889,7 +903,7 @@ For more information, see the function `buffer-menu'."
                ;; This way we avoid problems with unusual buffer names.
                (let ((name (nth 2 buffer))
                      (size (int-to-string (nth 3 buffer))))
-                     (Buffer-menu-buffer+size name size
+                 (Buffer-menu-buffer+size name size
                         `(buffer-name ,name
                                       buffer ,(car buffer)
                                       font-lock-face buffer-menu-buffer
@@ -919,8 +933,8 @@ For more information, see the function `buffer-menu'."
       (and desired-point
           (goto-char desired-point))
       (setq Buffer-menu-files-only files-only)
+      (setq Buffer-menu--buffers buffer-list)
       (set-buffer-modified-p nil)
       (current-buffer))))
 
-;; arch-tag: e7dfcfc9-6cb2-46e4-bf55-8ef1936d83c6
 ;;; buff-menu.el ends here