* 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
+2014-02-02 Glenn Morris <rgm@gnu.org>
+
+ * regs.texi (Registers): Mention previewing.
+
2014-01-29 Glenn Morris <rgm@gnu.org>
* killing.texi (Deletion): Mention cycle-spacing.
Display a description of what register @var{r} contains.
@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
return to those positions when you look at the file again. Bookmarks
are similar in spirit to registers, so they are also documented in
** Register changes
++++
*** All interactive commands that read a register (`copy-to-register', etc.)
now display a temporary window after `register-preview-delay' seconds
that summarizes existing registers. To disable this, set that option to nil.
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
-function,much like `defadvice' does.
+function, much like `defadvice' does.
** New package frameset.el.
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>
* progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Check for
(substring d (match-end 0))
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)
"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))
(with-temp-buffer-window
buffer
nil
(with-current-buffer standard-output
(setq cursor-in-non-selected-windows nil)
- (mapc
- (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)))))
+ (insert (mapconcat register-preview-function register-alist ""))))))
(defun register-read-with-preview (prompt)
"Read and return an event, prompting with PROMPT, possibly showing a preview.
help-chars)
(unless (get-buffer-window buffer)
(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))
(let ((w (get-buffer-window buffer)))
(and (window-live-p w) (delete-window w)))