From 68310f2a121dac224b0104c1526ad05ff0de3202 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 24 Apr 2002 05:35:03 +0000 Subject: [PATCH] (buffers-menu-show-directories, buffers-menu-show-status): New variables. (menu-bar-update-buffers-1): Use them. --- lisp/ChangeLog | 6 ++++++ lisp/menu-bar.el | 54 +++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9e59081b598..c2d67ad0e1a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2002-04-24 Miles Bader + + * menu-bar.el (buffers-menu-show-directories) + (buffers-menu-show-status): New variables. + (menu-bar-update-buffers-1): Use them. + 2002-04-24 Martin Stjernholm * progmodes/cc-cmds.el (c-mask-comment): More fixes when used diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 3618c8a5122..83eb7f069e0 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -1244,7 +1244,37 @@ key (or menu-item)")) (interactive "*") (push-mark (point)) (insert last-command-event)) + +(defcustom buffers-menu-show-directories 'unless-uniquify + "If non-nil, show directories in the Buffers menu for buffers that have them. +The special value `unless-uniquify' means that directories will be shown +unless `uniquify-buffer-name-style' is non-nil (in which case, buffer +names should include enough of a buffer's directory to distinguish it +from other buffers). + +Setting this variable directly does not take effect until next time the +Buffers menu is regenerated." + :set (lambda (symbol value) + (set symbol value) + (menu-bar-update-buffers t)) + :initialize 'custom-initialize-default + :type '(choice (const :tag "Never" nil) + (const :tag "Unless uniquify is enabled" unless-uniquify) + (const :tag "Always" t)) + :group 'menu) + +(defcustom buffers-menu-show-status t + "If non-nil, show modified/read-only status of buffers in the Buffers menu. +Setting this variable directly does not take effect until next time the +Buffers menu is regenerated." + :set (lambda (symbol value) + (set symbol value) + (menu-bar-update-buffers t)) + :initialize 'custom-initialize-default + :type 'boolean + :group 'menu) + (defvar list-buffers-directory nil) (defvar menu-bar-update-buffers-maxbuf) @@ -1264,25 +1294,29 @@ key (or menu-item)")) (select-frame frame))) (defun menu-bar-update-buffers-1 (elt) - ;; (format "%%%ds %%s%%s %%s" menu-bar-update-buffers-maxbuf) (let* ((buf (car elt)) (file - (and (or (not (boundp 'uniquify-buffer-name-style)) - (null uniquify-buffer-name-style)) + (and (if (eq buffers-menu-show-directories 'unless-uniquify) + (or (not (boundp 'uniquify-buffer-name-style)) + (null uniquify-buffer-name-style)) + buffers-menu-show-directories) (or (buffer-file-name buf) - (buffer-local-value 'list-buffers-directory buf)))) - (mod (if (buffer-modified-p buf) "*" "")) - (ro (if (buffer-local-value 'buffer-read-only buf) "%" ""))) + (buffer-local-value 'list-buffers-directory buf))))) (when file (setq file (file-name-directory file))) (when (and file (> (length file) 20)) (setq file (concat "..." (substring file -17)))) - (cons (if file - (format "%s %s%s -- %s" (cdr elt) mod ro file) - (format "%s %s%s" (cdr elt) mod ro)) + (cons (if buffers-menu-show-status + (let ((mod (if (buffer-modified-p buf) "*" "")) + (ro (if (buffer-local-value 'buffer-read-only buf) "%" ""))) + (if file + (format "%s %s%s -- %s" (cdr elt) mod ro file) + (format "%s %s%s" (cdr elt) mod ro))) + (if file + (format "%s -- %s" (cdr elt) file) + (cdr elt))) buf))) - ;; Used to cache the menu entries for commands in the Buffers menu (defvar menu-bar-buffers-menu-command-entries nil) -- 2.39.5