bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#3153: marked as done (23.0.60; which-func-mode (C++) confused when m


From: Emacs bug Tracking System
Subject: bug#3153: marked as done (23.0.60; which-func-mode (C++) confused when mixing structs/functions (patch included))
Date: Tue, 28 Apr 2009 21:40:06 +0000

Your message dated Tue, 28 Apr 2009 17:31:13 -0400
with message-id <address@hidden>
and subject line Re: 23.0.60; which-func-mode (C++) confused when mixing 
structs/functions (patch included)
has caused the Emacs bug report #3153,
regarding 23.0.60; which-func-mode (C++) confused when mixing structs/functions 
(patch included)
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact address@hidden
immediately.)


-- 
3153: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=3153
Emacs Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 23.0.60; which-func-mode (C++) confused when mixing structs/functions (patch included) Date: Tue, 28 Apr 2009 21:26:28 +0200
In GNU Emacs 23.0.60.1 (i686-pc-linux-gnu, GTK+ Version 2.12.0)
 of 2008-11-26 on geert-laptop
Windowing system distributor `The X.Org Foundation', version 11.0.10300000


When a C/C++ file contains mixed struct/function definitions,
which-func-mode gets confused.

To reproduce (see also the comments in the test case file):

1. open the test case file whichfunc-testcase.cpp
2. make sure which-func-mode is enabled (M-x which-func-mode)
3. put the point within the funcA() definition
4. the modeline shows "structA", not the expected "funcA"

In the following I'll describe the problem in somewhat more detail.

In `which-function()' it is assumed that the entries from
`imenu--index-alist' are ordered by buffer possition.  `which-function()'
does a linear search through the items, and as soon as a buffer position
is encountered greater than point, the search stops.  However, when
submenu's are present in `imenu--index-alist', the items are not
necessarily ordered by buffer position anymore:

  For the testcase the imenu--index-alist variable looks like this:

     (("Class"
       ("structA" . #<marker at 2 in whichfunc-testcase.cpp>)
       ("structB" . #<marker at 63 in whichfunc-testcase.cpp>))
      ("funcA" . #<marker at 34 in whichfunc-testcase.cpp>)
      ("funcB" . #<marker at 96 in whichfunc-testcase.cpp>))

The attached patch ensures the linear search through `menu--index-alist
does not end prematurely, and all items are taken into account.  This
fixes the problem.

/*
  test case for which-func-mode 
  (GJK 2009-04-28)

  Tested against the following revision:

  Repository revision: 1.26    
/cvsroot/emacs/emacs/lisp/progmodes/which-func.el,v

  The imenu--index-alist variable looks like this:

     (("Class"
       ("structA" . #<marker at 2 in whichfunc-testcase.cpp>)
       ("structB" . #<marker at 63 in whichfunc-testcase.cpp>))
      ("funcA" . #<marker at 34 in whichfunc-testcase.cpp>)
      ("funcB" . #<marker at 96 in whichfunc-testcase.cpp>))

   Because of the submenu, the overall items are not in order.
*/

struct structA
{
    int i;
};

void funcA()
{                       // here the modeline will still show "structA"
    dummy;
}

struct structB
{
    int i;
};

void funcB()
{
    dummy;
}
Index: which-func.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/which-func.el,v
retrieving revision 1.26
diff -c -r1.26 which-func.el
*** which-func.el       5 Jan 2009 03:23:54 -0000       1.26
--- which-func.el       28 Apr 2009 19:13:57 -0000
***************
*** 310,319 ****
                                 (setq minoffset offset
                                       name (funcall
                                             which-func-imenu-joiner-function
!                                            (reverse (cons (car pair) 
namestack)))))
!                          ;; Entries in order, so can skip all those after 
point.
!                          (setq alist nil
!                                imstack nil)))))
  
              (setq alist     (car imstack)
                    namestack (cdr namestack)
--- 310,317 ----
                                 (setq minoffset offset
                                       name (funcall
                                             which-func-imenu-joiner-function
!                                            (reverse (cons (car pair) 
!                                                           namestack)))))))))
  
              (setq alist     (car imstack)
                    namestack (cdr namestack)

Best regards,
Geert Kloosterman

--- End Message ---
--- Begin Message --- Subject: Re: 23.0.60; which-func-mode (C++) confused when mixing structs/functions (patch included) Date: Tue, 28 Apr 2009 17:31:13 -0400
> When a C/C++ file contains mixed struct/function definitions,
> which-func-mode gets confused.

Thanks for analyzing this problem, and fixing it.  I've committed your
patch.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]