Subject: bug#11142: 24.0.94; objc-mode fails for imenu and which-function-mode

From: Stefan Monnier <[email-masked]>
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)