diff options
author | Alan Mackenzie <acm@muc.de> | 2017-11-03 19:45:17 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2017-11-03 19:45:17 +0000 |
commit | a0d30d6369018deeffcae174a3c615e582de74d3 (patch) | |
tree | 3e0f21a0f8aae8b225bdce7f15c36d187690db57 /lisp/progmodes/cc-cmds.el | |
parent | 383abc8898cbdb46e460adffbccfda8b2236d24e (diff) | |
download | emacs-a0d30d6369018deeffcae174a3c615e582de74d3.tar.gz emacs-a0d30d6369018deeffcae174a3c615e582de74d3.tar.bz2 emacs-a0d30d6369018deeffcae174a3c615e582de74d3.zip |
Introduce a function to CC Mode which displays the current function name
Remove an erroneous interactive specification from two functions.
* lisp/progmodes/cc-cmds.el (c-display-defun-name): New command.
(c-defun-name, c-cpp-define-name): Remove interactive specification.
* lisp/progmodes/cc-mode.el (c-mode-base-map): Add binding C-c C-z for the new
command.
* doc/misc/cc-mode.texi (Other Commands): Add documentation for the new
command.
Diffstat (limited to 'lisp/progmodes/cc-cmds.el')
-rw-r--r-- | lisp/progmodes/cc-cmds.el | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index ca64b544200..2b663135932 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -1821,7 +1821,6 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'." "Return the name of the current defun, or NIL if there isn't one. \"Defun\" here means a function, or other top level construct with a brace block." - (interactive) (c-save-buffer-state (beginning-of-defun-function end-of-defun-function where pos name-end case-fold-search) @@ -2048,6 +2047,23 @@ with a brace block." (eq (char-after) ?\{) (cons (point-min) (point-max)))))))) +(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))))) +(put 'c-display-defun-name 'isearch-scroll t) + (defun c-mark-function () "Put mark at end of the current top-level declaration or macro, point at beginning. If point is not inside any then the closest following one is @@ -2092,7 +2108,6 @@ function does not require the declaration to contain a brace block." (defun c-cpp-define-name () "Return the name of the current CPP macro, or NIL if we're not in one." - (interactive) (let (case-fold-search) (save-excursion (and c-opt-cpp-macro-define-start |