From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Angelo Graziosi Newsgroups: gmane.emacs.devel Subject: Re: bug#9199: Imenu does not work any more with C/C++ mode Date: Thu, 15 Mar 2012 22:06:32 +0100 Message-ID: <4F6259D8.10905@alice.it> References: <4E332066.9000909@alice.it> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1331845606 1704 80.91.229.3 (15 Mar 2012 21:06:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Mar 2012 21:06:46 +0000 (UTC) Cc: emacs To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 15 22:06:43 2012 Return-path: Envelope-to: ged-emacs-devel@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 1S8Hsg-0004t2-Te for ged-emacs-devel@m.gmane.org; Thu, 15 Mar 2012 22:06:43 +0100 Original-Received: from localhost ([::1]:55884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8Hsg-0001VA-7x for ged-emacs-devel@m.gmane.org; Thu, 15 Mar 2012 17:06:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8Hsd-0001V0-Mu for emacs-devel@gnu.org; Thu, 15 Mar 2012 17:06:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8Hsb-0001Md-OM for emacs-devel@gnu.org; Thu, 15 Mar 2012 17:06:39 -0400 Original-Received: from smtp207.alice.it ([82.57.200.103]:47856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8Hsb-0001MT-Cy for emacs-devel@gnu.org; Thu, 15 Mar 2012 17:06:37 -0400 Original-Received: from [192.168.1.101] (79.43.228.162) by smtp207.alice.it (8.6.023.02) id 4F05A665084FB349; Thu, 15 Mar 2012 22:06:33 +0100 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120312 Thunderbird/11.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.57.200.103 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:149091 Archived-At: Il 15/03/2012 2.39, Stefan Monnier ha scritto: >> $ cat init.el >> (add-hook 'c-mode-hook >> '(lambda() >> (imenu-add-to-menubar "Functions") >> ) >> ) > > Running for the Useless Use of Quote Award? ;-) > >> $ cat test.c >> int main(){} >> void foo1(){} >> void foo2(){} >> void foo2(){} >> $ emacs test.c& >> Now click on 'Functions' in the menu bar, the result is as in > > Hmm... indeed. > >> If I remove init.el completely and >> $ emacs test.c& >> M-x imenu-add-to-menubar >> Functions >> Now clicking on Functions works as expected! > > Yup: the reason why this (and other major modes) works is that the bug > only manifests itself if you call imenu-add-to-menubar more than once > (and it so happens that c-mode-hook is run twice for some reason). > > I believe this is fixed in the trunk now thanks the the patch below, Indeed... :-) Thanks, Angelo. > > > Stefan > > > === modified file 'lisp/ChangeLog' > --- lisp/ChangeLog 2012-03-13 23:27:56 +0000 > +++ lisp/ChangeLog 2012-03-15 01:37:45 +0000 > @@ -1,3 +1,9 @@ > +2012-03-15 Stefan Monnier > + > + * imenu.el: Fix multiple inheritance breakage (bug#9199). > + (imenu-add-to-menubar): Don't add a redundant index. > + (imenu-update-menubar): Handle a dynamically composed keymap. > + > 2012-03-13 Katsumi Yamaoka > > * mail/sendmail.el (mail-encode-header): > > === modified file 'lisp/imenu.el' > --- lisp/imenu.el 2012-01-19 07:21:25 +0000 > +++ lisp/imenu.el 2012-03-15 01:32:35 +0000 > @@ -963,13 +963,14 @@ > imenu-generic-expression > (not (eq imenu-create-index-function > 'imenu-default-create-index-function))) > + (unless (keymapp (lookup-key (current-local-map) [menu-bar index])) > (let ((newmap (make-sparse-keymap))) > (set-keymap-parent newmap (current-local-map)) > (setq imenu--last-menubar-index-alist nil) > (define-key newmap [menu-bar index] > `(menu-item ,name ,(make-sparse-keymap "Imenu"))) > (use-local-map newmap) > - (add-hook 'menu-bar-update-hook 'imenu-update-menubar)) > + (add-hook 'menu-bar-update-hook 'imenu-update-menubar))) > (error "The mode `%s' does not support Imenu" > (format-mode-line mode-name)))) > > @@ -1008,6 +1009,9 @@ > (car (cdr menu)))) > 'imenu--menubar-select)) > (setq old (lookup-key (current-local-map) [menu-bar index])) > + ;; This should never happen, but in some odd cases, potentially, > + ;; lookup-key may return a dynamically composed keymap. > + (if (keymapp (cadr old)) (setq old (cadr old))) > (setcdr old (cdr menu1))))))) > > (defun imenu--menubar-select (item) >