emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to make Emacs buffers menu show long filenames in full


From: Juri Linkov
Subject: How to make Emacs buffers menu show long filenames in full
Date: Sun, 06 Apr 2008 23:50:27 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

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))
  
  
+ ;;; 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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]