all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: owner@emacsbugs.donarmstrong.com (Emacs bug Tracking System)
To: Chong Yidong <cyd@stupidchicken.com>
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	[thread overview]
Message-ID: <handler.3153.D3153.124095427324346.ackdone@emacsbugs.donarmstrong.com> (raw)
In-Reply-To: 87d4awwpej.fsf@gmail.com

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]


Your message dated Tue, 28 Apr 2009 17:31:13 -0400
with message-id <87ws94pise.fsf@cyd.mit.edu>
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 owner@emacsbugs.donarmstrong.com
immediately.)


-- 
3153: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=3153
Emacs Bug Tracking System
Contact owner@emacsbugs.donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 6860 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 1495 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2.1.2: whichfunc-testcase.cpp --]
[-- Type: text/x-c++src, Size: 754 bytes --]

/*
  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;
}

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2.1.3: which-func.patch --]
[-- Type: text/x-diff, Size: 1322 bytes --]

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)

[-- Attachment #2.1.4: Type: text/plain, Size: 34 bytes --]



Best regards,
Geert Kloosterman

[-- Attachment #3: Type: message/rfc822, Size: 1294 bytes --]

From: Chong Yidong <cyd@stupidchicken.com>
To: Geert Kloosterman <g.j.kloosterman@gmail.com>
Cc: 3153-done@emacsbugs.donarmstrong.com
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
Message-ID: <87ws94pise.fsf@cyd.mit.edu>

> 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.


      reply	other threads:[~2009-04-28 21:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87ws94pise.fsf@cyd.mit.edu>
2009-04-28 19:26 ` bug#3153: 23.0.60; which-func-mode (C++) confused when mixing structs/functions (patch included) Geert Kloosterman
2009-04-28 21:40   ` Emacs bug Tracking System [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=handler.3153.D3153.124095427324346.ackdone@emacsbugs.donarmstrong.com \
    --to=owner@emacsbugs.donarmstrong.com \
    --cc=cyd@stupidchicken.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.