summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/shortdoc.el
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2022-09-25 13:48:12 +0200
committerStefan Kangas <stefankangas@gmail.com>2022-09-25 13:48:52 +0200
commite5896907813a9540d0a6b3e60f682afd273fc8e9 (patch)
tree958d2fa5b5ec3834e5a7666bfe3e98fea1ab13e0 /lisp/emacs-lisp/shortdoc.el
parent46ec36adfd3925816f3baa87c5b457ade2677c43 (diff)
downloademacs-e5896907813a9540d0a6b3e60f682afd273fc8e9.tar.gz
emacs-e5896907813a9540d0a6b3e60f682afd273fc8e9.tar.bz2
emacs-e5896907813a9540d0a6b3e60f682afd273fc8e9.zip
Add new command 'shortdoc-copy-function-as-kill'
* lisp/emacs-lisp/shortdoc.el (shortdoc-copy-function-as-kill): New command. (shortdoc-mode-map): Bind above new command to "w".
Diffstat (limited to 'lisp/emacs-lisp/shortdoc.el')
-rw-r--r--lisp/emacs-lisp/shortdoc.el17
1 files changed, 16 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el
index 13d99adcf08..33106808d28 100644
--- a/lisp/emacs-lisp/shortdoc.el
+++ b/lisp/emacs-lisp/shortdoc.el
@@ -1515,7 +1515,8 @@ Example:
"N" #'shortdoc-next-section
"P" #'shortdoc-previous-section
"C-c C-n" #'shortdoc-next-section
- "C-c C-p" #'shortdoc-previous-section)
+ "C-c C-p" #'shortdoc-previous-section
+ "w" #'shortdoc-copy-function-as-kill)
(define-derived-mode shortdoc-mode special-mode "shortdoc"
"Mode for shortdoc."
@@ -1557,6 +1558,20 @@ With ARG, do it that many times."
(shortdoc--goto-section arg 'shortdoc-section t)
(forward-line -2))
+(defun shortdoc-copy-function-as-kill ()
+ "Copy name of the function near point into the kill ring."
+ (interactive)
+ (save-excursion
+ (goto-char (pos-bol))
+ (when-let* ((re (rx bol "(" (group (+ (not (in " "))))))
+ (string
+ (and (or (looking-at re)
+ (re-search-backward re nil t))
+ (match-string 1))))
+ (set-text-properties 0 (length string) nil string)
+ (kill-new string)
+ (message string))))
+
(provide 'shortdoc)
;;; shortdoc.el ends here