[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e589690781 3/6: Add new command 'shortdoc-copy-function-as-kill'
From: |
Stefan Kangas |
Subject: |
master e589690781 3/6: Add new command 'shortdoc-copy-function-as-kill' |
Date: |
Sun, 25 Sep 2022 08:46:26 -0400 (EDT) |
branch: master
commit e5896907813a9540d0a6b3e60f682afd273fc8e9
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>
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".
---
etc/NEWS | 4 ++++
lisp/emacs-lisp/shortdoc.el | 17 ++++++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index 139e65a4f1..0a5b7bc29c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1714,6 +1714,10 @@ info node. This command only works for the Emacs and
Emacs Lisp manuals.
** Shortdoc
+---
+*** New command 'shortdoc-copy-function-as-kill' bound to 'w'.
+It copies the name of the function near point into the kill ring.
+
---
*** 'N' and 'P' are now bound to 'shortdoc-(next|previous)-section'.
This is in addition to the old keybindings 'C-c C-n' and 'C-c C-p'.
diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el
index 13d99adcf0..33106808d2 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
- master updated (d25a26ab40 -> 489bca19b7), Stefan Kangas, 2022/09/25
- master 46ec36adfd 2/6: * etc/NEWS.22: Belatedly announce 'dired-copy-filename-as-kill'., Stefan Kangas, 2022/09/25
- master 489bca19b7 6/6: Improve shortdoc documentation, Stefan Kangas, 2022/09/25
- master e589690781 3/6: Add new command 'shortdoc-copy-function-as-kill',
Stefan Kangas <=
- master 971566e88a 4/6: Fix shortdoc movement commands, Stefan Kangas, 2022/09/25
- master 3af2f9cce3 1/6: Bind "N"/"P" to next/prev section in shortdoc, Stefan Kangas, 2022/09/25
- master a256f49f08 5/6: Make image-dired-thumb-name more portable, Stefan Kangas, 2022/09/25