emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole 398f8e4 32/50: Add hypb:def-to-buffer to hypb


From: Stefan Monnier
Subject: [elpa] externals/hyperbole 398f8e4 32/50: Add hypb:def-to-buffer to hypb.el for fast def copying
Date: Wed, 17 Mar 2021 18:44:19 -0400 (EDT)

branch: externals/hyperbole
commit 398f8e4ead18664dc64719e9504b5ffb6b925bda
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    Add hypb:def-to-buffer to hypb.el for fast def copying
---
 hypb.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/hypb.el b/hypb.el
index c3b199b..520ce18 100644
--- a/hypb.el
+++ b/hypb.el
@@ -184,6 +184,22 @@ Global keymap is used unless optional KEYMAP is given."
       ;; string.
       string)))
 
+;; Similar keyboard macro to next function, but less flexible: {C-x 1 M-o F 
M-o a C-x b *scratch* RET M-< M-o s C-@ C-M-h M-o t a C-u C-@ C-u C-@ M-o a 
C-M-p}
+
+;;;###autoload
+(defun hypb:def-to-buffer (&optional arg buffer)
+  "Copy next optional ARG (default = 1) code definitions to the start of 
BUFFER (default = *scratch*) and leave point at the start of the inserted text."
+  (interactive "p\nbDef insertion buffer (default *scratch*): ")
+  (let ((def (save-excursion
+              (mark-defun arg)
+              (deactivate-mark)
+              (buffer-substring (region-beginning) (region-end)))))
+    (pop-to-buffer (or buffer "*scratch*"))
+    (goto-char (point-min))
+    (insert def)
+    (goto-char (point-min))
+    (forward-line 1)))
+
 (defun hypb:domain-name ()
   "Return current Internet domain name with '@' prepended or nil if none."
   (let* ((dname-cmd (or (file-exists-p "/usr/bin/domainname")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]