diff options
| author | Stefan Monnier | 2025-04-29 22:48:33 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2025-04-30 12:28:34 -0400 |
| commit | fcaec1ff0d6be18d4fa3682401ced30741be6243 (patch) | |
| tree | 17528c8d4fa1a8c7a83efc8921048f75861dbb25 | |
| parent | 44069711e87c3a56f36a917ee46d673f77e0c733 (diff) | |
| download | emacs-fcaec1ff0d6be18d4fa3682401ced30741be6243.tar.gz emacs-fcaec1ff0d6be18d4fa3682401ced30741be6243.zip | |
(register-preview-function): Use a single default again
* lisp/register.el (register-preview-function): Revert to Emacs<30 value.
(register-use-preview, register-preview, register-preview-1):
Don't touch it.
(register-preview-default): Merge it with `register-preview-default-1`.
(register--preview-function): Delete function.
| -rw-r--r-- | lisp/register.el | 41 |
1 files changed, 7 insertions, 34 deletions
diff --git a/lisp/register.el b/lisp/register.el index 8a71fd70a79..a1bffb5529b 100644 --- a/lisp/register.el +++ b/lisp/register.el | |||
| @@ -120,12 +120,11 @@ provided function, `register-read-with-preview-traditional', behaves | |||
| 120 | the same as in Emacs 29 and before: no filtering, no navigation, | 120 | the same as in Emacs 29 and before: no filtering, no navigation, |
| 121 | and no defaults.") | 121 | and no defaults.") |
| 122 | 122 | ||
| 123 | (defvar register-preview-function nil | 123 | (defvar register-preview-function #'register-preview-default |
| 124 | "Function to format a register for previewing. | 124 | "Function to format a register for previewing. |
| 125 | Called with one argument, a cons (NAME . CONTENTS), as found | 125 | Called with one argument, a cons (NAME . CONTENTS), as found |
| 126 | in `register-alist'. The function should return a string, the | 126 | in `register-alist'. The function should return a string, the |
| 127 | description of the argument. The function to use is set according | 127 | description of the argument.") |
| 128 | to the value of `register--read-with-preview-function'.") | ||
| 129 | 128 | ||
| 130 | (defcustom register-use-preview 'traditional | 129 | (defcustom register-use-preview 'traditional |
| 131 | "Whether register commands show preview of registers with non-nil values. | 130 | "Whether register commands show preview of registers with non-nil values. |
| @@ -158,8 +157,7 @@ behavior of Emacs 29 and before." | |||
| 158 | (setq register--read-with-preview-function | 157 | (setq register--read-with-preview-function |
| 159 | (if (eq val 'traditional) | 158 | (if (eq val 'traditional) |
| 160 | #'register-read-with-preview-traditional | 159 | #'register-read-with-preview-traditional |
| 161 | #'register-read-with-preview-fancy)) | 160 | #'register-read-with-preview-fancy)))) |
| 162 | (setq register-preview-function nil))) | ||
| 163 | 161 | ||
| 164 | (defun get-register (register) | 162 | (defun get-register (register) |
| 165 | "Return contents of Emacs register named REGISTER, or nil if none." | 163 | "Return contents of Emacs register named REGISTER, or nil if none." |
| @@ -179,32 +177,13 @@ See the documentation of the variable `register-alist' for possible VALUEs." | |||
| 179 | (substring d (match-end 0)) | 177 | (substring d (match-end 0)) |
| 180 | d))) | 178 | d))) |
| 181 | 179 | ||
| 182 | (defun register-preview-default-1 (r) | ||
| 183 | "Function used to format a register for fancy previewing. | ||
| 184 | This is used as the value of the variable `register-preview-function' | ||
| 185 | when `register-use-preview' is set to t or nil." | ||
| 186 | (format "%s: %s\n" | ||
| 187 | (propertize (string (car r)) | ||
| 188 | 'display (single-key-description (car r))) | ||
| 189 | (register-describe-oneline (car r)))) | ||
| 190 | |||
| 191 | (defun register-preview-default (r) | 180 | (defun register-preview-default (r) |
| 192 | "Function used to format a register for traditional preview. | 181 | "Function used to format a register for previewing. |
| 193 | This is the default value of the variable `register-preview-function', | 182 | This is the default value of the variable `register-preview-function'." |
| 194 | and is used when `register-use-preview' is set to `traditional'." | ||
| 195 | (format "%s: %s\n" | 183 | (format "%s: %s\n" |
| 196 | (single-key-description (car r)) | 184 | (single-key-description (car r)) |
| 197 | (register-describe-oneline (car r)))) | 185 | (register-describe-oneline (car r)))) |
| 198 | 186 | ||
| 199 | (cl-defgeneric register--preview-function (read-preview-function) | ||
| 200 | "Return a function to format registers for previewing by READ-PREVIEW-FUNCTION.") | ||
| 201 | (cl-defmethod register--preview-function ((_read-preview-function | ||
| 202 | (eql register-read-with-preview-traditional))) | ||
| 203 | #'register-preview-default) | ||
| 204 | (cl-defmethod register--preview-function ((_read-preview-function | ||
| 205 | (eql register-read-with-preview-fancy))) | ||
| 206 | #'register-preview-default-1) | ||
| 207 | |||
| 208 | (cl-defstruct register-preview-info | 187 | (cl-defstruct register-preview-info |
| 209 | "Store data for a specific register command. | 188 | "Store data for a specific register command. |
| 210 | TYPES are the supported types of registers. | 189 | TYPES are the supported types of registers. |
| @@ -332,7 +311,7 @@ Do nothing when defining or executing kmacros." | |||
| 332 | pos) | 311 | pos) |
| 333 | (goto-char (if ovs | 312 | (goto-char (if ovs |
| 334 | (overlay-start (car ovs)) | 313 | (overlay-start (car ovs)) |
| 335 | (point-min))) | 314 | (point-min))) |
| 336 | (setq pos (point)) | 315 | (setq pos (point)) |
| 337 | (and ovs (forward-line arg)) | 316 | (and ovs (forward-line arg)) |
| 338 | (when (and (funcall fn) | 317 | (when (and (funcall fn) |
| @@ -401,9 +380,6 @@ satisfy `cl-typep', otherwise the new type should be defined with | |||
| 401 | "Pop up a window showing the preview of registers in BUFFER. | 380 | "Pop up a window showing the preview of registers in BUFFER. |
| 402 | If SHOW-EMPTY is non-nil, show the preview window even if no registers. | 381 | If SHOW-EMPTY is non-nil, show the preview window even if no registers. |
| 403 | Format of each entry is controlled by the variable `register-preview-function'." | 382 | Format of each entry is controlled by the variable `register-preview-function'." |
| 404 | (unless register-preview-function | ||
| 405 | (setq register-preview-function (register--preview-function | ||
| 406 | register--read-with-preview-function))) | ||
| 407 | (when (or show-empty (consp register-alist)) | 383 | (when (or show-empty (consp register-alist)) |
| 408 | (with-current-buffer-window buffer | 384 | (with-current-buffer-window buffer |
| 409 | register-preview-display-buffer-alist | 385 | register-preview-display-buffer-alist |
| @@ -431,9 +407,6 @@ If SHOW-EMPTY is non-nil, show the preview window even if no registers. | |||
| 431 | Optional argument TYPES (a list) specifies the types of register to show; | 407 | Optional argument TYPES (a list) specifies the types of register to show; |
| 432 | if it is nil, show all the registers. See `register-type' for suitable types. | 408 | if it is nil, show all the registers. See `register-type' for suitable types. |
| 433 | Format of each entry is controlled by the variable `register-preview-function'." | 409 | Format of each entry is controlled by the variable `register-preview-function'." |
| 434 | (unless register-preview-function | ||
| 435 | (setq register-preview-function (register--preview-function | ||
| 436 | register--read-with-preview-function))) | ||
| 437 | (let ((registers (register-of-type-alist (or types '(all))))) | 410 | (let ((registers (register-of-type-alist (or types '(all))))) |
| 438 | (when (or show-empty (consp registers)) | 411 | (when (or show-empty (consp registers)) |
| 439 | (with-current-buffer-window | 412 | (with-current-buffer-window |
| @@ -582,7 +555,7 @@ or `never'." | |||
| 582 | (setq input "") | 555 | (setq input "") |
| 583 | (delete-minibuffer-contents) | 556 | (delete-minibuffer-contents) |
| 584 | (minibuffer-message "Not matching")) | 557 | (minibuffer-message "Not matching")) |
| 585 | (when (not (string= input pat)) | 558 | (when (not (string= input pat)) ;; FIXME: Why this test? |
| 586 | (setq pat input)))) | 559 | (setq pat input)))) |
| 587 | (unless (or (string= pat "") | 560 | (unless (or (string= pat "") |
| 588 | (get-text-property (minibuffer-prompt-end) | 561 | (get-text-property (minibuffer-prompt-end) |