BufferMenuPlus

Library buff-menu+.el (BufferMenu+) provides the following enhancements to the standard BufferMenu:

Here is a screenshot of the *Buffer List* buffer in Emacs 20:

DrewsEmacsBufferMenu.

Here is a screenshot of it in Emacs 22, showing the new time-last-accessed column and highlighting (underlining) of the sorted column.

DrewsEmacsBufferMenuSorted.

Both of these screenshots are a bit old. Now, different kinds of buffers (directory, `*...*’ name, normal) are highlighted differently, and the buffer name is also highlighted specially when you mark or flag a buffer.

Celebrity of Buffer Menu+ (humor): [1]

Search All Marked Buffers using Icicles

With Icicles, you can use ‘M-s i’ in Buffer Menu to search all marked buffers and possibly replace search hits. You have available all of the Icicles Search features, including accessing search hits directly, in any order.

Buffer Menu+ Discussion

Buffer Menu+ looks very useful. But please, please use PNG for screenshots, not JPEG.[2]

Both buff-menu+.el and recent versions (Sept. 8/2004) of buff-menu.el call the function format-mode-line. Any ideas where it can be found? Thanks. – SteveTaylor

It’s in GNU Emacs 22 and later. – DrewAdams

I’m experiencing issues when some buffers are in some nxml-derivative mode (html, xml …). After calling list-buffers, the “buffer list” window gets updated until first nxml-typed buffer. Gets interrupted (backtrace buffer pops up), (wrong-type-argument characterp sgml-xml-mode) at the top of the backtrace, full spit is available at http://gist.github.com/458598 . Switching back the nxml buffers to text-mode works around the issue. Experiencing this issue since E23.0, now at 23.2.1, I believe this may have something to do with buffer-menu+. – elie

Your backtrace suggests that the problem is in ‘bs’, not in buff-menu+.el. The code in the backtrace is all from `bs.el’, it seems.

Debugger entered--Lisp error: (wrong-type-argument characterp sgml-xml-mode)
  concat("         " (sgml-xml-mode "XHTML" "HTML"))
  (if (eq (quote right) align) (concat (make-string ... 32) string) 
  (concat string (make-string ... 32)))  (if (>= length len) string (if (eq ... align)
  (concat ... string) (concat string ...)))
  (let ((length ...)) (if (>= length len) string (if ... ... ...)))
  bs--format-aux((sgml-xml-mode "XHTML" "HTML") right 12)

Something is passing '(sgml-xml-mode "XHTML" "HTML") to ‘concat’. It tries to process that list as a list of chars, which it is not (it is a list of a symbol and two strings). – DrewAdams


Buffer-Menu+ does not work with Emacs 24. Anyone know of any plans to make it do so? – ScottRandby

1. Emacs 24 has not been released. I don’t claim to support at present.

2. That said, it works for me.

3. Be specific about what problem you think you see. “Does not work” does not help. Provide a recipe to reproduce the problem, preferably from emacs -Q. Send a bug report by clicking the Send Bug Report link in the ‘Buffer-Menu-Plus’ ‘customize-group’ buffer. – DrewAdams

I’m very sorry for not being more specific. I downloaded v21 update 2742 of buff-menu+.el and now it works perfectly. I was using v21 update 2716 and the following message appeared in the minibuffer whenever I did C-x C-b from emacs -Q.

Wrong type argument: characterp, 8388640

I am using Emacs 24 because Emacs 23.3 won’t compile on Xubuntu 11.10 without a lot of work and I don’t want to use the version in the repository. It would be nice if buff-menu+ was part of GNU Emacs. – ScottRandby


I am using version 21.0, update 2742 of buff-menu+.el on GNU Emacs 24.0.92.1. When I don’t have the package loaded and do M-x buffer-menu and sort the buffer menu by file, I get the following (which is what I want).

Directory1
File1
Directory2
File2
*scratch*
*Message*

If I load buff-menu+.el and sort the buffer menu by file (ascending), I get this (which I don’t want):

File1
File2
*scratch*
*Message*
Directory1
Directory2

Older versions of buff-menu+.el that I used with Emacs 23 sorted files the first way. Has file sorting been changed? If so, is there any way that file sorting can be done the first way? – ScottRandby

I cannot reproduce the problem. If you are talking about sorting by file/dir name, then that still works (for me) the same as always: the file and dir names are sorted lexicographically (alphabetically), either ascending or descending. File and dir names are treated the same.

Anyway, the lists you show here are not file/dir names – they are buffer names. By sorting by file name I assume you mean just that, which you do by clicking the File column header.

Perhaps I’m misunderstanding you. Please elaborate/clarify. Thx – DrewAdams

Yes, the names are buffer names and the sort is done when I click on the File column header. So what is happening is that all the buffer names associated with files appear at the top of the list and all the buffer names associated with directories appear at the bottom of the list when buff-menu+.el is loaded. Does this help? – ScottRandby

1. When the library is loaded? Or after sorting by file name? Just what is the problem you mean?

2. When the library is loaded, the default sort is by last-visit time. But this default is controlled by user option ‘Buffer-menu-sort-column’, so you can have it start up with a sort of any of the columns.

3. When you sort by file name, it does not happen (for me, at least) that buffers associated with files are at the top and buffers associated with directories are at the bottom. What happens is that buffers associated with files and dirs are at the top, and buffers with no file/dir are at the bottom (or vice versa, depending on whether the sort is ascending/descending). And the buffers with a file or dir are sorted lexicographically, followed by the buffers with no file or dir, also sorted lexicographically.

4. Case is significant (respected) for sorting. Perhaps that is what is confusing you – perhaps your directories have a different letter case than your non-directory files?

None of this has changed in any way. And it works the same (AFAICT) in all Emacs versions. HTH – DrewAdams

I will address each of your points.

1. If the library is not loaded, the sorting by file name works as it should. If I load the library and then sort by file name, then I get the weird list.

2. I have the Buffer-menu-sort-column set to 6.

3. You may get the lexicographical sort, but I am not.

4. No, the case issue isn’t the problem. All my files and directories begin with capital letters.

Since you can’t reproduce the problem, I don’t know what to do. For now, I won’t use the package. – ScottRandby

a. Maybe your Emacs 24 version is different from mine. I get the same results (same as Emacs prior to 24) with both the second Emacs 24 pretest and a later snapshot (Dec 06, 2011).

b. 6 is not a valid value for ‘Buffer-menu-sort-column’. If you were to use either Customize or ‘M-x set-variable’ you would see that. Customize is your friend: it does type-checking. Valid values are 0-5. For file-name sorting, you want 5.

c. If that’s not the problem, and if you’re interested, you can try doing this:

    1. Load buff-menu.el (not .elc).
    2. In the definition of ‘list-buffers-noselect’, just before the last ‘dolist’, insert this: (debug), then evaluate the definition using ‘C-M-x’ (then you can remove the (debug)).
    3. That will enter the debugger just before sorting. Use ‘d’ to step or ‘c’ to skip through a step. Keep the source code open in another window to be able to follow it easily. You should be able to see what happens – let me know.

d. It’s OK for me if you don’t use the package – I’ll even give you your money back. ;-) If you do find out more about the problem or how to reproduce it, please let me know. Thx – DrewAdams

When I do M-x customize-group and go to the Buffer-menu-plus group, I get this:

 Buffer-menu-sort-column: 1
    State : CHANGED outside Customize. (mismatch)
   Sorted by (1) visit, (2) buffer, (3) size, (4) time, (5) mode, (6) file. More

So now I’m confused. But it doesn’t matter, because setting Buffer-menu-sort-column to 1 and then clicking on File in the buffer menu still gives the bad sorting.

I agree that the problem might stem from the version of Emacs 24 I’m using. But I don’t have time right now to compile the latest version.

I will try the steps you mentioned when I have time, maybe next week. Do you mean for me to load buff-menu+.el instead of buff-menu.el?

I really would like to get the package working. I have a hard time using the buffer menu without the syntax highlighting. --ScottRandby

With patience we will find the solution. ;-)

1. What you show from the Customize buffer is very wrong. I suspect it comes from your Emacs version, but I do not know. The fact that it says (mismatch) indicates that the current value (shown as STANDARD, which means the original definition) does not have the right custom type.

And what you show indicates that the current value is ‘1’. While ‘1’ is a valid value, you should never see that in Customize. Why? Because the ‘defcustom’ uses :tag and :choice. What you should see is (a) a Value Menu button followed by the text Sort by time of last visit or some such (that’s the default choice, which corresponds to value ‘1’).

2. The fact that it says the value was CHANGED outside Customize indicates that you are not starting with emacs -Q or that you have already somehow changed the value, without using Customize.

3. Vanilla buff-menu.el defines the same variable, but using a ‘defvar’, not ‘defcustom’, so it is not a user option there. The ‘defcustom’ in buff-menu+.el should override the ‘defvar’ in buff-menu.el. Perhaps that is not happening, for some reason. (Both libraries provide ‘1’ as the default value.)

4. “But it doesn’t matter, because setting Buffer-menu-sort-column to 1 and then…” — How are you setting it? If you use Customize, it must show you the Value Menu button and you must use that to choose. If you use ‘M-x set-variable’, that too should work. Even (setq Buffer-menu-sort-column 1) should work. But it sounds like something is broken in your setup or your Emacs version. Or perhaps you are doing more than you say, perhaps not starting with emacs -Q or something.

5. You need only put buff-menu+.el in your ‘load-path’ and load it (using (require 'buff-menu+) in your init file or `M-x load-library buff-menu+’ interactively). It will automatically load buff-menu first.

Please take another look, and let me know. Thx – DrewAdams


Buffer-Menu+ v21.0 does not work with Emacs 24.1.50.1 (full version information: GNU Emacs 24.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.1) of 2012-05-25 on rhenium, modified by Debian). When I invoke ‘buffer-menu’ I get the following error message: list-buffers-noselect: Symbol's value as variable is void: Buffer-menu-sort-button-mapMoritzBunkus

Yes, sorry about that. ChongYidong rewrote the code in vanilla buff-menu.el so that it uses his new so-called “tabulated list mode”. (And they apparently have not documented the change in ‘view-emacs-news’ – I filed a bug report about that.)

Dunno when (or whether) I will update buff-menu+.el to deal with that – no doubt not for a while anyway. Fortunately, 24.1 will not be affected – the change is only for 24.2+.

If you want a workaround for now, grab the buff-menu.el code from the latest Emacs 24 pretest or prior (e.g. from Emacs 23), and load that, then buff-menu+.el. – DrewAdams

I’ve taken buff-menu.el from Emacs 23, and that works. Thanks for the hint. I can happily use this combination, so fix buff-menu+ whenever it suits you best. – MoritzBunkus


CategoryBufferSwitching