Re: buff-menu.el header line

From:

Robert J. Chassell

Subject:

Re: buff-menu.el header line

Date:

Fri, 19 Nov 2004 13:21:54 +0000 (UTC)

It would also be nice to be able to move into the header and
invoke the "sort by" function by typing RET on it.
You can already invoke (Buffer-menu-sort 4) to sort the *Buffer List*
by Mode (the fourth column). [ i.e., C-u 4 M-x Buffer-menu-sort RET ]
So here is some sample code to enable you to type RET in the header
line of a *Buffer List* to sort by that column.
This works when Buffer-menu-use-header-line is set to nil and when
point is in the header line. (Please note that this awkward
proof-of-concept code does not test for either condition.)
(defun Buffer-menu-sort-on-column-position ()
"Sort by column type in a *Buffer List*
Point must be in the header line.
Must set Buffer-menu-use-header-line to nil.
Awkward proof-of-concept defun:
do not use except to show what can be done."
(interactive)
(let ((here (point))
(column 0))
(while (not (eq (point) (point-min)))
(backward-word)
(setq column (1+ column)))
(Buffer-menu-sort column)))
Here is the keybinding. This only works consistently if RET is
invoked from the header line. (If evoked in the body of a *Buffer
List* with point at the end of the a line that says
* *Shell Command Output* 68 Fundamental - Ex
i.e., point is in the Mode column, the function counts 6 columns from
the end ... so it sorts by File)
Please remember, this is merely `proof of concept' code.
(define-key
Buffer-menu-mode-map "\C-m" 'Buffer-menu-sort-on-column-position))
I just tested this successfully (but very briefly) in an experimental
instance of Emacs with Buffer-menu-use-header-line set to nil.
I am not sure whether it is worth developing this.
Incidentally, even though the keybinding appears as an echo area `tip'
when you move the mouse over a header line column heading,
Buffer-menu-mouse-select fails when Buffer-menu-use-header-line is set
to nil. It works fine when Buffer-menu-use-header-line is set to nil.
--
Robert J. Chassell
address@hidden GnuPG Key ID: 004B4AC8
http://www.rattlesnake.comhttp://www.teak.cc