Allow storing buffer names in registers

* doc/emacs/regs.texi (File and Buffer Registers): Rename and add
doc for `buffer' version.
* lisp/register.el (register-val-jump-to, register-val-describe):
Add support for (buffer . ...) registers (bug#33033).
This commit is contained in:
Lars Ingebrigtsen 2021-11-30 15:14:16 +01:00
parent 3966a28454
commit 7b235b1ec0
4 changed files with 44 additions and 18 deletions

View file

@ -345,14 +345,14 @@ Cut and Paste Operations on Graphical Displays
Registers
* Position Registers:: Saving positions in registers.
* Text Registers:: Saving text in registers.
* Rectangle Registers:: Saving rectangles in registers.
* Configuration Registers:: Saving window configurations in registers.
* Number Registers:: Numbers in registers.
* File Registers:: File names in registers.
* Keyboard Macro Registers:: Keyboard macros in registers.
* Bookmarks:: Bookmarks are like registers, but persistent.
* Position Registers:: Saving positions in registers.
* Text Registers:: Saving text in registers.
* Rectangle Registers:: Saving rectangles in registers.
* Configuration Registers:: Saving window configurations in registers.
* Number Registers:: Numbers in registers.
* File and Buffer Registers:: File and buffer names in registers.
* Keyboard Macro Registers:: Keyboard macros in registers.
* Bookmarks:: Bookmarks are like registers, but persistent.
Controlling the Display

View file

@ -47,14 +47,14 @@ are similar in spirit to registers, so they are also documented in
this chapter.
@menu
* Position Registers:: Saving positions in registers.
* Text Registers:: Saving text in registers.
* Rectangle Registers:: Saving rectangles in registers.
* Configuration Registers:: Saving window configurations in registers.
* Number Registers:: Numbers in registers.
* File Registers:: File names in registers.
* Keyboard Macro Registers:: Keyboard macros in registers.
* Bookmarks:: Bookmarks are like registers, but persistent.
* Position Registers:: Saving positions in registers.
* Text Registers:: Saving text in registers.
* Rectangle Registers:: Saving rectangles in registers.
* Configuration Registers:: Saving window configurations in registers.
* Number Registers:: Numbers in registers.
* File and Buffer Registers:: File and buffer names in registers.
* Keyboard Macro Registers:: Keyboard macros in registers.
* Bookmarks:: Bookmarks are like registers, but persistent.
@end menu
@node Position Registers
@ -238,9 +238,10 @@ register contents into the buffer. @kbd{C-x r +} with no numeric
argument increments the register value by 1; @kbd{C-x r n} with no
numeric argument stores zero in the register.
@node File Registers
@section Keeping File Names in Registers
@node File and Buffer Registers
@section Keeping File and Buffer Names in Registers
@cindex saving file name in a register
@cindex saving buffer name in a register
If you visit certain file names frequently, you can visit them more
conveniently if you put their names in registers. Here's the Lisp code
@ -265,6 +266,15 @@ puts the file name shown in register @samp{z}.
@var{r}}. (This is the same command used to jump to a position or
restore a frame configuration.)
Similarly, if there's certain buffers you visit frequently, you
can put their names in registers. For instance, if you visit the
@samp{*Messages*} buffer often, you can use the following snippet to
put that buffer into the @samp{m} register:
@smallexample
(set-register ?m '(buffer . "*Messages*"))
@end smallexample
@node Keyboard Macro Registers
@section Keyboard Macro Registers
@cindex saving keyboard macro in a register

View file

@ -295,6 +295,15 @@ received.
* Changes in Specialized Modes and Packages in Emacs 29.1
** Registers
+++
*** Buffer names can now be stored in registers.
For instance, to enable jumping to the *Messages* buffer with
`C-x r j m':
(set-register ?m '(buffer . "*Messages*"))
** pixel-fill
*** This is a new package that deals with filling variable-pitch text.

View file

@ -279,6 +279,8 @@ ARG is the value of the prefix argument or nil."
(goto-char (cadr val)))
((eq (car val) 'file)
(find-file (cdr val)))
((eq (car val) 'buffer)
(switch-to-buffer (cdr val)))
((eq (car val) 'file-query)
(or (find-buffer-visiting (nth 1 val))
(y-or-n-p (format "Visit file %s again? " (nth 1 val)))
@ -417,6 +419,11 @@ Interactively, reads the register using `register-read-with-preview'."
(prin1 (cdr val))
(princ "."))
((eq (car val) 'buffer)
(princ "the buffer ")
(prin1 (cdr val))
(princ "."))
((eq (car val) 'file-query)
(princ "a file-query reference:\n file ")
(prin1 (car (cdr val)))