diff options
| author | Glenn Morris | 2014-02-01 17:04:08 -0800 |
|---|---|---|
| committer | Glenn Morris | 2014-02-01 17:04:08 -0800 |
| commit | 7c3247627a102b53e9808ef51eca4a22c3a39fa3 (patch) | |
| tree | 0991781118d5d1e1a20952a9f5919e41b2bcd512 | |
| parent | 28e6cee8178fb4134480e01e92a3a58a64e6cbee (diff) | |
| download | emacs-7c3247627a102b53e9808ef51eca4a22c3a39fa3.tar.gz emacs-7c3247627a102b53e9808ef51eca4a22c3a39fa3.zip | |
register preview fixes
* doc/emacs/regs.texi (Registers): Mention previewing.
* lisp/register.el (register-preview-default): New function,
split from register-preview.
(register-preview-function): Rename from register-preview-functions,
make it not a hook.
(register-preview): Use register-preview-function.
(register-read-with-preview): Error on non-character event.
* etc/NEWS: Related markup.
Fixes: debbugs:16595
| -rw-r--r-- | doc/emacs/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/emacs/regs.texi | 9 | ||||
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/register.el | 26 |
5 files changed, 39 insertions, 12 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index 8f29d7c01f6..4478e4bd72c 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2014-02-02 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * regs.texi (Registers): Mention previewing. | ||
| 4 | |||
| 1 | 2014-01-29 Glenn Morris <rgm@gnu.org> | 5 | 2014-01-29 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * killing.texi (Deletion): Mention cycle-spacing. | 7 | * killing.texi (Deletion): Mention cycle-spacing. |
diff --git a/doc/emacs/regs.texi b/doc/emacs/regs.texi index 8ed0d848f59..8968cbbcffa 100644 --- a/doc/emacs/regs.texi +++ b/doc/emacs/regs.texi | |||
| @@ -29,6 +29,15 @@ you store something else in that register. To see what register | |||
| 29 | Display a description of what register @var{r} contains. | 29 | Display a description of what register @var{r} contains. |
| 30 | @end table | 30 | @end table |
| 31 | 31 | ||
| 32 | @vindex register-preview-delay | ||
| 33 | @cindex preview of registers | ||
| 34 | All of the commands that prompt for a register will display a | ||
| 35 | ``preview'' window that lists the existing registers (if there are | ||
| 36 | any) after a short delay. To change the length of the delay, | ||
| 37 | customize @code{register-preview-delay}. To prevent this display, set | ||
| 38 | that option to @code{nil}. You can explicitly request a preview | ||
| 39 | window by pressing @kbd{C-h} or @key{F1}. | ||
| 40 | |||
| 32 | @dfn{Bookmarks} record files and positions in them, so you can | 41 | @dfn{Bookmarks} record files and positions in them, so you can |
| 33 | return to those positions when you look at the file again. Bookmarks | 42 | return to those positions when you look at the file again. Bookmarks |
| 34 | are similar in spirit to registers, so they are also documented in | 43 | are similar in spirit to registers, so they are also documented in |
| @@ -301,6 +301,7 @@ bidirectional context. | |||
| 301 | 301 | ||
| 302 | ** Register changes | 302 | ** Register changes |
| 303 | 303 | ||
| 304 | +++ | ||
| 304 | *** All interactive commands that read a register (`copy-to-register', etc.) | 305 | *** All interactive commands that read a register (`copy-to-register', etc.) |
| 305 | now display a temporary window after `register-preview-delay' seconds | 306 | now display a temporary window after `register-preview-delay' seconds |
| 306 | that summarizes existing registers. To disable this, set that option to nil. | 307 | that summarizes existing registers. To disable this, set that option to nil. |
| @@ -930,7 +931,7 @@ It is layered as: | |||
| 930 | function-carrying place, such as process-filters or `<foo>-function' hooks. | 931 | function-carrying place, such as process-filters or `<foo>-function' hooks. |
| 931 | 932 | ||
| 932 | *** advice-add/advice-remove to add/remove a piece of advice on a named | 933 | *** advice-add/advice-remove to add/remove a piece of advice on a named |
| 933 | function,much like `defadvice' does. | 934 | function, much like `defadvice' does. |
| 934 | 935 | ||
| 935 | ** New package frameset.el. | 936 | ** New package frameset.el. |
| 936 | It provides a set of operations to save a frameset (the state of all | 937 | It provides a set of operations to save a frameset (the state of all |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b2adc2cf881..11952ba98ee 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2014-02-02 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * register.el (register-preview-default): New function, | ||
| 4 | split from register-preview. | ||
| 5 | (register-preview-function): Rename from register-preview-functions, | ||
| 6 | make it not a hook. | ||
| 7 | (register-preview): Use register-preview-function. | ||
| 8 | (register-read-with-preview): Error on non-character event. (Bug#16595) | ||
| 9 | |||
| 1 | 2014-02-01 Dmitry Gutov <dgutov@yandex.ru> | 10 | 2014-02-01 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 11 | ||
| 3 | * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Check for | 12 | * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Check for |
diff --git a/lisp/register.el b/lisp/register.el index 798ea0615d1..cca09930611 100644 --- a/lisp/register.el +++ b/lisp/register.el | |||
| @@ -119,11 +119,21 @@ See the documentation of the variable `register-alist' for possible VALUEs." | |||
| 119 | (substring d (match-end 0)) | 119 | (substring d (match-end 0)) |
| 120 | d))) | 120 | d))) |
| 121 | 121 | ||
| 122 | (defvar register-preview-functions nil) | 122 | (defun register-preview-default (r) |
| 123 | "Default function for the variable `register-preview-function'." | ||
| 124 | (format "%s %s\n" | ||
| 125 | (concat (single-key-description (car r)) ":") | ||
| 126 | (register-describe-oneline (car r)))) | ||
| 127 | |||
| 128 | (defvar register-preview-function #'register-preview-default | ||
| 129 | "Function to format a register for previewing. | ||
| 130 | Takes one argument, a cons (NAME . CONTENTS) as found in `register-alist'. | ||
| 131 | Returns a string.") | ||
| 123 | 132 | ||
| 124 | (defun register-preview (buffer &optional show-empty) | 133 | (defun register-preview (buffer &optional show-empty) |
| 125 | "Pop up a window to show register preview in BUFFER. | 134 | "Pop up a window to show register preview in BUFFER. |
| 126 | If SHOW-EMPTY is non-nil show the window even if no registers." | 135 | If SHOW-EMPTY is non-nil show the window even if no registers. |
| 136 | Format of each entry is controlled by the variable `register-preview-function'." | ||
| 127 | (when (or show-empty (consp register-alist)) | 137 | (when (or show-empty (consp register-alist)) |
| 128 | (with-temp-buffer-window | 138 | (with-temp-buffer-window |
| 129 | buffer | 139 | buffer |
| @@ -132,14 +142,7 @@ If SHOW-EMPTY is non-nil show the window even if no registers." | |||
| 132 | nil | 142 | nil |
| 133 | (with-current-buffer standard-output | 143 | (with-current-buffer standard-output |
| 134 | (setq cursor-in-non-selected-windows nil) | 144 | (setq cursor-in-non-selected-windows nil) |
| 135 | (mapc | 145 | (insert (mapconcat register-preview-function register-alist "")))))) |
| 136 | (lambda (r) | ||
| 137 | (insert (or (run-hook-with-args-until-success | ||
| 138 | 'register-preview-functions r) | ||
| 139 | (format "%s %s\n" | ||
| 140 | (concat (single-key-description (car r)) ":") | ||
| 141 | (register-describe-oneline (car r)))))) | ||
| 142 | register-alist))))) | ||
| 143 | 146 | ||
| 144 | (defun register-read-with-preview (prompt) | 147 | (defun register-read-with-preview (prompt) |
| 145 | "Read and return an event, prompting with PROMPT, possibly showing a preview. | 148 | "Read and return an event, prompting with PROMPT, possibly showing a preview. |
| @@ -162,7 +165,8 @@ such a window regardless." | |||
| 162 | help-chars) | 165 | help-chars) |
| 163 | (unless (get-buffer-window buffer) | 166 | (unless (get-buffer-window buffer) |
| 164 | (register-preview buffer 'show-empty))) | 167 | (register-preview buffer 'show-empty))) |
| 165 | last-input-event) | 168 | (if (characterp last-input-event) last-input-event |
| 169 | (error "Non-character input-event"))) | ||
| 166 | (and (timerp timer) (cancel-timer timer)) | 170 | (and (timerp timer) (cancel-timer timer)) |
| 167 | (let ((w (get-buffer-window buffer))) | 171 | (let ((w (get-buffer-window buffer))) |
| 168 | (and (window-live-p w) (delete-window w))) | 172 | (and (window-live-p w) (delete-window w))) |