cd c:/drews-lisp-20/cvs-lisp/
diff -c -b "c:/Emacs-22.1/lisp/buff-menu.el" "c:/drews-lisp-20/cvs-lisp/buff-menu-CVS-patched-2007-07-09.el"
*** c:/Emacs-22.1/lisp/buff-menu.el	Fri May 25 05:43:30 2007
--- c:/drews-lisp-20/cvs-lisp/buff-menu-CVS-patched-2007-07-09.el	Mon Jul  9 15:56:08 2007
***************
*** 64,85 ****
  ;; Put buffer *Buffer List* into proper mode right away
  ;; so that from now on even list-buffers is enough to get a buffer menu.
  
  (defgroup Buffer-menu nil
    "Show a menu of all buffers in a buffer."
    :group 'tools
    :group 'convenience)
  
- (defcustom Buffer-menu-use-header-line t
-   "*Non-nil means to use an immovable header-line."
-   :type 'boolean
-   :group 'Buffer-menu)
- 
  (defface buffer-menu-buffer
!   '((t (:weight bold)))
    "Face used to highlight buffer names in the buffer menu."
    :group 'Buffer-menu)
  (put 'Buffer-menu-buffer 'face-alias 'buffer-menu-buffer)
  
  (defcustom Buffer-menu-buffer+size-width 26
    "*How wide to jointly make the buffer name and size columns."
    :type 'number
--- 64,178 ----
  ;; Put buffer *Buffer List* into proper mode right away
  ;; so that from now on even list-buffers is enough to get a buffer menu.
  
+ (eval-when-compile (require 'cl)) ;; case
+ 
  (defgroup Buffer-menu nil
    "Show a menu of all buffers in a buffer."
    :group 'tools
    :group 'convenience)
  
  (defface buffer-menu-buffer
!   '((t (:foreground "Blue")))
    "Face used to highlight buffer names in the buffer menu."
    :group 'Buffer-menu)
+ (defvar buffer-menu-buffer-name 'buffer-menu-buffer-name)
  (put 'Buffer-menu-buffer 'face-alias 'buffer-menu-buffer)
  
+ (defface buffer-menu-headings
+   '((t (:foreground "Orange" :background "DarkGreen")))
+   "Face used for headings in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-headings 'buffer-menu-headings)
+ 
+ (defface buffer-menu-current-buffer
+   '((t (:foreground "Red" :background "Aquamarine")))
+   "Face used for current buffer mark in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-current-buffer 'buffer-menu-current-buffer)
+ 
+ (defface buffer-menu-view-mark
+   '((t (:foreground "Red" :background "Aquamarine")))
+   "Face used for buffers to view mark (>) in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-view-mark 'buffer-menu-view-mark)
+ 
+ (defface buffer-menu-star-buffer
+   '((t (:foreground "DarkBlue")))
+   "Face used for buffers named \"*...*\"in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-star-buffer 'buffer-menu-star-buffer)
+ 
+ (defface buffer-menu-directory-buffer
+   '((t (:foreground "Blue" :background "LightBlue")))
+   "Face used for directory buffers in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-directory-buffer 'buffer-menu-directory-buffer)
+ 
+ (defface buffer-menu-marked-buffer
+   '((t (:underline t)))
+   "Face used for buffers marked with `>' in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-marked-buffer 'buffer-menu-marked-buffer)
+ 
+ (defface buffer-menu-flagged-buffer
+   '((t (:foreground "Red")))
+   "Face used for buffers marked with `D' in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-flagged-buffer 'buffer-menu-flagged-buffer)
+ 
+ (defface buffer-menu-delete-mark
+   '((t (:foreground "Aquamarine" :background "Red")))
+   "Face used for buffers to delete mark (D) in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-delete-mark 'buffer-menu-delete-mark)
+ 
+ (defface buffer-menu-save-mark
+   '((t (:foreground "Orange" :background "Blue")))
+   "Face used for buffers to save mark (S) in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-save-mark 'buffer-menu-save-mark)
+ 
+ (defface buffer-menu-modified-mark
+   '((t (:foreground "DarkOrange")))
+   "Face used for modified buffers mark (*) in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-modified-mark 'buffer-menu-modified-mark)
+ 
+ (defface buffer-menu-read-only-mark
+   '((t (:foreground "Yellow")))
+   "Face used for read-only buffers mark (%) in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-read-only-mark 'buffer-menu-read-only-mark)
+ 
+ (defface buffer-menu-mode
+   '((t (:foreground "DarkGreen")))
+   "Face used for buffer modes in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-mode 'buffer-menu-mode)
+ 
+ (defface buffer-menu-size
+   '((t (:foreground "DarkRed")))
+   "Face used for buffer sizes in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-size 'buffer-menu-size)
+ 
+ (defface buffer-menu-time
+   '((t (:foreground "DarkGoldenrod4")))
+   "Face used for buffer time in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-time 'buffer-menu-time)
+ 
+ (defface buffer-menu-file-name
+   '((t (:foreground "DarkMagenta")))
+   "Face used for file names in *Buffer List* buffer."
+   :group 'Buffer-menu)
+ (defvar buffer-menu-file-name 'buffer-menu-file-name)
+ 
+ (defcustom Buffer-menu-use-header-line t
+   "*Non-nil means to use an immovable header-line."
+   :type 'boolean
+   :group 'Buffer-menu)
+ 
  (defcustom Buffer-menu-buffer+size-width 26
    "*How wide to jointly make the buffer name and size columns."
    :type 'number
***************
*** 100,115 ****
    :group 'Buffer-menu
    :version "22.1")
  
! ;; This should get updated & resorted when you click on a column heading
! (defvar Buffer-menu-sort-column nil
!   "Which column to sort the menu on.
! Use 2 to sort by buffer names, or 5 to sort by file names.
! nil means sort by visited order (the default).")
  
  (defconst Buffer-menu-buffer-column 4)
  
! (defvar Buffer-menu-mode-map nil
!   "Local keymap for `Buffer-menu-mode' buffers.")
  
  (defvar Buffer-menu-files-only nil
    "Non-nil if the current buffer-menu lists only file buffers.
--- 193,235 ----
    :group 'Buffer-menu
    :version "22.1")
  
! (defvar Buffer-menu-sort-column 1
!   "Which column to sort the buffer menu on.
! Sorted by (1) visit, (2) buffer, (3) size, (4) time, (5) mode, (6) file.
! This is updated when you click a column heading.")
! 
! (defvar buffer-menu-font-lock-keywords
!   (list
!    (list "^\\(CRM.*\\)" 1 'buffer-menu-headings)
!    (list "^....\\(.*[^ \t\n]\\)[ \t]+[0-9]+[ \t]+\\(.* \\(AM\\|PM\\)\\)?\\([^/\n]+\\)"
!              (list 1 'buffer-menu-buffer-name)) ; Default buffer name
!    (list "^....\\(.*[^ \t\n]\\)[ \t]+[0-9]+[ \t]+[a-zA-Z :0-9]*[ \t]+Dired"
!          1 'buffer-menu-directory-buffer t t) ; Directory buffer name
!    (list "^....\\(\\*.*[^ \t\n]\\*\\)[ \t]+" 1 'buffer-menu-star-buffer t t) ; Star buffer name
!    (list "^.*[ \t][0-9]+[ \t]+\\(.* \\(AM\\|PM\\)\\)?\\([^\n]+\\)"
!          (list 1 'buffer-menu-time t t) ; Time
!          (list 3 'buffer-menu-mode t t)) ; Mode
!    (list "^.*[ \t]\\([0-9]+\\)[ \t]+[^/\n]+" 1 'buffer-menu-size t t) ; Size
!    (list "^.*[ \t][0-9]+[ \t]+[^/\n]+[ \t\n]\\(\\([~]\\|\\([a-zA-Z]:\\)\\)*/.*\\)$"
!          1 'buffer-menu-file-name t t) ; File name
!    (list "^\\([.]\\)" 1 'buffer-menu-current-buffer t t) ; Current buffer mark (.)
!    (list "^\\(>\\)" 1 'buffer-menu-view-mark t t) ; To view mark (>)
!    (list "^>...\\(.*[^ \t\n]\\)[ \t]+[0-9]+[ \t]+\\(.* \\(AM\\|PM\\)\\)?\\([^/\n]+\\)"
!          (list 1 'buffer-menu-marked-buffer 'prepend t)) ; Buffer name when marked (>)
!    (list "^D...\\(.*[^ \t\n]\\)[ \t]+[0-9]+[ \t]+\\(.* \\(AM\\|PM\\)\\)?\\([^/\n]+\\)"
!          (list 1 'buffer-menu-flagged-buffer t t)) ; Buffer name when flagged (D)
!    (list "^\\(D\\)" 1 'buffer-menu-delete-mark t t) ; Deletion flag (D)
!    (list "^..\\(S\\)" 1 'buffer-menu-save-mark t t) ; Save flag (S)
!    (list "^..\\([*]\\)" 1 'buffer-menu-modified-mark t t) ; Buffer-modified-p (*)
!    (list "^.\\(%\\)" 1 'buffer-menu-read-only-mark t t) ; Read-only-p (%)
!    ) "*Expressions to highlight in Buffer Menu mode.")
! 
! (defvar Buffer-menu-overlay nil
!   "Overlay to highlight line of buffer during popup of `mouse-3' menu.")
  
  (defconst Buffer-menu-buffer-column 4)
  
! (defvar Buffer-menu-mode-map nil "Local keymap for `Buffer-menu-mode' buffers.")
  
  (defvar Buffer-menu-files-only nil
    "Non-nil if the current buffer-menu lists only file buffers.
***************
*** 157,162 ****
--- 277,284 ----
    (define-key Buffer-menu-mode-map "T" 'Buffer-menu-toggle-files-only)
    (define-key Buffer-menu-mode-map [mouse-2] 'Buffer-menu-mouse-select)
    (define-key Buffer-menu-mode-map [follow-link] 'mouse-face)
+   (define-key Buffer-menu-mode-map [down-mouse-3] 'Buffer-menu-mouse-3-menu)
+   (define-key Buffer-menu-mode-map [mouse-3] 'ignore)
  )
  
  ;; Buffer Menu mode is suitable only for specially formatted data.
***************
*** 165,209 ****
  (defun Buffer-menu-mode ()
    "Major mode for editing a list of buffers.
  Each line describes one of the buffers in Emacs.
! Letters do not insert themselves; instead, they are commands.
  \\<Buffer-menu-mode-map>
! \\[Buffer-menu-mouse-select] -- select buffer you click on, in place of the buffer menu.
! \\[Buffer-menu-this-window] -- select current line's buffer in place of the buffer menu.
! \\[Buffer-menu-other-window] -- select that buffer in another window,
!   so the buffer menu buffer remains visible in its window.
  \\[Buffer-menu-view] -- select current line's buffer, but in view-mode.
  \\[Buffer-menu-view-other-window] -- select that buffer in
    another window, in view-mode.
- \\[Buffer-menu-switch-other-window] -- make another window display that buffer.
- \\[Buffer-menu-mark] -- mark current line's buffer to be displayed.
- \\[Buffer-menu-select] -- select current line's buffer.
-   Also show buffers marked with m, in other windows.
- \\[Buffer-menu-1-window] -- select that buffer in full-frame window.
- \\[Buffer-menu-2-window] -- select that buffer in one window,
-   together with buffer selected before this one in another window.
- \\[Buffer-menu-visit-tags-table] -- visit-tags-table this buffer.
- \\[Buffer-menu-not-modified] -- clear modified-flag on that buffer.
- \\[Buffer-menu-save] -- mark that buffer to be saved, and move down.
- \\[Buffer-menu-delete] -- mark that buffer to be deleted, and move down.
- \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted, and move up.
- \\[Buffer-menu-execute] -- delete or save marked buffers.
- \\[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-revert] -- update the list of buffers.
  \\[Buffer-menu-toggle-files-only] -- toggle whether the menu displays only file 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)
    (setq mode-name "Buffer Menu")
!   (set (make-local-variable 'revert-buffer-function)
!        'Buffer-menu-revert-function)
!   (set (make-local-variable 'buffer-stale-function)
!        #'(lambda (&optional noconfirm) 'fast))
    (setq truncate-lines t)
    (setq buffer-read-only t)
    (run-mode-hooks 'buffer-menu-mode-hook))
  
  ;; This function exists so we can make the doc string of Buffer-menu-mode
--- 287,376 ----
  (defun Buffer-menu-mode ()
    "Major mode for editing a list of buffers.
  Each line describes one of the buffers in Emacs.
! In Buffer menu mode, chars do not insert themselves, but are commands.
  \\<Buffer-menu-mode-map>
! \(\"Current line\" here is the line of the text cursor or the mouse.)
! 
! If `Buffer-menu-use-header-line' is non-nil, you can click a column
! heading to sort by that column.  Clicking again reverses the sort
! direction.  The current sort column is indicated by an underlined or
! overlined column heading.  Note that sorting by column `CRM' depends
! on the value of option `Buffer-menu-use-frame-buffer-list'.  (Column
! sorting is not available in Emacs prior to release 22.)
! 
! Press `mouse-3' for a popup menu that provides most of the functions
! listed below.
! 
! Display buffers:
! ---------------
! \\[Buffer-menu-mouse-select], \\[Buffer-menu-select], \\[Buffer-menu-this-window] -- \
! Select current line's buffer.
! \\[Buffer-menu-mark]\t-- Mark current line's buffer `>' to be displayed (via \
! `\\[Buffer-menu-select]').
! \\[Buffer-menu-select]\t-- Show buffers marked `>'.  Select current line's \
! buffer.
! \\[Buffer-menu-1-window]\t-- Select current line's buffer (only) in a \
! full-frame window.
! \\[Buffer-menu-2-window]\t-- Select current line's buffer in one window.
! \t   Display previous buffer in a second window.
! \\[Buffer-menu-switch-other-window]\t-- Display current line's buffer in \
! another window.  No select.
  \\[Buffer-menu-view] -- select current line's buffer, but in view-mode.
  \\[Buffer-menu-view-other-window] -- select that buffer in
    another window, in view-mode.
  \\[Buffer-menu-toggle-files-only] -- toggle whether the menu displays only file buffers.
! 
! Mark/Unmark buffers to be Saved/Deleted:
! ---------------------------------------
! \\[Buffer-menu-save]\t-- Mark current line's buffer `S' to be saved.    \
! Cursor down.
! \\[Buffer-menu-delete]\t-- Mark current line's buffer `D' to be deleted.  \
! Cursor down.
! \\[Buffer-menu-delete-backwards]\t-- Mark current line's buffer `D' to be \
! deleted.  Cursor up.
! \\[Buffer-menu-unmark]\t-- Unmark current line.  Cursor down. (Prefix arg: \
! Cursor up.)
! \\[Buffer-menu-backup-unmark]\t-- Cursor up, then unmark line.
! 
! Save/Delete buffers:
! -------------------
! \\[Buffer-menu-execute]\t-- Save / Delete marked buffers (marks `S', `D').
! 
! Miscellaneous:
! -------------
! \\[Buffer-menu-revert] -- Update the list of buffers.
! \\[Buffer-menu-not-modified]\t-- Clear modified-flag on current line's buffer.
! \\[Buffer-menu-toggle-read-only]\t-- Toggle read-only status of current \
! line's buffer.
! \\[Buffer-menu-visit-tags-table]\t-- `visit-tags-table' using current line's \
! buffer.
! 
! 
! Bindings in Buffer Menu mode:
! ----------------------------
! 
! \\{Buffer-menu-mode-map}"
    (kill-all-local-variables)
    (use-local-map Buffer-menu-mode-map)
    (setq major-mode 'Buffer-menu-mode)
    (setq mode-name "Buffer Menu")
!   (save-excursion
!     (goto-char (point-min))
!     (unless Buffer-menu-use-header-line (forward-line 2)) ; First two lines are title, unless use header line.
!     (while (not (eobp))
!       (put-text-property (point) (save-excursion (end-of-line) (point)) 'mouse-face 'highlight)
!       (forward-line 1)))
!   (set (make-local-variable 'revert-buffer-function) 'Buffer-menu-revert-function)
!   (set (make-local-variable 'buffer-stale-function) #'(lambda (&optional noconfirm) 'fast))
    (setq truncate-lines t)
    (setq buffer-read-only t)
+   (save-window-excursion
+     (save-excursion
+       (pop-to-buffer "*Buffer List*")
+       (setq font-lock-defaults '(buffer-menu-font-lock-keywords t))
+       (turn-on-font-lock)
+       (when (and (fboundp 'fit-frame) (one-window-p t)) (fit-frame))
+       (raise-frame)))
    (run-mode-hooks 'buffer-menu-mode-hook))
  
  ;; This function exists so we can make the doc string of Buffer-menu-mode
***************
*** 269,293 ****
  
  (defun buffer-menu (&optional arg)
    "Make a menu of buffers so you can save, delete or select them.
! With argument, show only buffers that are visiting files.
! Type ? after invocation to get help on commands available.
! Type q to remove the buffer menu from the display.
! 
! The first column shows `>' for a buffer you have
! marked to be displayed, `D' for one you have marked for
! deletion, and `.' for the current buffer.
! 
! The C column has a `.' for the buffer from which you came.
! The R column has a `%' if the buffer is read-only.
! The M column has a `*' if it is modified,
! or `S' if you have marked it for saving.
  After this come the buffer name, its size in characters,
! its major mode, and the visited file name (if any)."
    (interactive "P")
! ;;;  (setq Buffer-menu-window-config (current-window-configuration))
!   (switch-to-buffer (list-buffers-noselect arg))
!   (message
!    "Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %%; q to quit; ? for help."))
  
  (defun buffer-menu-other-window (&optional arg)
    "Display a list of buffers in another window.
--- 436,478 ----
  
  (defun buffer-menu (&optional arg)
    "Make a menu of buffers so you can save, delete or select them.
! By default (no or null prefix arg), the buffers are listed in order of
! last access (visit).  With a non-nil prefix ARG:
!   ARG >= 0  means only buffers visiting files are listed.
!   ARG <= 0  means the buffers are listed alphabetically.
!  (ARG = 0   means only buffers visiting files, listed alphabetically.)
! 
! You can click a column heading to sort by that column.  Clicking again
! reverses the sort direction.  The current sort column is indicated by
! an underlined or overlined column heading.
! 
! The C column shows `>' if you have marked the buffer to be displayed,
!   `D' if you have marked it for deletion, and `.' for the buffer
!   from which you came.
! The R column shows `%' if the buffer is read-only.
! The M column shows `*' if the buffer is modified, or `S' if you have
!   marked it for saving.
  After this come the buffer name, its size in characters,
! its major mode, and the visited file name (if any).
! 
! Type `?' in buffer \"*Buffer List*\" to get help on available commands.
! Type `q' there to quit the buffer menu."
    (interactive "P")
!   (let ((num-arg (prefix-numeric-value arg)))
!     (if (and arg (< num-arg 0)) (list-buffers) (list-buffers arg))
!     (let ((newpoint (save-excursion (set-buffer "*Buffer List*") (point))))
!       (pop-to-buffer "*Buffer List*")
!       (when (and arg (not (> num-arg 0))) ; Sort lines after header.
!         (let ((buffer-read-only nil))
!           (goto-char (point-min))
!           (unless Buffer-menu-use-header-line (forward-line 2)) ; Header.
!           (forward-char 4)
!           (sort-columns nil (point) (save-excursion (goto-char (point-max))
!                                                     (when (bolp) (backward-char 1))
!                                                     (point)))))
!       (goto-char newpoint)))
!   (message "Help: ?;   Menu: mouse-3;   Show: v;   Mark: u,m,s,d;   \
! Save/Delete: x;   Misc: g,~,%%,t"))
  
  (defun buffer-menu-other-window (&optional arg)
    "Display a list of buffers in another window.
***************
*** 397,403 ****
      (forward-line)))
  
  (defun Buffer-menu-execute ()
!   "Save and/or delete buffers marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-save] or \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands."
    (interactive)
    (save-excursion
      (Buffer-menu-beginning)
--- 582,592 ----
      (forward-line)))
  
  (defun Buffer-menu-execute ()
!   "Save or delete buffers marked `S' or `D', respectively.
! Buffers can be marked using commands `\\<Buffer-menu-mode-map>\
! \\[Buffer-menu-save]' and `\\<Buffer-menu-mode-map>\\[Buffer-menu-delete]'
! \(or `\\<Buffer-menu-mode-map>\\[Buffer-menu-mouse-save]' and \
! `\\<Buffer-menu-mode-map>\\[Buffer-menu-mouse-delete]')."
    (interactive)
    (save-excursion
      (Buffer-menu-beginning)
***************
*** 429,437 ****
  
  (defun Buffer-menu-select ()
    "Select this line's buffer; also display buffers marked with `>'.
! You can mark buffers with the \\<Buffer-menu-mode-map>\\[Buffer-menu-mark] command.
! This command deletes and replaces all the previously existing windows
! in the selected frame."
    (interactive)
    (let ((buff (Buffer-menu-buffer t))
  	(menu (current-buffer))
--- 618,626 ----
  
  (defun Buffer-menu-select ()
    "Select this line's buffer; also display buffers marked with `>'.
! You can mark buffers with command `\\<Buffer-menu-mode-map>\\[Buffer-menu-mark]'.
! If the window is `window-dedicated-p', then another window is used;
! else, all windows previously in the frame are replaced by this one."
    (interactive)
    (let ((buff (Buffer-menu-buffer t))
  	(menu (current-buffer))
***************
*** 444,462 ****
  	(delete-char -1)
  	(insert ?\s))
        (or (eq tem buff) (memq tem others) (setq others (cons tem others))))
!     (setq others (nreverse others)
! 	  tem (/ (1- (frame-height)) (1+ (length others))))
      (delete-other-windows)
      (switch-to-buffer buff)
!     (or (eq menu buff)
! 	(bury-buffer menu))
      (if (equal (length others) 0)
  	(progn
  ;;;	  ;; Restore previous window configuration before displaying
  ;;;	  ;; selected buffers.
  ;;;	  (if Buffer-menu-window-config
! ;;;	      (progn
! ;;;		(set-window-configuration Buffer-menu-window-config)
  ;;;		(setq Buffer-menu-window-config nil)))
  	  (switch-to-buffer buff))
        (while others
--- 633,657 ----
  	(delete-char -1)
  	(insert ?\s))
        (or (eq tem buff) (memq tem others) (setq others (cons tem others))))
!     (setq others (nreverse others))
!     (cond ((window-dedicated-p (selected-window)) ; Can't split dedicated win.
!            (pop-to-buffer buff)
!            (unless (eq menu buff) (bury-buffer menu))
!            (while others
!              (pop-to-buffer (car others))
!              (pop others)))
!           (t
!            (setq tem (/ (1- (frame-height)) (1+ (length others))))
             (delete-other-windows)
             (switch-to-buffer buff)
!            (unless (eq menu buff) (bury-buffer menu))
             (if (equal (length others) 0)
                 (progn
  ;;;              ;; Restore previous window configuration before displaying
  ;;;              ;; selected buffers.
  ;;;              (if Buffer-menu-window-config
! ;;;                  (progn (set-window-configuration
! ;;;                            Buffer-menu-window-config)
  ;;;                         (setq Buffer-menu-window-config nil)))
                   (switch-to-buffer buff))
               (while others
***************
*** 464,471 ****
  	(other-window 1)
  	(switch-to-buffer (car others))
  	(setq others (cdr others)))
!       (other-window 1)  			;back to the beginning!
! )))
  
  
  
--- 659,665 ----
                 (other-window 1)
                 (switch-to-buffer (car others))
                 (setq others (cdr others)))
!              (other-window 1))))))
  
  
  
***************
*** 561,573 ****
          (insert line))
        (message "Buried buffer moved to the end"))))
  
- 
  (defun Buffer-menu-view ()
    "View this line's buffer in View mode."
    (interactive)
    (view-buffer (Buffer-menu-buffer t)))
  
- 
  (defun Buffer-menu-view-other-window ()
    "View this line's buffer in View mode in another window."
    (interactive)
--- 755,765 ----
***************
*** 615,627 ****
  	  size))
  
  (defun Buffer-menu-sort (column)
!   "Sort the buffer menu by COLUMN."
    (interactive "P")
    (when column
      (setq column (prefix-numeric-value column))
!     (if (< column 2) (setq column 2))
!     (if (> column 5) (setq column 5)))
!   (setq Buffer-menu-sort-column column)
    (let (buffer-read-only l buf m1 m2)
      (save-excursion
        (Buffer-menu-beginning)
--- 807,823 ----
  	  size))
  
  (defun Buffer-menu-sort (column)
!   "Sort the buffer menu by COLUMN.
! Consecutive executions of the same COLUMN reverse the sort order."
    (interactive "P")
    (when column
      (setq column (prefix-numeric-value column))
!     (when (= column 0) (setq column 1))
!     (when (> column 6) (setq column 6))
!     (when (< column -6) (setq column -6)))
!   (if (equal Buffer-menu-sort-column column)
!       (setq Buffer-menu-sort-column (- column))
!     (setq Buffer-menu-sort-column column))
    (let (buffer-read-only l buf m1 m2)
      (save-excursion
        (Buffer-menu-beginning)
***************
*** 650,656 ****
  	    (forward-char 2)
  	    (delete-char 1)
  	    (insert m2)))
! 	(forward-line)))))
  
  (defun Buffer-menu-sort-by-column (&optional e)
    "Sort the buffer menu by the column clicked on."
--- 846,861 ----
  	    (forward-char 2)
  	    (delete-char 1)
  	    (insert m2)))
! 	(forward-line))))
!   (message "Buffers are now sorted %s%s."
!            (case (abs column)
!              (1 "by time of last visit - see `Buffer-menu-use-frame-buffer-list'")
!              (2 "by buffer name")
!              (3 "by size")
!              (4 "by time of last display")
!              (5 "by major-mode name")
!              (otherwise "by associated file (including path)"))
!            (if (natnump Buffer-menu-sort-column) ", ascending" ", descending")))
  
  (defun Buffer-menu-sort-by-column (&optional e)
    "Sort the buffer menu by the column clicked on."
***************
*** 675,691 ****
      map)
    "Local keymap for Buffer menu sort buttons.")
  
! (defun Buffer-menu-make-sort-button (name column)
!   (if (equal column Buffer-menu-sort-column) (setq column nil))
    (propertize name
! 	      'column column
! 	      'help-echo (concat
! 			  (if Buffer-menu-use-header-line
! 			      "mouse-1, mouse-2: sort by "
! 			    "mouse-2, RET: sort by ")
! 			  (if column (downcase name) "visited order"))
  	      'mouse-face 'highlight
! 	      'keymap Buffer-menu-sort-button-map))
  
  (defun list-buffers-noselect (&optional files-only buffer-list)
    "Create and return a buffer with a list of names of existing buffers.
--- 880,913 ----
      map)
    "Local keymap for Buffer menu sort buttons.")
  
! (defun Buffer-menu-make-sort-button (name button-column)
!   (let ((the-sort-column-p nil))
!     (when (equal button-column (abs Buffer-menu-sort-column))
!       (setq the-sort-column-p t)
!       (setq button-column (- button-column)))
      (propertize name
!                 'column button-column
!                 'help-echo
!                 (case (abs button-column)
!                   (1 (if Buffer-menu-use-header-line
!                          "mouse-1, mouse-2: sort by time of last visit - \
! see `Buffer-menu-use-frame-buffer-list'"
!                        "mouse-2, RET: sort by time of last visit - \
! see `Buffer-menu-use-frame-buffer-list'"))
!                   (2 (if Buffer-menu-use-header-line
!                          "mouse-1, mouse-2: sort by buffer name"
!                        "mouse-2, RET: sort by buffer name"))
!                   (4 "mouse-1, mouse-2: sort by time of last display/access")
!                   (t (if Buffer-menu-use-header-line
!                          (concat "mouse-1, mouse-2: sort by " (downcase name))
!                        (concat "mouse-2, RET: sort by " (downcase name)))))
                  'mouse-face 'highlight
!                 (when the-sort-column-p 'face)
!                 (when the-sort-column-p
!                   (if (natnump Buffer-menu-sort-column)
!                       '(:underline t)
!                     '(:overline t)))
!                 'keymap Buffer-menu-sort-button-map)))
  
  (defun list-buffers-noselect (&optional files-only buffer-list)
    "Create and return a buffer with a list of names of existing buffers.
***************
*** 700,713 ****
    (let* ((old-buffer (current-buffer))
  	 (standard-output standard-output)
  	 (mode-end (make-string (- Buffer-menu-mode-width 2) ?\s))
! 	 (header (concat "CRM "
  			 (Buffer-menu-buffer+size
  			  (Buffer-menu-make-sort-button "Buffer" 2)
  			  (Buffer-menu-make-sort-button "Size" 3))
  			 "  "
! 			 (Buffer-menu-make-sort-button "Mode" 4) mode-end
! 			 (Buffer-menu-make-sort-button "File" 5) "\n"))
! 	 list desired-point)
      (when Buffer-menu-use-header-line
        (let ((pos 0))
  	;; Turn whitespace chars in the header into stretch specs so
--- 922,936 ----
    (let* ((old-buffer (current-buffer))
  	 (standard-output standard-output)
  	 (mode-end (make-string (- Buffer-menu-mode-width 2) ?\s))
! 	 (header (concat (Buffer-menu-make-sort-button "CRM" 1) " "
  			 (Buffer-menu-buffer+size
  			  (Buffer-menu-make-sort-button "Buffer" 2)
  			  (Buffer-menu-make-sort-button "Size" 3))
  			 "  "
!                          (Buffer-menu-make-sort-button "Time" 4) "             "
! 			 (Buffer-menu-make-sort-button "Mode" 5) mode-end
! 			 (Buffer-menu-make-sort-button "File" 6) "\n"))
! 	 list desired-point name buffer-time mode file)
      (when Buffer-menu-use-header-line
        (let ((pos 0))
  	;; Turn whitespace chars in the header into stretch specs so
***************
*** 718,725 ****
  			     ;; Assume fixed-size chars in the buffer.
  			     (list 'space :align-to pos)
  			     header)))
-       ;; Try to better align the one-char headers.
-       (put-text-property 0 3 'face 'fixed-pitch header)
        ;; Add a "dummy" leading space to align the beginning of the header
        ;; line with the beginning of the text (rather than with the left
        ;; scrollbar or the left fringe).  --Stef
--- 941,946 ----
***************
*** 730,747 ****
        (erase-buffer)
        (setq standard-output (current-buffer))
        (unless Buffer-menu-use-header-line
          ;; Use U+2014 (EM DASH) to underline if possible, else use ASCII
          ;; (i.e. U+002D, HYPHEN-MINUS).
! 	(let ((underline (if (char-displayable-p ?\u2014) ?\u2014 ?-)))
  	  (insert header
  		  (apply 'string
  			 (mapcar (lambda (c)
  				   (if (memq c '(?\n ?\s)) c underline))
  				 header)))))
        ;; Collect info for every buffer we're interested in.
        (dolist (buffer (or buffer-list
  			  (buffer-list
! 			   (when Buffer-menu-use-frame-buffer-list
  			     (selected-frame)))))
  	(with-current-buffer buffer
  	  (let ((name (buffer-name))
--- 951,974 ----
        (erase-buffer)
        (setq standard-output (current-buffer))
        (unless Buffer-menu-use-header-line
+         ;; Only Emacs > 21 has `char-displayable' and U+2014.
          ;; Use U+2014 (EM DASH) to underline if possible, else use ASCII
          ;; (i.e. U+002D, HYPHEN-MINUS).
! 	(let ((underline (if (and (fboundp 'char-displayable-p)
!                                   (char-displayable-p ?\u2014))
!                              ?\u2014    ; EM dash
!                            ?-)))        ; regular dash
  	  (insert header
  		  (apply 'string
  			 (mapcar (lambda (c)
  				   (if (memq c '(?\n ?\s)) c underline))
  				 header)))))
+       (if buffer-list
+           (setq list buffer-list)
          ;; Collect info for every buffer we're interested in.
          (dolist (buffer (or buffer-list
                              (buffer-list
!                              (and Buffer-menu-use-frame-buffer-list
                                    (selected-frame)))))
            (with-current-buffer buffer
              (let ((name (buffer-name))
***************
*** 754,761 ****
  			  (and files-only (not file))
  			  (string= name "*Buffer List*")))
  	      ;; Otherwise output info.
! 	      (let ((mode (concat (format-mode-line mode-name nil nil buffer)
! 				  (if mode-line-process
  				      (format-mode-line mode-line-process
  							nil nil buffer))))
  		    (bits (string
--- 981,996 ----
                              (and files-only (not file))
                              (string= name "*Buffer List*")))
                  ;; Otherwise output info.
!                 (let (;; Need to record two values for time: numerical time value, for
!                       ;; sorting, and string time value, for display.
!                       (buffer-time (cons (or (float-time buffer-display-time) 0)
!                                          (if buffer-display-time
!                                              (format-time-string
!                                               "%_3a %_2k:%02M:%02S %_2p"
!                                               buffer-display-time)
!                                            "               ")))
!                       (mode (concat (format-mode-line mode-name nil nil buffer)
!                                     (and mode-line-process
                                           (format-mode-line mode-line-process
                                                             nil nil buffer))))
                        (bits (string
***************
*** 788,818 ****
  			   (setq file "*Info History*"))
  			  ((eq file 'toc)
  			   (setq file "*Info TOC*"))
! 			  ((not (stringp file))  ;; avoid errors
  			   (setq file nil))
  			  (t
  			   (setq file (concat "("
  					      (file-name-nondirectory file)
  					      ")"
  					      Info-current-node)))))))
! 		(push (list buffer bits name (buffer-size) mode file)
  		      list))))))
!       ;; Preserve the original buffer-list ordering, just in case.
!       (setq list (nreverse list))
        ;; Place the buffers's info in the output buffer, sorted if necessary.
        (dolist (buffer
! 	       (if Buffer-menu-sort-column
  		   (sort list
! 			 (if (eq Buffer-menu-sort-column 3)
  			     (lambda (a b)
! 			       (< (nth Buffer-menu-sort-column a)
  				  (nth Buffer-menu-sort-column b)))
  			   (lambda (a b)
! 			     (string< (nth Buffer-menu-sort-column a)
! 				      (nth Buffer-menu-sort-column b)))))
! 		 list))
! 	(if (eq (car buffer) old-buffer)
! 	    (setq desired-point (point)))
  	(insert (cadr buffer)
  		;; Put the buffer name into a text property
  		;; so we don't have to extract it from the text.
--- 1023,1064 ----
                                (setq file "*Info History*"))
                               ((eq file 'toc)
                                (setq file "*Info TOC*"))
!                              ((not (stringp file));; avoid errors
                                (setq file nil))
                               (t
                                (setq file (concat "("
                                                   (file-name-nondirectory file)
                                                   ")"
                                                   Info-current-node)))))))
!                   (push (list buffer bits name (buffer-size) buffer-time mode file)
                          list))))))
!         ;; Preserve original list order (by reversing).
!         ;; Flip it if Buffer-menu-sort-column = -1.
!         (unless (eq -1 Buffer-menu-sort-column) (setq list (nreverse list))))
        ;; Place the buffers's info in the output buffer, sorted if necessary.
        (dolist (buffer
!                 (if (eq 1 (abs Buffer-menu-sort-column))
!                     list
!                   (let* ((descending-p (natnump Buffer-menu-sort-column))
!                          (Buffer-menu-sort-column (abs Buffer-menu-sort-column)))
                      (sort list
!                           (cond ((eq Buffer-menu-sort-column 3) ; Size
!                                  (if descending-p
!                                      (lambda (a b) (< (nth 3 a) (nth 3 b)))
!                                    (lambda (a b) (< (nth 3 b) (nth 3 a)))))
!                                 ((eq Buffer-menu-sort-column 4) ; Time (value)
!                                  (if descending-p
!                                      (lambda (a b) (< (car (nth 4 a)) (car (nth 4 b))))
!                                    (lambda (a b) (< (car (nth 4 b)) (car (nth 4 a))))))
!                                 (t
!                                  (if descending-p
                                       (lambda (a b)
!                                        (string< (nth Buffer-menu-sort-column a)
                                                  (nth Buffer-menu-sort-column b)))
                                     (lambda (a b)
!                                      (string< (nth Buffer-menu-sort-column b)
!                                               (nth Buffer-menu-sort-column a))))))))))
!         (when (eq (car buffer) old-buffer) (setq desired-point (point)))
          (insert (cadr buffer)
                  ;; Put the buffer name into a text property
                  ;; so we don't have to extract it from the text.
***************
*** 825,848 ****
  					   mouse-face highlight
  					   help-echo "mouse-2: select this buffer"))
  		"  "
! 		(if (> (length (nth 4 buffer)) Buffer-menu-mode-width)
! 		    (substring (nth 4 buffer) 0 Buffer-menu-mode-width)
! 		  (nth 4 buffer)))
! 	(when (nth 5 buffer)
  	  (indent-to (+ Buffer-menu-buffer-column Buffer-menu-buffer+size-width
! 			Buffer-menu-mode-width 4) 1)
! 	  (princ (abbreviate-file-name (nth 5 buffer))))
  	(princ "\n"))
        (Buffer-menu-mode)
        (when Buffer-menu-use-header-line
  	(setq header-line-format header))
!       ;; DESIRED-POINT doesn't have to be set; it is not when the
        ;; current buffer is not displayed for some reason.
!       (and desired-point
! 	   (goto-char desired-point))
        (setq Buffer-menu-files-only files-only)
        (set-buffer-modified-p nil)
        (current-buffer))))
  
  ;; arch-tag: e7dfcfc9-6cb2-46e4-bf55-8ef1936d83c6
  ;;; buff-menu.el ends here
--- 1071,1245 ----
                                             mouse-face highlight
                                             help-echo "mouse-2: select this buffer"))
                  "  "
!                 (cdr (nth 4 buffer)) "  " ; Time
!                 (if (> (length (nth 5 buffer)) Buffer-menu-mode-width) ; Mode
!                     (substring (nth 5 buffer) 0 Buffer-menu-mode-width)
!                   (nth 5 buffer)))
!         (when (nth 6 buffer)
            (indent-to (+ Buffer-menu-buffer-column Buffer-menu-buffer+size-width
!                         Buffer-menu-mode-width 17 4) 1)
!           (princ (abbreviate-file-name (nth 6 buffer))))
          (princ "\n"))
        (Buffer-menu-mode)
        (when Buffer-menu-use-header-line
          (setq header-line-format header))
!       ;; DESIRED-POINT doesn't have to be set; it is not set when the
        ;; current buffer is not displayed for some reason.
!       (goto-char (or desired-point (point-min)))
        (setq Buffer-menu-files-only files-only)
        (set-buffer-modified-p nil)
        (current-buffer))))
  
+ 
+ (defun Buffer-menu-mouse-3-menu (event)
+   "Pop up menu for Mouse-3 for buffer listed in buffer menu."
+   (interactive "e")
+   (let* ((mouse-pos (event-start event))
+          bol eol temp
+          (buffer-name
+           (save-excursion
+             (set-buffer (window-buffer (posn-window mouse-pos)))
+             (save-excursion
+               (goto-char (posn-point mouse-pos))
+               (save-excursion
+                 (setq bol (progn (beginning-of-line) (point)))
+                 (setq eol (progn (end-of-line) (point))))
+               (if Buffer-menu-overlay   ; Don't recreate if exists.
+                   (move-overlay Buffer-menu-overlay bol eol (current-buffer))
+                 (setq Buffer-menu-overlay (make-overlay bol eol))
+                 (overlay-put Buffer-menu-overlay 'face 'region))
+               (setq temp (and (not (eobp)) (Buffer-menu-buffer nil)))
+               ;; Nil if mouse is not on a buffer name.
+               (and temp (buffer-name temp)))))) ; temp no longer used.
+     (sit-for 0)
+     (let ((selection
+            (x-popup-menu
+             event
+             (list
+              "Menu"
+              (if buffer-name
+                  (list
+                   buffer-name
+                   '("Select Buffer" . Buffer-menu-mouse-select)
+                   '("Unmark Buffer" . Buffer-menu-mouse-unmark)
+                   '("Mark to Save Buffer (S)" . Buffer-menu-mouse-save)
+                   '("Mark to Delete Buffer (D)" . Buffer-menu-mouse-delete)
+                   '("Mark as Modified/Unmodified (*)" .
+                     Buffer-menu-mouse-modified)
+                   '("--")               ; Separator: next not buffer-specific.
+                   '("Execute: Save/Delete Marked Buffers" .
+                     Buffer-menu-mouse-execute))
+                (list "" '("Execute: Save/Delete Marked Buffers" .
+                           Buffer-menu-mouse-execute)))))))
+       (when Buffer-menu-overlay (delete-overlay Buffer-menu-overlay))
+       (and selection (call-interactively selection)))))
+ 
+ (defun Buffer-menu-mouse-unmark (event)
+   "Cancel all requested operations on buffer."
+   (interactive "e")
+   (let (buffer)
+     (save-excursion
+       (set-buffer (window-buffer (posn-window (event-end event))))
+       (save-excursion
+         (goto-char (posn-point (event-end event)))
+         (setq buffer (Buffer-menu-buffer t))))
+     (select-window (posn-window (event-end event)))
+     (goto-char (posn-point (event-end event)))
+     (beginning-of-line)
+     (if (looking-at " [-M]")            ;header lines
+         (ding)
+       (let* ((mod (buffer-modified-p buffer))
+              (readonly (save-excursion (set-buffer buffer) buffer-read-only))
+              (buffer-read-only nil))
+         (delete-char 3)
+         (insert (if readonly (if mod " *%" "  %") (if mod " * " "   ")))))
+     (beginning-of-line)))
+ 
+ (defun Buffer-menu-mouse-save (event)
+   "Mark buffer to be saved.
+ Actual deletion is done via `\\<Buffer-menu-mode-map>\\[Buffer-menu-execute]' \
+ or `\\<Buffer-menu-mode-map>\\[Buffer-menu-mouse-execute]'."
+   (interactive "e")
+   (select-window (posn-window (event-end event)))
+   (goto-char (posn-point (event-end event)))
+   (beginning-of-line)
+   (forward-char 1)
+   (if (looking-at " [-M]")              ;header lines
+       (ding)
+     (let ((buffer-read-only nil))
+       (delete-char 1)
+         (insert ?S)))
+   (beginning-of-line))
+ 
+ (defun Buffer-menu-mouse-delete (event)
+   "Mark buffer to be deleted.
+ Actual deletion is done via `\\<Buffer-menu-mode-map>\\[Buffer-menu-execute]' \
+ or `\\<Buffer-menu-mode-map>\\[Buffer-menu-mouse-execute]'."
+   (interactive "e")
+   (select-window (posn-window (event-end event)))
+   (goto-char (posn-point (event-end event)))
+   (beginning-of-line)
+   (if (looking-at " [-M]")              ;header lines
+       (ding)
+     (let ((buffer-read-only nil))
+       (delete-char 1)
+       (insert ?D)))
+   (beginning-of-line))
+ 
+ (defun Buffer-menu-mouse-modified (event)
+   "Mark buffer as unmodified (no changes to save) if modified, and vice versa."
+   (interactive "e")
+   (select-window (posn-window (event-end event)))
+   (goto-char (posn-point (event-end event)))
+   (beginning-of-line)
+   (forward-char 1)
+   (let ((buffer-read-only nil)
+         modified-p)
+     (save-excursion
+       (set-buffer (Buffer-menu-buffer t))
+       (set-buffer-modified-p (not (buffer-modified-p))))
+     (cond ((= ?\* (char-after (point)))
+            (delete-char 1)
+            (insert ?\ ))
+           (t
+            (delete-char 1)
+            (insert ?\*))))
+   (beginning-of-line))
+ 
+ (defun Buffer-menu-mouse-execute (event)
+   "Save and/or delete buffers marked `S' or `D', respectively.
+ Buffers can be marked via commands `\\<Buffer-menu-mode-map>\
+ \\[Buffer-menu-save]' and `\\<Buffer-menu-mode-map>\\[Buffer-menu-delete]'
+ \(or `\\<Buffer-menu-mode-map>\\[Buffer-menu-mouse-save]' and \
+ `\\<Buffer-menu-mode-map>\\[Buffer-menu-mouse-delete]')."
+   (interactive "e")
+   (select-window (posn-window (event-end event)))
+   (save-excursion
+     (Buffer-menu-beginning)
+     (while (if (> emacs-major-version 21)
+                (re-search-forward "^..S" nil t)
+              (re-search-forward "^.S" nil t))
+       (let ((modp nil))
+         (save-excursion
+           (set-buffer (Buffer-menu-buffer t))
+           (save-buffer)
+           (setq modp (buffer-modified-p)))
+         (let ((buffer-read-only nil))
+           (delete-char -1)
+           (insert (if modp ?* ? ))))))
+   (save-excursion
+     (Buffer-menu-beginning)
+     (let ((buff-menu-buffer (current-buffer))
+           (buffer-read-only nil))
+       (while (re-search-forward "^D" nil t)
+         (forward-char -1)
+         (let ((buf (Buffer-menu-buffer nil)))
+           (or (eq buf nil) (eq buf buff-menu-buffer)
+               (save-excursion (kill-buffer buf)))
+           (if (and buf (buffer-name buf))
+               (progn (delete-char 1) (insert ? ))
+             (delete-region (point) (progn (forward-line 1) (point)))
+             (unless (bobp) (forward-char -1))))))))
+ 
  ;; arch-tag: e7dfcfc9-6cb2-46e4-bf55-8ef1936d83c6
  ;;; buff-menu.el ends here

Diff finished at Mon Jul 09 16:13:02
