unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11142: 24.0.94; objc-mode fails for imenu and which-function-mode
@ 2012-04-01  2:34 Leo
  2012-04-04 16:18 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Leo @ 2012-04-01  2:34 UTC (permalink / raw)
  To: 11142; +Cc: bug-cc-mode

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#11142: 24.0.94; objc-mode fails for imenu and which-function-mode
  2012-04-01  2:34 bug#11142: 24.0.94; objc-mode fails for imenu and which-function-mode Leo
@ 2012-04-04 16:18 ` Stefan Monnier
  2012-04-05 11:18   ` Leo
       [not found]   ` <m1wr5uifz0.fsf@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2012-04-04 16:18 UTC (permalink / raw)
  To: Leo; +Cc: 11142

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






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#11142: 24.0.94; objc-mode fails for imenu and which-function-mode
  2012-04-04 16:18 ` Stefan Monnier
@ 2012-04-05 11:18   ` Leo
       [not found]   ` <m1wr5uifz0.fsf@gmail.com>
  1 sibling, 0 replies; 6+ messages in thread
From: Leo @ 2012-04-05 11:18 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 11142

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#11142: 24.0.94; objc-mode fails for imenu and which-function-mode
       [not found]   ` <m1wr5uifz0.fsf@gmail.com>
@ 2012-04-06 17:11     ` Alan Mackenzie
  2012-04-13  6:53       ` Chong Yidong
  2012-04-11 18:15     ` Alan Mackenzie
  1 sibling, 1 reply; 6+ messages in thread
From: Alan Mackenzie @ 2012-04-06 17:11 UTC (permalink / raw)
  To: Leo; +Cc: 11142

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#11142: 24.0.94; objc-mode fails for imenu and which-function-mode
       [not found]   ` <m1wr5uifz0.fsf@gmail.com>
  2012-04-06 17:11     ` Alan Mackenzie
@ 2012-04-11 18:15     ` Alan Mackenzie
  1 sibling, 0 replies; 6+ messages in thread
From: Alan Mackenzie @ 2012-04-11 18:15 UTC (permalink / raw)
  To: 11142-done

Bug fixed.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#11142: 24.0.94; objc-mode fails for imenu and which-function-mode
  2012-04-06 17:11     ` Alan Mackenzie
@ 2012-04-13  6:53       ` Chong Yidong
  0 siblings, 0 replies; 6+ messages in thread
From: Chong Yidong @ 2012-04-13  6:53 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Leo, 11142

Alan Mackenzie <acm@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).





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-13  6:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-01  2:34 bug#11142: 24.0.94; objc-mode fails for imenu and which-function-mode Leo
2012-04-04 16:18 ` Stefan Monnier
2012-04-05 11:18   ` Leo
     [not found]   ` <m1wr5uifz0.fsf@gmail.com>
2012-04-06 17:11     ` Alan Mackenzie
2012-04-13  6:53       ` Chong Yidong
2012-04-11 18:15     ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).