The Emacs buffers menu shows two columns: One with the buffer name, and one with the filename, with full path. The paths in our projects can become very long, spanning more than one screen. So I would like to not show them in the buffers menu. How can I achieve this? Bonus: use a tooltip for the path instead.
Since Emacs comes with sources, I just took the liberty to adjust the mouse-buffer-menu. I put this in my
init.el to override the default implementation that creates the
mouse-buffer-menu-alist. This one does away with the filename and only shows the buffer name. For my needs this is enough:
(defun mouse-buffer-menu-alist (buffers) (let (tail (maxlen 0) head) (setq buffers (sort buffers (function (lambda (elt1 elt2) (string< (buffer-name elt1) (buffer-name elt2)))))) (setq tail buffers) (while tail (or (eq ?\s (aref (buffer-name (car tail)) 0)) (setq maxlen (max maxlen (length (buffer-name (car tail)))))) (setq tail (cdr tail))) (setq tail buffers) (while tail (let ((elt (car tail))) (if (/= (aref (buffer-name elt) 0) ?\s) (setq head (cons (cons (format (format "%%-%ds %%s%%s" maxlen) (buffer-name elt) (if (buffer-modified-p elt) "*" " ") (with-current-buffer elt (if buffer-read-only "%" " ")) ) elt) head)))) (setq tail (cdr tail))) ;; Compensate for the reversal that the above loop does. (nreverse head)))