GNU bug report logs - #18268
24.3.92; Make imenu sort submenus also (fix included)

Previous Next

Package: emacs;

Reported by: carlosjosepita <at> gmail.com

Date: Thu, 14 Aug 2014 23:19:02 UTC

Severity: minor

Tags: patch

Found in version 24.3.92

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18268 in the body.
You can then email your comments to 18268 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18268; Package emacs. (Thu, 14 Aug 2014 23:19:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to carlosjosepita <at> gmail.com:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 14 Aug 2014 23:19:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: carlosjosepita <at> gmail.com
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.92; Make imenu sort submenus also (fix included)
Date: Thu, 14 Aug 2014 20:18:33 -0300
When the current major mode provides submenus (say, python-mode, with
methods nested inside classes, classes being top-level), imenu always
shows them at the top of the menu and unsorted. Only sibling leaves of
the menu tree are sorted.

To fix this, just sort the output of imenu--split submenus when a custom
imenu-sort-function was required by the user:

(defun imenu--split-submenus (alist)
  "Split up each long alist that are nested within ALIST into nested alists.
Return a split and sorted copy of ALIST.  The returned alist DOES
NOT share structure with ALIST."
  (let ((menulist (mapcar (lambda (elt)
                            (if (imenu--subalist-p elt)
                                (imenu--split-menu (cdr elt) (car elt))
                              elt))
                          alist)))
    (if imenu-sort-function
	(sort menulist imenu-sort-function)
      menulist)))

Regards
--
Carlos








In GNU Emacs 24.3.92.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
 of 2014-08-07 on memeplex
Windowing system distributor `The X.Org Foundation', version 11.0.11600000
Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  shell-dirtrack-mode: t
  show-paren-mode: t
  winner-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  ido-everywhere: t
  global-auto-complete-mode: t
  auto-complete-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  global-prettify-symbols-mode: t
  prettify-symbols-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<up> <up> <up> <up> <up> <up> <up> <up> <up> C-SPC 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> C-w <return> C-x C-s <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <prior> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <S-left> <down> <down> <down> C-x d <return> <S-right> 
<down> <down> <down> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
C-e ( r e q u i r e SPC ' i m e n u - a n y w h e e 
r <backspace> <backspace> r e ) C-x C-e <up> <up> <down> 
C-e C-x C-e <S-left> <up> <down> <down> <down> d <down> 
x y e s <return> <up> <up> <up> <return> C-x C-s <down> 
<down> <down> <down> <down> C-x b s c <return> <S-right> 
<next> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <return> ( r e q 
u i r e SPC ' f i x e s ) C-x C-e C-g C-x C-s <up> 
<up> <S-left> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> M-x r e p o <tab> 
r t <tab> <return>

Recent messages:
End of buffer [3 times]
imenu-anywhere
imenu--sort-by-name
Deleting...done
(No changes need to be saved)
progn: Required feature `fixes' was not provided
Quit
Saving file /home/carlos/.emacs...
Wrote /home/carlos/.emacs
Making completion list...

Load-path shadows:
~/.emacs.d/lisp/python hides /usr/share/emacs/24.3.92/lisp/progmodes/python
~/.emacs.d/lisp/rmail hides /usr/share/emacs/24.3.92/lisp/mail/rmail

Features:
(shadow sort mail-extr emacsbug message idna rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils debug
mule-util tramp-cache tramp tramp-compat tramp-loaddefs trampver shell
image-file org-rmail org-mhe org-irc org-info org-gnus org-docview
doc-view image-mode dired org-bibtex bibtex org-bbdb org-w3m org-capture
org org-macro org-footnote org-pcomplete pcomplete org-list org-faces
org-entities noutline outline easy-mmode org-version ob-emacs-lisp ob
ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint
ob-core ob-eval org-compat org-macs org-loaddefs format-spec cal-menu
calendar cal-loaddefs edebug misearch multi-isearch jka-compr eieio-opt
speedbar sb-image ezimage dframe network-stream auth-source eieio
byte-opt bytecomp byte-compile cconv eieio-core gnus-util mm-util
mail-prsvr password-cache starttls tls warnings vc-git jedi
python-environment epc ctable concurrent deferred python skeleton
derived pcase rx json imenu-anywhere cl-macs imenu thingatpt find-func
flymake compile comint ansi-color paren winner ring windmove advice
help-fns yasnippet help-mode cl gv ido auto-complete-config
auto-complete popup edmacro kmacro cl-loaddefs cl-lib info easymenu
package wombat-theme time-date tooltip electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 361814 22370)
 (symbols 48 36390 0)
 (miscs 40 1153 1328)
 (strings 32 103033 9931)
 (string-bytes 1 2189271)
 (vectors 16 35814)
 (vector-slots 8 1446654 27798)
 (floats 8 665 911)
 (intervals 56 9261 0)
 (buffers 960 26)
 (heap 1024 67756 2517))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18268; Package emacs. (Thu, 14 Aug 2014 23:58:01 GMT) Full text and rfc822 format available.

Message #8 received at 18268 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 18268 <at> debbugs.gnu.org
Date: Thu, 14 Aug 2014 20:56:56 -0300
Besides that, I see no point in the keep-at-top behaviour of
imenu--split-menu, which pushes every submenu to the top of its parent
menu. The user is looking for a name in a list sorted according to
some required criterion. Splitting this list in two sorted lists in
virtue of a totally different criterion will only bring confusion.
It's ok to make this the default behaviour, in case the user isn't
interested in any particular ordering (that is, imenu-sort-function is
nil). But if a particular ordering is required, then it should be
honoured. Or, at least, an option should be provided to turn off
keep-at-top.

If you agree I will gladly provide a patch.

Regards
--
Carlos




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18268; Package emacs. (Fri, 15 Aug 2014 15:20:02 GMT) Full text and rfc822 format available.

Message #11 received at 18268 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 18268 <at> debbugs.gnu.org
Subject: Re:
Date: Fri, 15 Aug 2014 12:18:36 -0300
The following is a simpler and more correct patch that also lets the
user (final user or major mode developer) control whether the submenus
are sorted or kept on top. The guiding idea is that there is two major
ways to offer an imenu, according to the mode:

1) Some modes show a hierarchy of language objects. For example:
python-mode will show class/method, function/nested function, etc.
relationships; org-mode will show section/subsection/subsubsection/...
hierarchies. In these cases keeping the submenus on top is not
adequate since it creates an artificial split of the list.

2) Some modes show top level submenus with fixed categories
(Functions, Classes, Variables, etc). These modes will presumably want
to keep the submenus on top and sorted in the order they were given.

3) Other modes would not fit either (1) or (2). Then, there is always
the possibility of turning off sorting and provide the menu structure
as is.

Regards
--
Carlos

156a157,161
> (defcustom imenu-sort-submenus nil
>   "Non-nil means Imenu should sort submenus also (using imenu-sort-function)."
>   :type 'boolean
>   :group 'imenu)
>
541c546,547
<       (when (imenu--subalist-p item)
---
>       (when (and (not imenu-sort-submenus)
>                  (imenu--subalist-p item))

On Thu, Aug 14, 2014 at 8:56 PM, Carlos Pita <carlosjosepita <at> gmail.com> wrote:
> Besides that, I see no point in the keep-at-top behaviour of
> imenu--split-menu, which pushes every submenu to the top of its parent
> menu. The user is looking for a name in a list sorted according to
> some required criterion. Splitting this list in two sorted lists in
> virtue of a totally different criterion will only bring confusion.
> It's ok to make this the default behaviour, in case the user isn't
> interested in any particular ordering (that is, imenu-sort-function is
> nil). But if a particular ordering is required, then it should be
> honoured. Or, at least, an option should be provided to turn off
> keep-at-top.
>
> If you agree I will gladly provide a patch.
>
> Regards
> --
> Carlos




Added tag(s) patch. Request was from Carlos Pita <carlosjosepita <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 25 Nov 2014 18:58:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18268; Package emacs. (Tue, 23 Feb 2016 12:23:01 GMT) Full text and rfc822 format available.

Message #16 received at 18268 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: 18268 <at> debbugs.gnu.org
Subject: Re: bug#18268:
Date: Tue, 23 Feb 2016 23:21:43 +1100
Carlos Pita <carlosjosepita <at> gmail.com> writes:

> The following is a simpler and more correct patch that also lets the
> user (final user or major mode developer) control whether the submenus
> are sorted or kept on top. The guiding idea is that there is two major
> ways to offer an imenu, according to the mode:
>
> 1) Some modes show a hierarchy of language objects. For example:
> python-mode will show class/method, function/nested function, etc.
> relationships; org-mode will show section/subsection/subsubsection/...
> hierarchies. In these cases keeping the submenus on top is not
> adequate since it creates an artificial split of the list.
>
> 2) Some modes show top level submenus with fixed categories
> (Functions, Classes, Variables, etc). These modes will presumably want
> to keep the submenus on top and sorted in the order they were given.
>
> 3) Other modes would not fit either (1) or (2). Then, there is always
> the possibility of turning off sorting and provide the menu structure
> as is.
>
> Regards
> --
> Carlos
>
> 156a157,161
>> (defcustom imenu-sort-submenus nil
>>   "Non-nil means Imenu should sort submenus also (using imenu-sort-function)."
>>   :type 'boolean
>>   :group 'imenu)

Could you resubmit this as a context patch instead of a "raw" patch?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18268; Package emacs. (Tue, 25 Jun 2019 21:46:02 GMT) Full text and rfc822 format available.

Message #19 received at 18268 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: 18268 <at> debbugs.gnu.org
Subject: Re: bug#18268:
Date: Tue, 25 Jun 2019 23:45:39 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Could you resubmit this as a context patch instead of a "raw" patch?

That was three years ago, so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 18268 <at> debbugs.gnu.org and carlosjosepita <at> gmail.com Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 25 Jun 2019 21:46:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 24 Jul 2019 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 249 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.