From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Hui Liu Newsgroups: gmane.emacs.bugs Subject: bug#8725: imenu--split-menu should not deliver surprises Date: Sat, 12 Apr 2014 21:52:30 +0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1397327548 24836 80.91.229.3 (12 Apr 2014 18:32:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Apr 2014 18:32:28 +0000 (UTC) To: 8725@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 12 20:32:21 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WZ2iy-0000Lz-VZ for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Apr 2014 20:32:21 +0200 Original-Received: from localhost ([::1]:35316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZ2iy-0007TI-JP for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Apr 2014 14:32:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZ2iq-0007Su-6Z for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 14:32:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WZ2ik-0006di-2d for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 14:32:12 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZ2ij-0006dd-VK for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 14:32:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WZ2ij-0005la-F9 for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 14:32:05 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Hui Liu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Apr 2014 18:32:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8725 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8725-submit@debbugs.gnu.org id=B8725.139732751722115 (code B ref 8725); Sat, 12 Apr 2014 18:32:05 +0000 Original-Received: (at 8725) by debbugs.gnu.org; 12 Apr 2014 18:31:57 +0000 Original-Received: from localhost ([127.0.0.1]:46421 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WZ2ia-0005kc-Iq for submit@debbugs.gnu.org; Sat, 12 Apr 2014 14:31:57 -0400 Original-Received: from mail-qg0-f68.google.com ([209.85.192.68]:43033) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WYyMH-00065a-7R for 8725@debbugs.gnu.org; Sat, 12 Apr 2014 09:52:38 -0400 Original-Received: by mail-qg0-f68.google.com with SMTP id q108so2129741qgd.7 for <8725@debbugs.gnu.org>; Sat, 12 Apr 2014 06:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=/3PqopgjLGBxwo8reYi6EZ+muYd38Ppz8oyGYeVVqXA=; b=GLox1cMEIg+7JBvs0faVIXyHtM28O9uJGH/k0Iubs/HBim7VEbXCuJoZ+RuaEaiSs7 fl9eVr2T+rjLGm+LlvtGTHZ1SKvv+PNJzwzISrOgMCzgBqiPR2HyWDcXXC8f/fbkVbjv Gt8dHKQkA1RtEl9kWdzUseY7m52AbcAm4rerH4Zc3kCYdCQ5CQz98trsT2G1Shdg3mSf NFRQCbcMqAkGxsC156Oc3NQFZ56WL6lBYxNTKMeW1KoZv2eiGdS4qeFB4bI1vEGJhScO ol8RXD6mZRI2jhHYn7mpL0siNggF47Wh+araCMALjAYuVneo2JyRdn0riW0nGkBQ6qmD GaoQ== X-Received: by 10.224.4.5 with SMTP id 5mr6330036qap.85.1397310750820; Sat, 12 Apr 2014 06:52:30 -0700 (PDT) Original-Received: by 10.140.34.80 with HTTP; Sat, 12 Apr 2014 06:52:30 -0700 (PDT) X-Mailman-Approved-At: Sat, 12 Apr 2014 14:31:54 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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:87978 Archived-At: Hi. This bug still exists in 24.4.50. An example: emacs -Q M-x org-mode ;;; type the following text * section 1 * section 2 ** 2.1 ** 2.2 * section 3 * section 4 ** 4.1 ** 4.2 ;;; end M-x imenu-add-menubar-index Then Imenu produces a confusing menu like this: section 2 |=E2=80=942.1 |=E2=80=942.2 section 4 |=E2=80=944.1 |=E2=80=944.2 section 1 section 3 and the reason is Imenu put items with submenus at the top. Such behaviour may be reasonable for programming modes, but is clearly unnecessary for text modes. How about making a discrimination in imenu--split-menu? --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -537,10 +537,11 @@ The returned alist DOES NOT share structure with MENULIST." (if (memq imenu--rescan-item menulist) (setq keep-at-top (list imenu--rescan-item) menulist (delq imenu--rescan-item menulist))) - (dolist (item menulist) + (unless (derived-mode-p 'text-mode) + (dolist (item menulist) (when (imenu--subalist-p item) (push item keep-at-top) - (setq menulist (delq item menulist)))) + (setq menulist (delq item menulist))))) (if imenu-sort-function (setq menulist (sort menulist imenu-sort-function))) (if (> (length menulist) imenu-max-items)