unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Sorting buffers with ibuffer
@ 2008-11-21 18:07 z0d
  2008-11-21 18:36 ` z0d
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: z0d @ 2008-11-21 18:07 UTC (permalink / raw
  To: help-gnu-emacs

Hello,


I'm trying to sort my buffers by major-mode with ibuffer, but it seems
like it doesn't work.

I started Emacs with '-q' and then evaluated the following two lines:

(require 'ibuffer)
(setq-default ibuffer-default-sorting-mode 'major-mode)

When I do M-x ibuffer my buffers are sort by 'recency' (the default),
but the mode-line tells me 'Ibuffer by major-mode'. When I evalute
ibuffer-default-sorting-mode it's 'major-mode' as it should be. If I
cycle the sorting mode with ',' the sorting works fine thereafter. Am
I missing something?

By the way, what's the difference between 'major-mode' and 'mode-
name'? 'mode-name' isn't mentioned in the documentation, but if I
cycle through sorting modes with ',' I see it on the mode-line.

Thank you in advance.


Regards,
Peter.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Sorting buffers with ibuffer
  2008-11-21 18:07 Sorting buffers with ibuffer z0d
@ 2008-11-21 18:36 ` z0d
  2008-11-23  2:39   ` Juanma Barranquero
       [not found]   ` <mailman.1052.1227407986.26697.help-gnu-emacs@gnu.org>
  2008-11-22  3:07 ` Kevin Rodgers
       [not found] ` <mailman.990.1227323256.26697.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 8+ messages in thread
From: z0d @ 2008-11-21 18:36 UTC (permalink / raw
  To: help-gnu-emacs

On Nov 21, 7:07 pm, z0d <peter.bara...@gmail.com> wrote:
> Hello,
>
> I'm trying to sort my buffers by major-mode with ibuffer, but it seems
> like it doesn't work.

Sorry, I forget to mention that I'm using CVS Emacs, updated today.

If I (setq ibuffer-default-sorting-mode 'major-mode) instead of (setq-
default ibuffer-default-sorting-mode 'major-mode) it doesn't work
either.


Regards,
Peter.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Sorting buffers with ibuffer
  2008-11-21 18:07 Sorting buffers with ibuffer z0d
  2008-11-21 18:36 ` z0d
@ 2008-11-22  3:07 ` Kevin Rodgers
       [not found] ` <mailman.990.1227323256.26697.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 8+ messages in thread
From: Kevin Rodgers @ 2008-11-22  3:07 UTC (permalink / raw
  To: help-gnu-emacs

z0d wrote:
> By the way, what's the difference between 'major-mode' and 'mode-
> name'? 'mode-name' isn't mentioned in the documentation, but if I
> cycle through sorting modes with ',' I see it on the mode-line.

`C-h v' tells all.  Basically, major-mode's value is a symbol whose
function binding defines a major mode.  mode-line's value is a string
for display.

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Sorting buffers with ibuffer
  2008-11-21 18:36 ` z0d
@ 2008-11-23  2:39   ` Juanma Barranquero
       [not found]   ` <mailman.1052.1227407986.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 8+ messages in thread
From: Juanma Barranquero @ 2008-11-23  2:39 UTC (permalink / raw
  To: z0d; +Cc: help-gnu-emacs

On Fri, Nov 21, 2008 at 19:36, z0d <peter.barabas@gmail.com> wrote:

>> I'm trying to sort my buffers by major-mode with ibuffer, but it seems
>> like it doesn't work.
>
> Sorry, I forget to mention that I'm using CVS Emacs, updated today.

Could you show us  an example?

In a recently started Emacs, with several buffers loaded through
desktop.el, doing

 M-: (setq-default ibuffer-default-sorting-mode 'major-mode) <RET>
 M-x ibuffer <RET>

produces:

 MR Name                    Size Mode             Filename/Process
 -- ----                    ---- ----             ----------------
[ Default ]
    emacsclient.c          39732 C/lah            c:/emacs/lib-src/emacsclient.c
    misc/ChangeLog        169122 Change Log       c:/emacs/doc/misc/ChangeLog
    lisp/ChangeLog        595040 Change Log       c:/emacs/lisp/ChangeLog
    bs.el                  56668 Emacs-Lisp       c:/emacs/lisp/bs.el
    server.el              52641 Emacs-Lisp       c:/emacs/lisp/server.el
  % init.el                79607 Emacs-Lisp       ~/.emacs.d/init.el
 *  *Messages*               372 Fundamental
  % *server*                   0 Fundamental
  % *info*                280500 Info
    *scratch*                  0 Lisp Interaction

which is correctly sorted by major-mode

             Juanma




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Sorting buffers with ibuffer
       [not found] ` <mailman.990.1227323256.26697.help-gnu-emacs@gnu.org>
@ 2008-11-23 11:45   ` z0d
  0 siblings, 0 replies; 8+ messages in thread
From: z0d @ 2008-11-23 11:45 UTC (permalink / raw
  To: help-gnu-emacs

On Nov 22, 4:07 am, Kevin Rodgers <kevin.d.rodg...@gmail.com> wrote:
> z0d wrote:
> > By the way, what's the difference between 'major-mode' and 'mode-
> > name'? 'mode-name' isn't mentioned in the documentation, but if I
> > cycle through sorting modes with ',' I see it on the mode-line.
>
> `C-h v' tells all.  Basically, major-mode's value is a symbol whose
> function binding defines a major mode.  mode-line's value is a string
> for display.

Hello,


I know what mode-line is. I meant the symbol 'mode-name, which is a
sorting mode in ibuffer.el.


Regards,
Peter.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Sorting buffers with ibuffer
       [not found]   ` <mailman.1052.1227407986.26697.help-gnu-emacs@gnu.org>
@ 2008-11-26  3:29     ` z0d
  2008-11-26 10:28       ` Juanma Barranquero
       [not found]       ` <mailman.1281.1227695324.26697.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: z0d @ 2008-11-26  3:29 UTC (permalink / raw
  To: help-gnu-emacs

On Nov 23, 3:39 am, "Juanma Barranquero" <lek...@gmail.com> wrote:
>
> Could you show us  an example?
>

Yes:

shell: emacs -q .emacs .ssh/config .Emacs-lisp/init-lisp.el

M-: (setq-default ibuffer-default-sorting-mode 'major-mode) <RET>
M-x ibuffer <RET>

produces:

 MR Name                    Size Mode             Filename/Process
 -- ----                    ---- ----             ----------------
[ Default ]
    asdf-skeleton.el        1052 Emacs-Lisp       ~/.Emacs-Lisp/asdf-
skeleton.el
    config                   488 Conf[Space]      ~/.ssh/config
    .emacs                 13170 Emacs-Lisp       ~/.emacs
    *scratch*                191 Lisp Interaction
 *  *Messages*               142 Fundamental
  % *GNU Emacs*              744 Fundamental

    6 buffers              15787                  3 files, no
processes



> In a recently started Emacs, with several buffers loaded through
> desktop.el, doing
>
>  M-: (setq-default ibuffer-default-sorting-mode 'major-mode) <RET>
>  M-x ibuffer <RET>
>
> produces:
>
>  MR Name                    Size Mode             Filename/Process
>  -- ----                    ---- ----             ----------------
> [ Default ]
>     emacsclient.c          39732 C/lah            c:/emacs/lib-src/emacsclient.c
>     misc/ChangeLog        169122 Change Log       c:/emacs/doc/misc/ChangeLog
>     lisp/ChangeLog        595040 Change Log       c:/emacs/lisp/ChangeLog
>     bs.el                  56668 Emacs-Lisp       c:/emacs/lisp/bs.el
>     server.el              52641 Emacs-Lisp       c:/emacs/lisp/server.el
>   % init.el                79607 Emacs-Lisp       ~/.emacs.d/init.el
>  *  *Messages*               372 Fundamental
>   % *server*                   0 Fundamental
>   % *info*                280500 Info
>     *scratch*                  0 Lisp Interaction
>
> which is correctly sorted by major-mode
>
>              Juanma



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Sorting buffers with ibuffer
  2008-11-26  3:29     ` z0d
@ 2008-11-26 10:28       ` Juanma Barranquero
       [not found]       ` <mailman.1281.1227695324.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 8+ messages in thread
From: Juanma Barranquero @ 2008-11-26 10:28 UTC (permalink / raw
  To: z0d; +Cc: quiet, help-gnu-emacs

Package: emacs
Severity: minor
X-Debbugs-CC: jpw@gnu.org


On Wed, Nov 26, 2008 at 04:29, z0d <peter.barabas@gmail.com> wrote:

> shell: emacs -q .emacs .ssh/config .Emacs-lisp/init-lisp.el
>
> M-: (setq-default ibuffer-default-sorting-mode 'major-mode) <RET>
> M-x ibuffer <RET>
>
> produces:
>
>  MR Name                    Size Mode             Filename/Process
>  -- ----                    ---- ----             ----------------
> [ Default ]
>    asdf-skeleton.el        1052 Emacs-Lisp       ~/.Emacs-Lisp/asdf-
> skeleton.el
>    config                   488 Conf[Space]      ~/.ssh/config
>    .emacs                 13170 Emacs-Lisp       ~/.emacs
>    *scratch*                191 Lisp Interaction
>  *  *Messages*               142 Fundamental
>  % *GNU Emacs*              744 Fundamental
>
>    6 buffers              15787                  3 files, no
> processes

You're right.

What's happening is that, in fact, ibuffer is not sorting at all,
because there's a variable ibuffer-sorting-functions-alist that is
null at that point. That variable is initialized by code in
ibuf-ext.el; defaulting to 'recency works because that sorting order
is special-cased in ibuffer.el.

You can workaround the issue by making sure ibuf-ext is loaded, for example:

  emacs -q -l ibuf-ext .emacs .ssh/config .Emacs-lisp/init-lisp.el

but I think ibuffer should take care that the sorting functions' alist
is properly stuffed.


John, I've considered the attached patch, which checks in
ibuffer-sort-bufferlist. The alternative I see is to require 'ibuf-ext
in `ibuffer-mode' if the user modified `ibuffer-default-sorting-mode',
like

  (set (make-local-variable 'ibuffer-sorting-mode)
       ibuffer-default-sorting-mode)
  (unless (eq ibuffer-sorting-mode 'recency)
    (require 'ibuf-ext))

Are you OK with one of these changes?

  Juanma




Index: lisp/ibuffer.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/ibuffer.el,v
retrieving revision 1.110
diff -u -2 -r1.110 ibuffer.el
--- lisp/ibuffer.el	8 Oct 2008 05:02:09 -0000	1.110
+++ lisp/ibuffer.el	26 Nov 2008 09:56:30 -0000
@@ -2192,4 +2192,6 @@

 (defun ibuffer-sort-bufferlist (bmarklist)
+  (unless ibuffer-sorting-functions-alist
+    (require 'ibuf-ext))
   (let* ((sortdat (assq ibuffer-sorting-mode
 			ibuffer-sorting-functions-alist))




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Sorting buffers with ibuffer
       [not found]       ` <mailman.1281.1227695324.26697.help-gnu-emacs@gnu.org>
@ 2008-11-26 18:21         ` z0d
  0 siblings, 0 replies; 8+ messages in thread
From: z0d @ 2008-11-26 18:21 UTC (permalink / raw
  To: help-gnu-emacs

On Nov 26, 11:28 am, "Juanma Barranquero" <lek...@gmail.com> wrote:

Thank you for your help.

> Package: emacs
> Severity: minor
> X-Debbugs-CC: j...@gnu.org
>
>
>
> On Wed, Nov 26, 2008 at 04:29, z0d <peter.bara...@gmail.com> wrote:
> > shell: emacs -q .emacs .ssh/config .Emacs-lisp/init-lisp.el
>
> > M-: (setq-default ibuffer-default-sorting-mode 'major-mode) <RET>
> > M-x ibuffer <RET>
>
> > produces:
>
> >  MR Name                    Size Mode             Filename/Process
> >  -- ----                    ---- ----             ----------------
> > [ Default ]
> >    asdf-skeleton.el        1052 Emacs-Lisp       ~/.Emacs-Lisp/asdf-
> > skeleton.el
> >    config                   488 Conf[Space]      ~/.ssh/config
> >    .emacs                 13170 Emacs-Lisp       ~/.emacs
> >    *scratch*                191 Lisp Interaction
> >  *  *Messages*               142 Fundamental
> >  % *GNU Emacs*              744 Fundamental
>
> >    6 buffers              15787                  3 files, no
> > processes
>
> You're right.
>
> What's happening is that, in fact, ibuffer is not sorting at all,
> because there's a variable ibuffer-sorting-functions-alist that is
> null at that point. That variable is initialized by code in
> ibuf-ext.el; defaulting to 'recency works because that sorting order
> is special-cased in ibuffer.el.
>
> You can workaround the issue by making sure ibuf-ext is loaded, for example:
>
>   emacs -q -l ibuf-ext .emacs .ssh/config .Emacs-lisp/init-lisp.el
>
> but I think ibuffer should take care that the sorting functions' alist
> is properly stuffed.
>
> John, I've considered the attached patch, which checks in
> ibuffer-sort-bufferlist. The alternative I see is to require 'ibuf-ext
> in `ibuffer-mode' if the user modified `ibuffer-default-sorting-mode',
> like
>
>   (set (make-local-variable 'ibuffer-sorting-mode)
>        ibuffer-default-sorting-mode)
>   (unless (eq ibuffer-sorting-mode 'recency)
>     (require 'ibuf-ext))
>
> Are you OK with one of these changes?
>
>   Juanma
>
> Index: lisp/ibuffer.el
> ===================================================================
> RCS file: /sources/emacs/emacs/lisp/ibuffer.el,v
> retrieving revision 1.110
> diff -u -2 -r1.110 ibuffer.el
> --- lisp/ibuffer.el     8 Oct 2008 05:02:09 -0000       1.110
> +++ lisp/ibuffer.el     26 Nov 2008 09:56:30 -0000
> @@ -2192,4 +2192,6 @@
>
>  (defun ibuffer-sort-bufferlist (bmarklist)
> +  (unless ibuffer-sorting-functions-alist
> +    (require 'ibuf-ext))
>    (let* ((sortdat (assq ibuffer-sorting-mode
>                         ibuffer-sorting-functions-alist))



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-11-26 18:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-21 18:07 Sorting buffers with ibuffer z0d
2008-11-21 18:36 ` z0d
2008-11-23  2:39   ` Juanma Barranquero
     [not found]   ` <mailman.1052.1227407986.26697.help-gnu-emacs@gnu.org>
2008-11-26  3:29     ` z0d
2008-11-26 10:28       ` Juanma Barranquero
     [not found]       ` <mailman.1281.1227695324.26697.help-gnu-emacs@gnu.org>
2008-11-26 18:21         ` z0d
2008-11-22  3:07 ` Kevin Rodgers
     [not found] ` <mailman.990.1227323256.26697.help-gnu-emacs@gnu.org>
2008-11-23 11:45   ` z0d

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).