Commit 7c324762 authored by Glenn Morris's avatar Glenn Morris

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
parent 28e6cee8
2014-02-02 Glenn Morris <rgm@gnu.org>
* regs.texi (Registers): Mention previewing.
2014-01-29 Glenn Morris <rgm@gnu.org> 2014-01-29 Glenn Morris <rgm@gnu.org>
* killing.texi (Deletion): Mention cycle-spacing. * killing.texi (Deletion): Mention cycle-spacing.
......
...@@ -29,6 +29,15 @@ you store something else in that register. To see what register ...@@ -29,6 +29,15 @@ you store something else in that register. To see what register
Display a description of what register @var{r} contains. Display a description of what register @var{r} contains.
@end table @end table
@vindex register-preview-delay
@cindex preview of registers
All of the commands that prompt for a register will display a
``preview'' window that lists the existing registers (if there are
any) after a short delay. To change the length of the delay,
customize @code{register-preview-delay}. To prevent this display, set
that option to @code{nil}. You can explicitly request a preview
window by pressing @kbd{C-h} or @key{F1}.
@dfn{Bookmarks} record files and positions in them, so you can @dfn{Bookmarks} record files and positions in them, so you can
return to those positions when you look at the file again. Bookmarks return to those positions when you look at the file again. Bookmarks
are similar in spirit to registers, so they are also documented in are similar in spirit to registers, so they are also documented in
......
...@@ -301,6 +301,7 @@ bidirectional context. ...@@ -301,6 +301,7 @@ bidirectional context.
** Register changes ** Register changes
+++
*** All interactive commands that read a register (`copy-to-register', etc.) *** All interactive commands that read a register (`copy-to-register', etc.)
now display a temporary window after `register-preview-delay' seconds now display a temporary window after `register-preview-delay' seconds
that summarizes existing registers. To disable this, set that option to nil. that summarizes existing registers. To disable this, set that option to nil.
...@@ -930,7 +931,7 @@ It is layered as: ...@@ -930,7 +931,7 @@ It is layered as:
function-carrying place, such as process-filters or `<foo>-function' hooks. function-carrying place, such as process-filters or `<foo>-function' hooks.
*** advice-add/advice-remove to add/remove a piece of advice on a named *** advice-add/advice-remove to add/remove a piece of advice on a named
function,much like `defadvice' does. function, much like `defadvice' does.
** New package frameset.el. ** New package frameset.el.
It provides a set of operations to save a frameset (the state of all It provides a set of operations to save a frameset (the state of all
......
2014-02-02 Glenn Morris <rgm@gnu.org>
* 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. (Bug#16595)
2014-02-01 Dmitry Gutov <dgutov@yandex.ru> 2014-02-01 Dmitry Gutov <dgutov@yandex.ru>
* progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Check for * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Check for
......
...@@ -119,11 +119,21 @@ See the documentation of the variable `register-alist' for possible VALUEs." ...@@ -119,11 +119,21 @@ See the documentation of the variable `register-alist' for possible VALUEs."
(substring d (match-end 0)) (substring d (match-end 0))
d))) d)))
(defvar register-preview-functions nil) (defun register-preview-default (r)
"Default function for the variable `register-preview-function'."
(format "%s %s\n"
(concat (single-key-description (car r)) ":")
(register-describe-oneline (car r))))
(defvar register-preview-function #'register-preview-default
"Function to format a register for previewing.
Takes one argument, a cons (NAME . CONTENTS) as found in `register-alist'.
Returns a string.")
(defun register-preview (buffer &optional show-empty) (defun register-preview (buffer &optional show-empty)
"Pop up a window to show register preview in BUFFER. "Pop up a window to show register preview in BUFFER.
If SHOW-EMPTY is non-nil show the window even if no registers." If SHOW-EMPTY is non-nil show the window even if no registers.
Format of each entry is controlled by the variable `register-preview-function'."
(when (or show-empty (consp register-alist)) (when (or show-empty (consp register-alist))
(with-temp-buffer-window (with-temp-buffer-window
buffer buffer
...@@ -132,14 +142,7 @@ If SHOW-EMPTY is non-nil show the window even if no registers." ...@@ -132,14 +142,7 @@ If SHOW-EMPTY is non-nil show the window even if no registers."
nil nil
(with-current-buffer standard-output (with-current-buffer standard-output
(setq cursor-in-non-selected-windows nil) (setq cursor-in-non-selected-windows nil)
(mapc (insert (mapconcat register-preview-function register-alist ""))))))
(lambda (r)
(insert (or (run-hook-with-args-until-success
'register-preview-functions r)
(format "%s %s\n"
(concat (single-key-description (car r)) ":")
(register-describe-oneline (car r))))))
register-alist)))))
(defun register-read-with-preview (prompt) (defun register-read-with-preview (prompt)
"Read and return an event, prompting with PROMPT, possibly showing a preview. "Read and return an event, prompting with PROMPT, possibly showing a preview.
...@@ -162,7 +165,8 @@ such a window regardless." ...@@ -162,7 +165,8 @@ such a window regardless."
help-chars) help-chars)
(unless (get-buffer-window buffer) (unless (get-buffer-window buffer)
(register-preview buffer 'show-empty))) (register-preview buffer 'show-empty)))
last-input-event) (if (characterp last-input-event) last-input-event
(error "Non-character input-event")))
(and (timerp timer) (cancel-timer timer)) (and (timerp timer) (cancel-timer timer))
(let ((w (get-buffer-window buffer))) (let ((w (get-buffer-window buffer)))
(and (window-live-p w) (delete-window w))) (and (window-live-p w) (delete-window w)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment