[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 6a272dedad3 2/2: ; Touch up 'buffer-to-register'
From: |
Eshel Yaron |
Subject: |
master 6a272dedad3 2/2: ; Touch up 'buffer-to-register' |
Date: |
Tue, 8 Oct 2024 05:17:52 -0400 (EDT) |
branch: master
commit 6a272dedad384614190ee04bf1a47aff05c7dd3b
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
; Touch up 'buffer-to-register'
* lisp/register.el (buffer-to-register): Refine docstring
and interactive prompts; sharp-quote function name.
---
lisp/register.el | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/lisp/register.el b/lisp/register.el
index d9dbc3ab186..407fd8a8779 100644
--- a/lisp/register.el
+++ b/lisp/register.el
@@ -718,20 +718,25 @@ for FILE-NAME."
(set-register register (cons 'file file-name))))
(defun buffer-to-register (buffer register)
- "Insert BUFFER into REGISTER.
+ "Store reference to BUFFER in REGISTER.
To visit the buffer, use \\[jump-to-register].
-Interactively, prompt for REGISTER using `register-read-with-preview'.
-With a prefix-argument, prompt for BUFFER-NAME using `read-buffer',
-With no prefix-argument, use the current buffer for BUFFER."
- (interactive (list (if (eq current-prefix-arg nil)
- (current-buffer)
- (read-buffer "Buffer: "))
- (register-read-with-preview "Buffer to register: ")))
- (let ((buffer (or (get-buffer buffer) buffer)))
- (with-current-buffer buffer
- (add-hook 'kill-buffer-hook 'register-buffer-to-file-query nil t))
- (set-register register (cons 'buffer buffer))))
+Interactively, use current buffer as BUFFER, and prompt for REGISTER.
+With a prefix argument, prompt for BUFFER as well."
+ (interactive
+ (let ((buffer
+ (if current-prefix-arg
+ (get-buffer (read-buffer "Store reference to buffer"
+ (current-buffer) t))
+ (current-buffer))))
+ (list buffer
+ (register-read-with-preview
+ (substitute-quotes
+ (format "Store reference to buffer `%s' in register: "
+ (buffer-name buffer)))))))
+ (with-current-buffer buffer
+ (add-hook 'kill-buffer-hook #'register-buffer-to-file-query nil t))
+ (set-register register (cons 'buffer buffer)))
(cl-defgeneric register-val-jump-to (_val _arg)
"Execute the \"jump\" operation of VAL.