From 6a6b8e405e82dfcc506bb926f742c9fa1f5b080b Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sun, 2 Feb 2014 16:40:49 -0800 Subject: [PATCH] Be more consistent in using register-read-with-preview to read registers * frameset.el (frameset-to-register): * kmacro.el (kmacro-to-register): * register.el (increment-register): * calc/calc-yank.el (calc-copy-to-register, calc-insert-register) (calc-append-to-register, calc-prepend-to-register): * play/gametree.el (gametree-layout-to-register) (gametree-apply-register-layout): * textmodes/picture.el (picture-clear-rectangle-to-register) (picture-yank-rectangle-from-register): * vc/emerge.el (emerge-combine-versions-register): Use register-read-with-preview to read registers. * cedet/semantic/senator.el (senator-copy-tag-to-register): Use register-read-with-preview, if available. * calculator.el, emulation/viper-cmd.el: Comments. --- lisp/ChangeLog | 14 ++++++++++++++ lisp/calc/calc-yank.el | 30 ++++++++++++++++++++++-------- lisp/calculator.el | 4 ++++ lisp/cedet/ChangeLog | 5 +++++ lisp/cedet/semantic/senator.el | 10 ++++++++-- lisp/emulation/viper-cmd.el | 1 + lisp/frameset.el | 7 +++++-- lisp/kmacro.el | 6 ++++-- lisp/play/gametree.el | 15 +++++++++++---- lisp/register.el | 7 +++++-- lisp/textmodes/picture.el | 15 +++++++++++---- lisp/vc/emerge.el | 8 ++++++-- 12 files changed, 96 insertions(+), 26 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 542e686dfe2..b4391a165d3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,17 @@ +2014-02-03 Glenn Morris + + * frameset.el (frameset-to-register): + * kmacro.el (kmacro-to-register): + * register.el (increment-register): + * calc/calc-yank.el (calc-copy-to-register, calc-insert-register) + (calc-append-to-register, calc-prepend-to-register): + * play/gametree.el (gametree-layout-to-register) + (gametree-apply-register-layout): + * textmodes/picture.el (picture-clear-rectangle-to-register) + (picture-yank-rectangle-from-register): + * vc/emerge.el (emerge-combine-versions-register): + Use register-read-with-preview to read registers. + 2014-02-03 João Távora * elec-pair.el (electric-pair-backward-delete-char): Don't error diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el index 0f38b318432..8d182372cfb 100644 --- a/lisp/calc/calc-yank.el +++ b/lisp/calc/calc-yank.el @@ -163,8 +163,12 @@ text) or `nil'." (defun calc-copy-to-register (register start end &optional delete-flag) "Copy the lines in the region into register REGISTER. -With prefix arg, delete as well." - (interactive "cCopy to register: \nr\nP") +With prefix arg, delete as well. + +Interactively, reads the register using `register-read-with-preview'." + (interactive (list (register-read-with-preview "Copy to register: ") + (region-beginning) (region-end) + current-prefix-arg)) (if (eq major-mode 'calc-mode) (let* ((top-num (calc-locate-cursor-element start)) (top-pos (save-excursion @@ -183,8 +187,10 @@ With prefix arg, delete as well." (copy-to-register register start end delete-flag))) (defun calc-insert-register (register) - "Insert the contents of register REGISTER." - (interactive "cInsert register: ") + "Insert the contents of register REGISTER. + +Interactively, reads the register using `register-read-with-preview'." + (interactive (list (register-read-with-preview "Insert register: "))) (if (eq major-mode 'calc-mode) (let ((val (calc-get-register register))) (calc-wrapper @@ -237,16 +243,24 @@ otherwise the end. If DELETE-FLAG is non-nil, also delete the region." (defun calc-append-to-register (register start end &optional delete-flag) "Copy the lines in the region to the end of register REGISTER. -With prefix arg, also delete the region." - (interactive "cAppend to register: \nr\nP") +With prefix arg, also delete the region. + +Interactively, reads the register using `register-read-with-preview'." + (interactive (list (register-read-with-preview "Append to register: ") + (region-beginning) (region-end) + current-prefix-arg)) (if (eq major-mode 'calc-mode) (calc-add-to-register register start end nil delete-flag) (append-to-register register start end delete-flag))) (defun calc-prepend-to-register (register start end &optional delete-flag) "Copy the lines in the region to the beginning of register REGISTER. -With prefix arg, also delete the region." - (interactive "cPrepend to register: \nr\nP") +With prefix arg, also delete the region. + +Interactively, reads the register using `register-read-with-preview'." + (interactive (list (register-read-with-preview "Prepend to register: ") + (region-beginning) (region-end) + current-prefix-arg)) (if (eq major-mode 'calc-mode) (calc-add-to-register register start end t delete-flag) (prepend-to-register register start end delete-flag))) diff --git a/lisp/calculator.el b/lisp/calculator.el index 3018080da9d..d6eb892f7fb 100644 --- a/lisp/calculator.el +++ b/lisp/calculator.el @@ -1618,6 +1618,8 @@ Optional string argument KEYS will force using it as the keys entered." (setq s (match-string 1 s))) (kill-new s))))) +;; FIXME this should use register-read-with-preview, but it +;; uses calculator-registers rather than register-alist. (defun calculator-set-register (reg) "Set a register value for REG." (interactive "cRegister to store into: ") @@ -1660,6 +1662,8 @@ Used by `calculator-paste' and `get-register'." (or (match-string 3 str) "")))) (ignore-errors (calculator-string-to-number str))))) +;; FIXME this should use register-read-with-preview, but it +;; uses calculator-registers rather than register-alist. (defun calculator-get-register (reg) "Get a value from a register REG." (interactive "cRegister to get value from: ") diff --git a/lisp/cedet/ChangeLog b/lisp/cedet/ChangeLog index 24c076d0bcb..61391d6b16e 100644 --- a/lisp/cedet/ChangeLog +++ b/lisp/cedet/ChangeLog @@ -1,3 +1,8 @@ +2014-02-03 Glenn Morris + + * semantic/senator.el (senator-copy-tag-to-register): + Use register-read-with-preview, if available. + 2014-01-13 Eric Ludlam * semantic/analyze/refs.el (semantic-analyze-refs-impl): Fix typo diff --git a/lisp/cedet/semantic/senator.el b/lisp/cedet/semantic/senator.el index 366f4a8b7ff..afbed323e5d 100644 --- a/lisp/cedet/semantic/senator.el +++ b/lisp/cedet/semantic/senator.el @@ -722,8 +722,14 @@ yanked to." (defun senator-copy-tag-to-register (register &optional kill-flag) "Copy the current tag into REGISTER. Optional argument KILL-FLAG will delete the text of the tag to the -kill ring." - (interactive "cTag to register: \nP") +kill ring. + +Interactively, reads the register using `register-read-with-preview', +if available." + (interactive (list (if (fboundp 'register-read-with-preview) + (register-read-with-preview "Tag to register: ") + (read-char "Tag to register: ")) + current-prefix-arg)) (semantic-fetch-tags) (let ((ft (semantic-obtain-foreign-tag))) (when ft diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index 54690dd6a0f..8ce63b4e63e 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -4831,6 +4831,7 @@ Please, specify your level now: ") (beep 1)) +;; FIXME Use register-read-with-preview? ;; if ENFORCE-BUFFER is not nil, error if CHAR is a marker in another buffer (defun viper-register-to-point (char &optional enforce-buffer) "Like `jump-to-register', but switches to another buffer in another window." diff --git a/lisp/frameset.el b/lisp/frameset.el index 163c6dd7ac3..378fe20a497 100644 --- a/lisp/frameset.el +++ b/lisp/frameset.el @@ -1223,8 +1223,11 @@ Called from `jump-to-register'. Internal use only." (defun frameset-to-register (register &optional _arg) "Store the current frameset in register REGISTER. Use \\[jump-to-register] to restore the frameset. -Argument is a character, naming the register." - (interactive "cFrameset to register: \nP") +Argument is a character, naming the register. + +Interactively, reads the register using `register-read-with-preview'." + (interactive (list (register-read-with-preview "Frameset to register: ") + current-prefix-arg)) (set-register register (registerv-make (vector (frameset-save nil diff --git a/lisp/kmacro.el b/lisp/kmacro.el index d0c34b9749f..c09b15362cb 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -845,11 +845,13 @@ Such a \"function\" cannot be called from Lisp, but it is a valid editor command (kmacro-call-macro current-prefix-arg nil nil k)) (defun kmacro-to-register (r) - "Store the last keyboard macro in register R." + "Store the last keyboard macro in register R. + +Interactively, reads the register using `register-read-with-preview'." (interactive (progn (or last-kbd-macro (error "No keyboard macro defined")) - (list (read-char "Save to register: ")))) + (list (register-read-with-preview "Save to register: ")))) (set-register r (registerv-make last-kbd-macro :jump-func 'kmacro-execute-from-register diff --git a/lisp/play/gametree.el b/lisp/play/gametree.el index 5bb3ca94afc..a2a93730cf0 100644 --- a/lisp/play/gametree.el +++ b/lisp/play/gametree.el @@ -531,8 +531,10 @@ Subnodes which have been manually scored are honored." (defun gametree-layout-to-register (register) "Store current tree layout in register REGISTER. Use \\[gametree-apply-register-layout] to restore that configuration. -Argument is a character, naming the register." - (interactive "cLayout to register: ") +Argument is a character, naming the register. + +Interactively, reads the register using `register-read-with-preview'." + (interactive (list (register-read-with-preview "Layout to register: "))) (save-excursion (goto-char (point-min)) (set-register register @@ -540,8 +542,13 @@ Argument is a character, naming the register." (defun gametree-apply-register-layout (char) "Return to a tree layout stored in a register. -Argument is a character, naming the register." - (interactive "*cApply layout from register: ") +Argument is a character, naming the register. + +Interactively, reads the register using `register-read-with-preview'." + (interactive + (progn + (barf-if-buffer-read-only) + (list (register-read-with-preview "Apply layout from register: ")))) (save-excursion (goto-char (point-min)) (gametree-apply-layout (get-register char) 0 t))) diff --git a/lisp/register.el b/lisp/register.el index 3b65c648d98..1a42d0bf376 100644 --- a/lisp/register.el +++ b/lisp/register.el @@ -296,8 +296,11 @@ If REGISTER contains a number, add `prefix-numeric-value' of PREFIX to it. If REGISTER is empty or if it contains text, call -`append-to-register' with `delete-flag' set to PREFIX." - (interactive "P\ncIncrement register: ") +`append-to-register' with `delete-flag' set to PREFIX. + +Interactively, reads the register using `register-read-with-preview'." + (interactive (list current-prefix-arg + (register-read-with-preview "Increment register: "))) (let ((register-val (get-register register))) (cond ((numberp register-val) diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el index b7ab729abae..615d4c7ed41 100644 --- a/lisp/textmodes/picture.el +++ b/lisp/textmodes/picture.el @@ -494,8 +494,12 @@ prefix argument, the rectangle is actually killed, shifting remaining text." (defun picture-clear-rectangle-to-register (start end register &optional killp) "Clear rectangle delineated by point and mark into REGISTER. The rectangle is saved in REGISTER and replaced with whitespace. With -prefix argument, the rectangle is actually killed, shifting remaining text." - (interactive "r\ncRectangle to register: \nP") +prefix argument, the rectangle is actually killed, shifting remaining text. + +Interactively, reads the register using `register-read-with-preview'." + (interactive (list (region-beginning) (region-end) + (register-read-with-preview "Rectangle to register: ") + current-prefix-arg)) (set-register register (picture-snarf-rectangle start end killp))) (defun picture-snarf-rectangle (start end &optional killp) @@ -534,8 +538,11 @@ regardless of where you click." The rectangle is positioned with upper left corner at point, overwriting existing text. With prefix argument, the rectangle is inserted instead, shifting existing text. Leaves mark at one corner -of rectangle and point at the other (diagonally opposed) corner." - (interactive "cRectangle from register: \nP") +of rectangle and point at the other (diagonally opposed) corner. + +Interactively, reads the register using `register-read-with-preview'." + (interactive (list (register-read-with-preview "Rectangle from register: ") + current-prefix-arg)) (let ((rectangle (get-register register))) (if (not (consp rectangle)) (error "Register %c does not contain a rectangle" register) diff --git a/lisp/vc/emerge.el b/lisp/vc/emerge.el index af13665fc2a..0cf4484aac1 100644 --- a/lisp/vc/emerge.el +++ b/lisp/vc/emerge.el @@ -2516,8 +2516,12 @@ for how the template is interpreted. Refuses to function if this difference has been edited, i.e., if it is neither the A nor the B variant. An argument forces the variant to be selected even if the difference has -been edited." - (interactive "cRegister containing template: \nP") +been edited. + +Interactively, reads the register using `register-read-with-preview'." + (interactive (list + (register-read-with-preview "Register containing template: ") + current-prefix-arg)) (let ((template (get-register char))) (if (not (stringp template)) (error "Register does not contain text")) -- 2.39.2