GNU bug report logs - #11142
24.0.94; objc-mode fails for imenu and which-function-mode

Previous Next

Packages: emacs, cc-mode;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Sun, 1 Apr 2012 02:36:02 UTC

Severity: normal

Found in version 24.0.94

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11142 in the body.
You can then email your comments to 11142 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-cc-mode <at> gnu.org, bug-gnu-emacs <at> gnu.org:
bug#11142; Package emacs. (Sun, 01 Apr 2012 02:36:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-cc-mode <at> gnu.org, bug-gnu-emacs <at> gnu.org. (Sun, 01 Apr 2012 02:36:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.94; objc-mode fails for imenu and which-function-mode
Date: Sun, 01 Apr 2012 10:34:48 +0800
Turn on which-function-mode and open an objc file, it cannot show the
function name. Also, M-x imenu-add-menubar-index says: Error in
menu-bar-update-hook (imenu-update-menubar): (wrong-type-argument
integerp nil)

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11142; Package emacs,cc-mode. (Wed, 04 Apr 2012 16:20:03 GMT) Full text and rfc822 format available.

Message #8 received at 11142 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo <sdl.web <at> gmail.com>
Cc: bug-cc-mode <at> gnu.org, 11142 <at> debbugs.gnu.org
Subject: Re: bug#11142: 24.0.94;
	objc-mode fails for imenu and which-function-mode
Date: Wed, 04 Apr 2012 12:18:59 -0400
> Turn on which-function-mode and open an objc file, it cannot show the
> function name.

That's partly normal: objc-mode is not in `which-func-modes'.
But if you add `objc-mode' to which-func-modes, indeed the function name
still doesn't show up in the mode-line (whereas it did in Emacs-23, so
this is a regression).

> Also, M-x imenu-add-menubar-index says: Error in
> menu-bar-update-hook (imenu-update-menubar): (wrong-type-argument
> integerp nil)

I can indeed reproduce it (I used the src/nsfont.m file as sample ObjC file).

Hopefully Alan can figure it out


        Stefan


The imenu error has the following backtrace:

Debugger entered--Lisp error: (wrong-type-argument integerp nil)
  match-beginning(nil)
  (funcall func (match-beginning langnum) (match-end langnum))
  (setq str (funcall func (match-beginning langnum) (match-end langnum)))
  (while (re-search-backward cc-imenu-objc-generic-expression nil t) (setq langnum (if (match-beginning OBJC) OBJC (cond ((match-beginning Cproto) Cproto) ((match-beginning Cgeneralfunc) Cgeneralfunc) ((match-beginning Cnoreturn) Cnoreturn)))) (setq str (funcall func (match-beginning langnum) (match-end langnum))) (cond ((not (eq langnum OBJC)) (setq clist (cons (cons str (match-beginning langnum)) clist))) ((eq (aref str 0) 45) (setq str (concat "-" (cc-imenu-objc-method-to-selector str))) (setq methodlist (cons (cons str (match-beginning langnum)) methodlist))) ((eq (aref str 0) 43) (setq str (concat "+" (cc-imenu-objc-method-to-selector str))) (setq methodlist (cons (cons str (match-beginning langnum)) methodlist))) ((eq (aref str 0) 64) (setq classcount (1+ classcount)) (cond ((and (> (length str) implen) (string= (substring str 0 implen) "@implementation")) (setq str (substring str implen) str2 "@implementation")) ((string= (substring str 0 intflen) "@interface") (setq str (substring str intflen) str2 "@interface")) ((string= (substring str 0 prtlen) "@protocol") (setq str (substring str prtlen) str2 "@protocol"))) (setq str (cc-imenu-objc-remove-white-space str)) (setq methodlist (cons (cons str2 (match-beginning langnum)) methodlist)) (setq toplist (cons nil (cons (cons str methodlist) toplist)) methodlist nil))))
  (let (methodlist clist (OBJC cc-imenu-objc-generic-expression-objc-base-index) (Cnoreturn cc-imenu-objc-generic-expression-noreturn-index) (Cgeneralfunc cc-imenu-objc-generic-expression-general-func-index) (Cproto cc-imenu-objc-generic-expression-proto-index) langnum (classcount 0) toplist str str2 (intflen (length "@interface")) (implen (length "@implementation")) (prtlen (length "@protocol")) (func (if (fboundp (quote buffer-substring-no-properties)) (quote buffer-substring-no-properties) (quote buffer-substring)))) (goto-char (point-max)) (while (re-search-backward cc-imenu-objc-generic-expression nil t) (setq langnum (if (match-beginning OBJC) OBJC (cond ((match-beginning Cproto) Cproto) ((match-beginning Cgeneralfunc) Cgeneralfunc) ((match-beginning Cnoreturn) Cnoreturn)))) (setq str (funcall func (match-beginning langnum) (match-end langnum))) (cond ((not (eq langnum OBJC)) (setq clist (cons (cons str (match-beginning langnum)) clist))) ((eq (aref str 0) 45) (setq str (concat "-" (cc-imenu-objc-method-to-selector str))) (setq methodlist (cons (cons str (match-beginning langnum)) methodlist))) ((eq (aref str 0) 43) (setq str (concat "+" (cc-imenu-objc-method-to-selector str))) (setq methodlist (cons (cons str (match-beginning langnum)) methodlist))) ((eq (aref str 0) 64) (setq classcount (1+ classcount)) (cond ((and (> ... implen) (string= ... "@implementation")) (setq str (substring str implen) str2 "@implementation")) ((string= (substring str 0 intflen) "@interface") (setq str (substring str intflen) str2 "@interface")) ((string= (substring str 0 prtlen) "@protocol") (setq str (substring str prtlen) str2 "@protocol"))) (setq str (cc-imenu-objc-remove-white-space str)) (setq methodlist (cons (cons str2 (match-beginning langnum)) methodlist)) (setq toplist (cons nil (cons (cons str methodlist) toplist)) methodlist nil)))) (if (eq (car toplist) nil) (setq toplist (cdr toplist))) (if (< classcount 2) (let ((classname (car (car toplist))) (p (cdr (car (cdr ...)))) last) (setq toplist (cons (cons classname p) (cdr (cdr (car toplist))))) (if clist (progn (setq last toplist) (while (cdr last) (setq last (cdr last))) (setcdr last clist)))) (if clist (setq toplist (cons (cons "C" clist) toplist)))) toplist)
  cc-imenu-objc-function()
  imenu--make-index-alist(t)
  imenu-update-menubar()
  eval((imenu-update-menubar) nil)
  eval-expression((imenu-update-menubar) nil)
  call-interactively(eval-expression nil nil)





Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11142; Package emacs,cc-mode. (Thu, 05 Apr 2012 11:21:02 GMT) Full text and rfc822 format available.

Message #11 received at 11142 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: bug-cc-mode <at> gnu.org, 11142 <at> debbugs.gnu.org
Subject: Re: bug#11142: 24.0.94;
	objc-mode fails for imenu and which-function-mode
Date: Thu, 05 Apr 2012 19:18:59 +0800
On 2012-04-05 00:18 +0800, Stefan Monnier wrote:
> That's partly normal: objc-mode is not in `which-func-modes'.
> But if you add `objc-mode' to which-func-modes, indeed the function name
> still doesn't show up in the mode-line (whereas it did in Emacs-23, so
> this is a regression).
>
>> Also, M-x imenu-add-menubar-index says: Error in
>> menu-bar-update-hook (imenu-update-menubar): (wrong-type-argument
>> integerp nil)
>
> I can indeed reproduce it (I used the src/nsfont.m file as sample ObjC file).
>
> Hopefully Alan can figure it out

It seems the bug was brought in by commit

------------------------------------------------------------
revno: 105590
committer: Alan Mackenzie <acm <at> muc.de>
branch nick: trunk
timestamp: Sat 2011-08-27 08:41:23 +0000
message:
  progmodes/cc-menus.el (cc-imenu-c++-generic-expression): Make it handle
  function pointer parameters properly.

which increases the number of grouped matches by 1 and the sad fact that
cc-imenu-objc-generic-expression-*-index dependent on that.

BTW, the warning

,----
| ;;                        *Warning for cc-mode developers*
| ;;
| ;; `cc-imenu-objc-generic-expression' elements depend on
| ....
`----

should be placed in front of cc-imenu-c++-generic-expression to be of
any use.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11142; Package emacs,cc-mode. (Fri, 06 Apr 2012 17:15:02 GMT) Full text and rfc822 format available.

Message #14 received at 11142 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Leo <sdl.web <at> gmail.com>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 11142 <at> debbugs.gnu.org
Subject: Re: bug#11142: 24.0.94; objc-mode fails for imenu and
	which-function-mode
Date: Fri, 6 Apr 2012 17:11:54 +0000
Hi, Leo.

On Thu, Apr 05, 2012 at 07:18:59PM +0800, Leo wrote:
> On 2012-04-05 00:18 +0800, Stefan Monnier wrote:
> > That's partly normal: objc-mode is not in `which-func-modes'.
> > But if you add `objc-mode' to which-func-modes, indeed the function name
> > still doesn't show up in the mode-line (whereas it did in Emacs-23, so
> > this is a regression).

> >> Also, M-x imenu-add-menubar-index says: Error in
> >> menu-bar-update-hook (imenu-update-menubar): (wrong-type-argument
> >> integerp nil)

> > I can indeed reproduce it (I used the src/nsfont.m file as sample ObjC file).

> > Hopefully Alan can figure it out

> It seems the bug was brought in by commit

> ------------------------------------------------------------
> revno: 105590
> committer: Alan Mackenzie <acm <at> muc.de>
> branch nick: trunk
> timestamp: Sat 2011-08-27 08:41:23 +0000
> message:
>   progmodes/cc-menus.el (cc-imenu-c++-generic-expression): Make it handle
>   function pointer parameters properly.

> which increases the number of grouped matches by 1 and the sad fact that
> cc-imenu-objc-generic-expression-*-index dependent on that.

Brilliant diagnosis, absolutely right!  Thanks.  There're some pretty
non-standard coding techniques in that file.  ;-)

Here's the final bit of the fix; please try it out if you haven't done
already, and let me know whether it works fully.

> BTW, the warning

> ,----
> | ;;                        *Warning for cc-mode developers*
> | ;;
> | ;; `cc-imenu-objc-generic-expression' elements depend on
> | ....
> `----

> should be placed in front of cc-imenu-c++-generic-expression to be of
> any use.

Yes indeed.

> Leo


diff -r 4b03c7ef6cf2 cc-menus.el
--- a/cc-menus.el	Tue Apr 03 20:57:45 2012 +0000
+++ b/cc-menus.el	Fri Apr 06 17:03:33 2012 +0000
@@ -223,7 +223,7 @@
    "\\|"
    ;; > General function name regexp
    ;; Pick a token by  (match-string 3)
-   (car (cdr (nth 2 cc-imenu-c++-generic-expression))) ; -> index += 5
+   (car (cdr (nth 2 cc-imenu-c++-generic-expression))) ; -> index += 6
    (prog2 (setq cc-imenu-objc-generic-expression-general-func-index 3) "")
    ;; > Special case for definitions using phony prototype macros like:
    ;; > `int main _PROTO( (int argc,char *argv[]) )'.
@@ -232,11 +232,11 @@
        (concat
 	"\\|"
 	(car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1
-	(prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 9) "")
+	(prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 10) "")
 	)
-     (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 8) "")
+     (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 9) "")
      "")				; -> index += 0
-   (prog2 (setq cc-imenu-objc-generic-expression-proto-index 8) "")
+   (prog2 (setq cc-imenu-objc-generic-expression-proto-index 9) "")
    ;;
    ;; For Objective-C
    ;; Pick a token by (match-string 8 or 9)


-- 
Alan Mackenzie (Nuremberg, Germany).




Reply sent to Alan Mackenzie <acm <at> muc.de>:
You have taken responsibility. (Wed, 11 Apr 2012 18:19:01 GMT) Full text and rfc822 format available.

Notification sent to Leo <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Wed, 11 Apr 2012 18:19:01 GMT) Full text and rfc822 format available.

Message #19 received at 11142-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: 11142-done <at> debbugs.gnu.org
Subject: Re: bug#11142: 24.0.94; objc-mode fails for imenu and
	which-function-mode
Date: Wed, 11 Apr 2012 18:15:23 +0000
Bug fixed.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#11142; Package emacs,cc-mode. (Fri, 13 Apr 2012 06:56:01 GMT) Full text and rfc822 format available.

Message #22 received at 11142 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Leo <sdl.web <at> gmail.com>, 11142 <at> debbugs.gnu.org,
	Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#11142: 24.0.94;
	objc-mode fails for imenu and which-function-mode
Date: Fri, 13 Apr 2012 14:53:30 +0800
Alan Mackenzie <acm <at> muc.de> writes:

> Brilliant diagnosis, absolutely right!  Thanks.  There're some pretty
> non-standard coding techniques in that file.  ;-)
>
> Here's the final bit of the fix; please try it out if you haven't done
> already, and let me know whether it works fully.

Hi Alan,

Looks like c-defun-name still doesn't work right for objc-mode.  Could
you take a look at the patch from Jan Djärv in Bug#9032?  Thanks.  (That
should go into trunk since it's not a regression).




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 11 May 2012 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 47 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.