From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: dino chiesa Newsgroups: gmane.emacs.bugs Subject: bug#8725: 23.2; imenu--split-menu should not deliver surprises Date: Tue, 24 May 2011 06:16:32 -0700 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_b592907e-47b1-485e-b5c4-99f01913932d_" X-Trace: dough.gmane.org 1306243034 30843 80.91.229.12 (24 May 2011 13:17:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 24 May 2011 13:17:14 +0000 (UTC) To: 8725@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 24 15:17:10 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QOrTw-0000oL-LV for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 May 2011 15:17:08 +0200 Original-Received: from localhost ([::1]:59068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOrTw-0006rQ-5f for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 May 2011 09:17:08 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:47859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOrTs-0006rG-7Y for bug-gnu-emacs@gnu.org; Tue, 24 May 2011 09:17:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOrTq-0004TS-Ik for bug-gnu-emacs@gnu.org; Tue, 24 May 2011 09:17:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOrTq-0004TO-FT for bug-gnu-emacs@gnu.org; Tue, 24 May 2011 09:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QOrTq-00031I-B9; Tue, 24 May 2011 09:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: dino chiesa Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 May 2011 13:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: Original-Received: via spool by submit@debbugs.gnu.org id=B.130624300911568 (code B ref -1); Tue, 24 May 2011 13:17:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 May 2011 13:16:49 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QOrTc-00030W-4T for submit@debbugs.gnu.org; Tue, 24 May 2011 09:16:49 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QOrTZ-00030G-UL for submit@debbugs.gnu.org; Tue, 24 May 2011 09:16:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOrTQ-0004QB-FO for submit@debbugs.gnu.org; Tue, 24 May 2011 09:16:40 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:40695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOrTQ-0004Q6-DZ for submit@debbugs.gnu.org; Tue, 24 May 2011 09:16:36 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:47750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOrTO-0006q4-Nu for bug-gnu-emacs@gnu.org; Tue, 24 May 2011 09:16:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOrTM-0004PT-So for bug-gnu-emacs@gnu.org; Tue, 24 May 2011 09:16:34 -0400 Original-Received: from blu0-omc1-s27.blu0.hotmail.com ([65.55.116.38]:20342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOrTM-0004PK-Mk for bug-gnu-emacs@gnu.org; Tue, 24 May 2011 09:16:32 -0400 Original-Received: from BLU159-W47 ([65.55.116.9]) by blu0-omc1-s27.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 24 May 2011 06:16:32 -0700 X-Originating-IP: [71.60.182.236] Importance: Normal X-OriginalArrivalTime: 24 May 2011 13:16:32.0454 (UTC) FILETIME=[CCCCBE60:01CC1A14] X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP4, XP SP1+ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 24 May 2011 09:17:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:46680 Archived-At: --_b592907e-47b1-485e-b5c4-99f01913932d_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable imenu--split-menu sorts the menu structure=2C placing breakout menus at the top. This seems arbitrary=2C surprising=2C and unnecessary. =20 =20 A reasonable sorting behavior would be to sort in the order in which the menu items were found - that is to say=2C leave the order the way it was on entry to the defun. Another reasonable sorting behavior would be to sort menu items lexicographically. This defun does neither of those things but rather applies the arbitrary decision to put items with submenus at the top. Why? =20 This is not consistent with good UI design. It makes for a confusing menu=2C in which the order of items doesn't correspond to *anything* useful= . =20 Also=2C this behavior is not avoidable. Though imenu allows specification of a sort function for menbu items=2C the arbitrary sorting described above happens whether or not a custom sort function is provided. The only way around this is to advise or redefine imenu--split-menu. =20 To fix this=2C in imenu.el =2C redefine imenu--split-menu to remove the off= ending arbitrariness:=20 =20 (defun imenu--split-menu (menulist title) (let ((menulist (copy-sequence menulist)) keep-at-top tail) (if (memq imenu--rescan-item menulist) (setq keep-at-top (list imenu--rescan-item) menulist (delq imenu--rescan-item menulist))) =3B=3B DPC - ban menu fascism!=20 =3B=3B (setq tail menulist) =3B=3B (dolist (item tail) =3B=3B (when (imenu--subalist-p item) =3B=3B (push item keep-at-top) =3B=3B (setq menulist (delq item menulist)))) (if imenu-sort-function (setq menulist (sort menulist imenu-sort-function))) (if (> (length menulist) imenu-max-items) (setq menulist (mapcar (lambda (menu) (cons (format "From: %s" (caar menu)) menu)) (imenu--split menulist imenu-max-items)))) (cons title (nconc (nreverse keep-at-top) menulist)))) =20 =20 In GNU Emacs 23.2.1 (i386-mingw-nt6.1.7601) of 2010-05-08 on G41R2F1 Windowing system distributor `Microsoft Corp.'=2C version 6.1.7601 configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/xpm/inc= lude' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: ENU value of $XMODIFIERS: nil locale-coding-system: cp1252 default enable-multibyte-characters: t Major mode: Emacs-Lisp Minor modes in effect: auto-revert-mode: t yas/minor-mode: t global-hl-line-mode: t hl-line-mode: t global-auto-complete-mode: t auto-complete-mode: t tooltip-mode: t mouse-wheel-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-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: Recent messages: Load-path shadows: /users/dino/elisp/linum hides c:/emacs/lisp/linum /users/dino/elisp/css-mode hides c:/emacs/lisp/textmodes/css-mode Features: (browse-url mailalias mailclient sendmail gnus-msg gnus-art mm-uu mml2015 pgg pgg-parse pgg-def epg-config mm-view smime dig gnus-sum nnoo gnus-group gnus-undo nnmail mail-source format-spec gnus-start gnus-spec gnus-int gnus-range gnus-win gnus gnus-ems shadow sort mail-extr message ecomplete rfc822 mml mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1 hex-util hashcash mail-utils emacsbug help-mode view js find-func dired-aux flymake-for-jslint-for-wsh flymake-cursor flymake autopair espresso bytecomp byte-compile ido json thingatpt etags imenu newcomment cc-mode cc-fonts cc-menus cc-cmds multi-isearch grep compile comint ring time-stamp sgml-mode autorevert server cperl-mode paren mic-paren hideshow easymenu cc-styles cc-align cc-engine cc-vars cc-defs dired regexp-opt defaultcontent yasnippet-bundle dropdown-list yasnippet easy-mmode cl cl-19 tfs skeleton httpget hl-line advice help-fns advice-preload auto-complete-config auto-complete edmacro kmacro popup tooltip ediff-hook vc-hooks lisp-float-type mwheel dos-w32 disp-table ls-lisp w32-win w32-vars tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag 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 loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process multi-tty emacs) = --_b592907e-47b1-485e-b5c4-99f01913932d_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable imenu--split-menu sorts the menu structure=2C placing breakout menus at
= the top. =3B This seems arbitrary=2C surprising=2C and unnecessary.&nbs= p=3B
 =3B
A reasonable sorting behavior would be to sort in the order in which themenu items were found - that is to say=2C leave the order the way it wason entry to the defun. =3B Another reasonable sorting behavior would = be to
sort menu items lexicographically. =3B This defun does neither= of those
things but rather applies the arbitrary decision to put items = with
submenus at the top. Why?
 =3B
This is not consistent with good UI design. It makes for a confusing
men= u=2C in which the order of items doesn't correspond to *anything* useful.  =3B
Also=2C this behavior is not avoidable. Though imenu allows specificationof a sort function for menbu items=2C the arbitrary sorting described
= above happens whether or not a custom sort function is provided. The
onl= y way around this is to advise or redefine imenu--split-menu.
 =3B
To fix this=2C in imenu.el =2C redefine imenu--split-menu to remove the off= ending
arbitrariness:
 =3B
 =3B =3B =3B (defun imenu--split-menu (menulist title)
 = =3B =3B =3B =3B =3B (let ((menulist (copy-sequence menulist= ))
 =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B keep-at-top tail)
 =3B =3B =3B =3B&n= bsp=3B =3B =3B (if (memq imenu--rescan-item menulist)
 =3B&n= bsp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B (setq keep-at-top (list imenu--rescan-item)
 =3B =3B =3B=  =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B menulist (delq imenu--rescan-item men= ulist)))
 =3B =3B =3B =3B =3B =3B =3B =3B=3B= DPC - ban menu fascism!
 =3B =3B =3B =3B =3B = =3B =3B =3B=3B (setq tail menulist)
 =3B =3B =3B =3B=  =3B =3B =3B =3B=3B (dolist (item tail)
 =3B =3B&nbs= p=3B =3B =3B =3B =3B =3B=3B =3B =3B (when (imenu--s= ubalist-p item)
 =3B =3B =3B =3B =3B =3B =3B= =3B=3B =3B =3B =3B =3B (push item keep-at-top)
 =3B=  =3B =3B =3B =3B =3B =3B =3B=3B =3B =3B&nbs= p=3B =3B (setq menulist (delq item menulist))))
 =3B =3B&nbs= p=3B =3B =3B =3B =3B (if imenu-sort-function
 =3B&nb= sp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B (setq menulist (sort menulist imenu-sort-function)))
 =3B = =3B =3B =3B =3B =3B =3B (if (>=3B (length menulist) i= menu-max-items)
 =3B =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B (setq menulist
 =3B =3B =3B=  =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B (mapcar
 =3B =3B =3B&n= bsp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B (lambda (menu)
 =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B =3B =3B =3B =3B =3B (c= ons (format "From: %s" (caar menu)) menu))
 =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B =3B (imenu--split menulist imenu-max-i= tems))))
 =3B =3B =3B =3B =3B =3B =3B (cons = title
 =3B =3B =3B =3B =3B =3B =3B =3B&n= bsp=3B =3B =3B =3B =3B (nconc (nreverse keep-at-top) menuli= st))))
 =3B
 =3B
In GNU Emacs 23.2.1 (i386-mingw-nt6.1.7601)
 =3Bof 2010-05-08 on G41= R2F1
Windowing system distributor `Microsoft Corp.'=2C version 6.1.7601<= BR>configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/xpm/= include'
Important settings:
 =3B value of $LC_ALL: nil
 =3B value of = $LC_COLLATE: nil
 =3B value of $LC_CTYPE: nil
 =3B value of $= LC_MESSAGES: nil
 =3B value of $LC_MONETARY: nil
 =3B value o= f $LC_NUMERIC: nil
 =3B value of $LC_TIME: nil
 =3B value of = $LANG: ENU
 =3B value of $XMODIFIERS: nil
 =3B locale-coding-= system: cp1252
 =3B default enable-multibyte-characters: t
Major mode: Emacs-Lisp
Minor modes in effect:
 =3B auto-revert-mode: t
 =3B yas/mino= r-mode: t
 =3B global-hl-line-mode: t
 =3B hl-line-mode: t =3B global-auto-complete-mode: t
 =3B auto-complete-mode: t =3B tooltip-mode: t
 =3B mouse-wheel-mode: t
 =3B menu-= bar-mode: t
 =3B file-name-shadow-mode: t
 =3B global-font-lo= ck-mode: t
 =3B font-lock-mode: t
 =3B blink-cursor-mode: t =3B auto-encryption-mode: t
 =3B auto-compression-mode: t
=  =3B line-number-mode: t
 =3B transient-mark-mode: t
Recent input:
Recent messages:
Load-path shadows:
/users/dino/elis= p/linum hides c:/emacs/lisp/linum
/users/dino/elisp/css-mode hides c:/em= acs/lisp/textmodes/css-mode
Features:
(browse-url mailalias mailclient sendmail gnus-msg gnus-art mm= -uu
mml2015 pgg pgg-parse pgg-def epg-config mm-view smime dig gnus-sum = nnoo
gnus-group gnus-undo nnmail mail-source format-spec gnus-start gnus= -spec
gnus-int gnus-range gnus-win gnus gnus-ems shadow sort mail-extr m= essage
ecomplete rfc822 mml mml-sec password-cache mm-decode mm-bodiesmm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums
mai= labbrev nnheader gnus-util netrc time-date mm-util mail-prsvr
gmm-utils = wid-edit mailheader canlock sha1 hex-util hashcash mail-utils
emacsbug h= elp-mode view js find-func dired-aux
flymake-for-jslint-for-wsh flymake-= cursor flymake autopair espresso
bytecomp byte-compile ido json thingatp= t etags imenu newcomment cc-mode
cc-fonts cc-menus cc-cmds multi-isearch= grep compile comint ring
time-stamp sgml-mode autorevert server cperl-m= ode paren mic-paren
hideshow easymenu cc-styles cc-align cc-engine cc-va= rs cc-defs dired
regexp-opt defaultcontent yasnippet-bundle dropdown-lis= t yasnippet
easy-mmode cl cl-19 tfs skeleton httpget hl-line advice help= -fns
advice-preload auto-complete-config auto-complete edmacro kmacro po= pup
tooltip ediff-hook vc-hooks lisp-float-type mwheel dos-w32 disp-tabl= e
ls-lisp w32-win w32-vars tool-bar dnd fontset image fringe lisp-moderegister page menu-bar rfn-eshadow timer select scroll-bar mldrag mousejit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8= -lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese heb= rew greek romanian slovak czech european ethiopic indian
cyrillic chines= e case-table epa-hook jka-cmpr-hook help simple abbrev
loaddefs button m= inibuffer faces cus-face files text-properties overlay
md5 base64 format= env code-pages mule custom widget
hashtable-print-readable backquote ma= ke-network-process multi-tty emacs)

= --_b592907e-47b1-485e-b5c4-99f01913932d_--