Skip to content

Commit

Permalink
Sort buffers menu and show checkmark next to buffer in selected window
Browse files Browse the repository at this point in the history
  • Loading branch information
davidswelt committed Apr 27, 2010
1 parent e42d6d4 commit dff71e3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lisp/menu-bar.el
Expand Up @@ -1687,11 +1687,12 @@ Buffers menu is regenerated."
;; Used to cache the menu entries for commands in the Buffers menu
(defvar menu-bar-buffers-menu-command-entries nil)

(defun menu-bar-update-buffers (&optional force)
(defun menu-bar-update-buffers (&optional force)
;; If user discards the Buffers item, play along.
(and (lookup-key (current-global-map) [menu-bar buffer])
(or force (frame-or-buffer-changed-p))
(let ((buffers (buffer-list))
;; buffers list in menu should be stable (rather than reflecting Emacs buffer ordering)
(let ((buffers (sort (buffer-list) (lambda (a b) (string< (buffer-name a) (buffer-name b)))))
(frames (frame-list))
buffers-menu)
;; If requested, list only the N most recently selected buffers.
Expand Down Expand Up @@ -1728,11 +1729,15 @@ Buffers menu is regenerated."
(dolist (pair alist)
(setq i (1- i))
(aset buffers-vec i
(nconc (list (car pair)
(cons nil nil))
`(lambda ()
(interactive)
(menu-bar-select-buffer ,(cdr pair))))))
(cons 'menu-item
(nconc (list
(car pair)
`(lambda ()
(interactive)
(menu-bar-select-buffer ,(cdr pair))))
(if (eq (window-buffer) (cdr pair)) ; menu-updating-frame is incorrect
(list :button '(:toggle . t)))
))))
(list buffers-vec))))

;; Make a Frames menu if we have more than one frame.
Expand Down

0 comments on commit dff71e3

Please sign in to comment.