aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorAlan Mackenzie2017-11-03 19:45:17 +0000
committerAlan Mackenzie2017-11-03 19:45:17 +0000
commita0d30d6369018deeffcae174a3c615e582de74d3 (patch)
tree3e0f21a0f8aae8b225bdce7f15c36d187690db57 /lisp
parent383abc8898cbdb46e460adffbccfda8b2236d24e (diff)
downloademacs-a0d30d6369018deeffcae174a3c615e582de74d3.tar.gz
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')
-rw-r--r--lisp/progmodes/cc-cmds.el19
-rw-r--r--lisp/progmodes/cc-mode.el3
2 files changed, 19 insertions, 3 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'."
1821 "Return the name of the current defun, or NIL if there isn't one. 1821 "Return the name of the current defun, or NIL if there isn't one.
1822\"Defun\" here means a function, or other top level construct 1822\"Defun\" here means a function, or other top level construct
1823with a brace block." 1823with a brace block."
1824 (interactive)
1825 (c-save-buffer-state 1824 (c-save-buffer-state
1826 (beginning-of-defun-function end-of-defun-function 1825 (beginning-of-defun-function end-of-defun-function
1827 where pos name-end case-fold-search) 1826 where pos name-end case-fold-search)
@@ -2048,6 +2047,23 @@ with a brace block."
2048 (eq (char-after) ?\{) 2047 (eq (char-after) ?\{)
2049 (cons (point-min) (point-max)))))))) 2048 (cons (point-min) (point-max))))))))
2050 2049
2050(defun c-display-defun-name (&optional arg)
2051 "Display the name of the current CC mode defun and the position in it.
2052With a prefix arg, push the name onto the kill ring too."
2053 (interactive "P")
2054 (save-restriction
2055 (widen)
2056 (c-save-buffer-state ((name (c-defun-name))
2057 (limits (c-declaration-limits t))
2058 (point-bol (c-point 'bol)))
2059 (when name
2060 (message "%s. Line %s/%s." name
2061 (1+ (count-lines (car limits) point-bol))
2062 (count-lines (car limits) (cdr limits)))
2063 (if arg (kill-new name))
2064 (sit-for 3 t)))))
2065(put 'c-display-defun-name 'isearch-scroll t)
2066
2051(defun c-mark-function () 2067(defun c-mark-function ()
2052 "Put mark at end of the current top-level declaration or macro, point at beginning. 2068 "Put mark at end of the current top-level declaration or macro, point at beginning.
2053If point is not inside any then the closest following one is 2069If 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."
2092 2108
2093(defun c-cpp-define-name () 2109(defun c-cpp-define-name ()
2094 "Return the name of the current CPP macro, or NIL if we're not in one." 2110 "Return the name of the current CPP macro, or NIL if we're not in one."
2095 (interactive)
2096 (let (case-fold-search) 2111 (let (case-fold-search)
2097 (save-excursion 2112 (save-excursion
2098 (and c-opt-cpp-macro-define-start 2113 (and c-opt-cpp-macro-define-start
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index b0e5fe47a7c..f74e931a8bb 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -389,7 +389,8 @@ control). See \"cc-mode.el\" for more info."
389 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version) 389 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version)
390 ;; (define-key c-mode-base-map "\C-c\C-y" 'c-toggle-hungry-state) Commented out by ACM, 2005-11-22. 390 ;; (define-key c-mode-base-map "\C-c\C-y" 'c-toggle-hungry-state) Commented out by ACM, 2005-11-22.
391 (define-key c-mode-base-map "\C-c\C-w" 'c-subword-mode) 391 (define-key c-mode-base-map "\C-c\C-w" 'c-subword-mode)
392 (define-key c-mode-base-map "\C-c\C-k" 'c-toggle-comment-style)) 392 (define-key c-mode-base-map "\C-c\C-k" 'c-toggle-comment-style)
393 (define-key c-mode-base-map "\C-c\C-z" 'c-display-defun-name))
393 394
394;; We don't require the outline package, but we configure it a bit anyway. 395;; We don't require the outline package, but we configure it a bit anyway.
395(cc-bytecomp-defvar outline-level) 396(cc-bytecomp-defvar outline-level)