Fix text and code of the registers section; add example text block

This commit is contained in:
Gerard Vermeulen 2023-12-16 17:14:53 +01:00
parent d179453a81
commit 86ddd09b24

View File

@ -864,34 +864,39 @@ to claims in [[info:consult#Top][consult (info)]]).
:CUSTOM_ID: sec:registers
:END:
Listing [[lst:setup-register][setup register usage]] sets up relevant register options. Table
[[tab:register-commands-and-bindings]] lists all =bookmark= commands with working
Listing [[lst:register-separator-usage-example][register separator usage example]] shows how to use a register
{{{kbd(+)}}} as register separator when appending regions to text registers.
Listing [[lst:setup-register][setup register usage]] prepares my preferred register usage. Table
[[tab:register-commands-and-bindings]] lists all =register= commands with working
key bindings. The =desktop= library allows to preserve the =register= history
between Emacs sessions.
#+caption[Register separator usage example]:
#+caption: Register separator usage example.
#+name: lst:register-separator-usage-example
#+begin_src text -n :exports code
When I set register ?+ to
(set-register ?+ "\n*REGISTER SEPARATOR*\n")
to test append-to-register on two regions like
Mark this line without new-line as region 1
Mark this line without new-line as region 2
The correct result of
"C-x r s T" with region 1 marked
"C-x r + T" with region 2 marked
"C-x r i T"
is:
Mark this line without new-line as region 1
*REGISTER SEPARATOR*
Mark this line without new-line as region 2
#+end_src
#+caption[Setup register usage]:
#+caption: Setup register usage.
#+name: lst:setup-register
#+begin_src emacs-lisp -n
(with-eval-after-load 'register
;; BUG: (setopt register-separator "\n") warns non-matching type.
;; * lisp/register.el (register-separator): add string type to
;; choice options and clarify documentation.
;; * doc/emacs/regs.texi (Text Registers): fix example setting
;; 'register-separator'.
(defcustom register-separator nil
"Separator between texts collected in registers, or nil if none.
When collecting text with \\[append-to-register] (or \\[prepend-to-register]),
the separator is added to the beginning (or end, respectively) of the marked
text."
:group 'register
:type '(choice (const :tag "None" nil)
(character :tag "Use register" :value ?+)
(string :tag "Use string" :value "")))
(setopt register-separator "\n"
register-use-preview t)
;; Register `?+' serves as register separator when using `append-to-register':
(set-register ?+ "\n")
;; https://emacs.stackexchange.com/a/52290
(defun delete-all-registers ()