unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to make Emacs buffers menu show long filenames in full
@ 2008-04-06 20:50 Juri Linkov
  0 siblings, 0 replies; only message in thread
From: Juri Linkov @ 2008-04-06 20:50 UTC (permalink / raw)
  To: emacs-devel

I received a complaint from a Emacs user about buffer names truncated
in the Buffers menu.  I think it is justified to provide a new variable
to customize the length of buffer names in this menu and even to
provide an option to not truncate buffer names at all because usually
buffer names are not too long, unlike e.g. items in the yank-menu
whose length are limited by the existing variable `yank-menu-length'
that doesn't have an option to display in full length usually very long
multi-line elements of the kill ring.

Below is a patch that adds a new user option `buffers-menu-buffer-name-length'
with the default 30 (rounded from the currently hard-coded value 27).
Also it moves the definition of `buffers-menu-max-size' to the
"Buffers Menu" section, and changes the group name from `mouse' to
`menu':

Index: lisp/menu-bar.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/menu-bar.el,v
retrieving revision 1.327
diff -c -r1.327 menu-bar.el
*** lisp/menu-bar.el	23 Mar 2008 11:44:23 -0000	1.327
--- lisp/menu-bar.el	6 Apr 2008 20:45:52 -0000
***************
*** 30,46 ****
  
  ;;; Code:
  
- ;;; User options:
- 
- (defcustom buffers-menu-max-size 10
-   "*Maximum number of entries which may appear on the Buffers menu.
- If this is 10, then only the ten most-recently-selected buffers are shown.
- If this is nil, then all buffers are shown.
- A large number or nil slows down menu responsiveness."
-   :type '(choice integer
- 		 (const :tag "All" nil))
-   :group 'mouse)
- 
  ;; Don't clobber an existing menu-bar keymap, to preserve any menu-bar key
  ;; definitions made in loaddefs.el.
  (or (lookup-key global-map [menu-bar])
--- 30,35 ----
***************
*** 1477,1483 ****
  (defcustom yank-menu-length 20
    "*Maximum length to display in the yank-menu."
    :type 'integer
!   :group 'mouse)
  
  (defun menu-bar-update-yank-menu (string old)
    (let ((front (car (cdr yank-menu)))
--- 1466,1472 ----
  (defcustom yank-menu-length 20
    "*Maximum length to display in the yank-menu."
    :type 'integer
!   :group 'menu)
  
  (defun menu-bar-update-yank-menu (string old)
    (let ((front (car (cdr yank-menu)))
***************
*** 1514,1519 ****
--- 1503,1528 ----
    (insert last-command-event))
  
  \f
+ ;;; Buffers Menu
+ 
+ (defcustom buffers-menu-max-size 10
+   "*Maximum number of entries which may appear on the Buffers menu.
+ If this is 10, then only the ten most-recently-selected buffers are shown.
+ If this is nil, then all buffers are shown.
+ A large number or nil slows down menu responsiveness."
+   :type '(choice integer
+ 		 (const :tag "All" nil))
+   :group 'menu)
+ 
+ (defcustom buffers-menu-buffer-name-length 30
+   "*Maximum length of the buffer name on the Buffers menu.
+ If this is a number, then buffer names are truncated to this length.
+ If this is nil, then buffer names are shown in full.
+ A large number or nil makes the menu too wide."
+   :type '(choice integer
+ 		 (const :tag "Full length" nil))
+   :group 'menu)
+ 
  (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
***************
*** 1601,1611 ****
                       (unless (eq ?\s (aref name 0))
                         (push (menu-bar-update-buffers-1
                                (cons buf
!                                     (if (> (length name) 27)
!                                         (concat (substring name 0 12)
!                                                 "..."
!                                                 (substring name -12))
!                                       name)))
                               alist))))
  		 ;; Now make the actual list of items.
                   (let ((buffers-vec (make-vector (length alist) nil))
--- 1610,1625 ----
                       (unless (eq ?\s (aref name 0))
                         (push (menu-bar-update-buffers-1
                                (cons buf
! 				    (if (and (integerp buffers-menu-buffer-name-length)
! 					     (> (length name) buffers-menu-buffer-name-length))
! 					(concat
! 					 (substring
! 					  name 0 (/ buffers-menu-buffer-name-length 2))
! 					 "..."
! 					 (substring
! 					  name (- (/ buffers-menu-buffer-name-length 2))))
! 				      name)
!                                     ))
                               alist))))
  		 ;; Now make the actual list of items.
                   (let ((buffers-vec (make-vector (length alist) nil))

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-06 20:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-06 20:50 How to make Emacs buffers menu show long filenames in full Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).