GNU bug report logs -
#29083
CC Mode 5.32.99 (C/l); M-x c-defun-mode doesn't show anything
Previous Next
Reported by: Felip Moll <lipixx <at> gmail.com>
Date: Tue, 31 Oct 2017 15:42:02 UTC
Severity: normal
Done: Alan Mackenzie <acm <at> muc.de>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi Alan,
This is great. It works and I understand the issue.
Just to know, is there any plan to change it to non-interactive and
provide such an interactive command in CC Mode?
BR
Felip M
--
Felip Moll Marquès
Computer Science Engineer
E-Mail - lipixx <at> gmail.com
WebPage - http://lipix.ciutadella.es
2017-10-31 18:38 GMT+01:00 Alan Mackenzie <acm <at> muc.de>:
> Hello, Felip.
>
> On Tue, Oct 31, 2017 at 13:43:43 +0100, Felip Moll wrote:
>> When inspecting a C code file, I pressed M-x c-defun-mode in order emacs
>> to show me in which function I was, but nothing happened.
>
> Yes, thanks for the report.
>
> The bug here seems to be that c-defun-mode is interactive, when it
> merely returns the function name rather than displaying it. You really
> need a function calling c-defun-name, which then displays it. Here is
> what I use. You're welcome to adapt it to do what you need:
>
> (eval-after-load "cc-mode"
> '(progn
> (defun c-display-defun-name (&optional arg)
> "Display the name of the current CC mode defun and the position in it.
> With a prefix arg, push the name onto the kill ring too."
> (interactive "P")
> (save-restriction
> (widen)
> (c-save-buffer-state ((name (c-defun-name))
> (limits (c-declaration-limits t))
> (point-bol (c-point 'bol)))
> (when name
> (message "%s. Line %s/%s." name
> (1+ (count-lines (car limits) point-bol))
> (count-lines (car limits) (cdr limits)))
> (if arg (kill-new name))
> (sit-for 3 t)))))
> (define-key c-mode-base-map "\C-cn" 'c-display-defun-name)
> (put 'c-display-defun-name 'isearch-scroll t)))
>
> [ Version information an CC Mode dump snipped, but appreciated. ]
>
> --
> Alan Mackenzie (Nuremberg, Germany).
This bug report was last modified 7 years and 264 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.