emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109950: Allow scrolling in y-or-n-p.


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109950: Allow scrolling in y-or-n-p.
Date: Sun, 09 Sep 2012 14:43:47 +0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109950
fixes bug: http://debbugs.gnu.org/8948
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2012-09-09 14:43:47 +0800
message:
  Allow scrolling in y-or-n-p.
  
  * lisp/replace.el (query-replace-map): Bind four new symbols for
  requesting window scrolling.
  
  * lisp/subr.el (y-or-n-p): Handle the window-scrolling bindings in
  query-replace-map.
  
  * lisp/custom.el (custom-theme-load-confirm): Use y-or-n-p.
  
  * lisp/window.el (scroll-other-window-down): Make the arg optional.
  
  * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Don't bind scrolling keys
  since they are now in query-replace-map.
  
  * doc/lispref/minibuf.texi (Yes-or-No Queries): Document recentering and
  scrolling in y-or-n-p.  Remove gratuitous example.
  
  * doc/lispref/searching.texi (Search and Replace): Document window scrolling
  entries in query-replace-map.
modified:
  doc/lispref/ChangeLog
  doc/lispref/minibuf.texi
  doc/lispref/searching.texi
  etc/NEWS
  lisp/ChangeLog
  lisp/custom.el
  lisp/emacs-lisp/map-ynp.el
  lisp/replace.el
  lisp/subr.el
  lisp/window.el
=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog     2012-09-08 14:23:01 +0000
+++ b/doc/lispref/ChangeLog     2012-09-09 06:43:47 +0000
@@ -1,3 +1,11 @@
+2012-09-09  Chong Yidong  <address@hidden>
+
+       * minibuf.texi (Yes-or-No Queries): Document recentering and
+       scrolling in y-or-n-p.  Remove gratuitous example.
+
+       * searching.texi (Search and Replace): Document window scrolling
+       entries in query-replace-map.
+
 2012-09-08  Chong Yidong  <address@hidden>
 
        * syntax.texi (Syntax Table Internals): Define "raw syntax

=== modified file 'doc/lispref/minibuf.texi'
--- a/doc/lispref/minibuf.texi  2012-05-27 01:34:14 +0000
+++ b/doc/lispref/minibuf.texi  2012-09-09 06:43:47 +0000
@@ -1888,46 +1888,14 @@
 cursor moves to the echo area while the question is being asked.
 
 The answers and their meanings, even @samp{y} and @samp{n}, are not
-hardwired.  The keymap @code{query-replace-map} specifies them.
address@hidden and Replace}.
-
-In the following example, the user first types @kbd{q}, which is
-invalid.  At the next prompt the user types @kbd{y}.
-
address@hidden Need an interactive example, because otherwise the return value
address@hidden obscures the display of the valid answer.
address@hidden
address@hidden
-(defun ask ()
-  (interactive)
-  (y-or-n-p "Do you need a lift? "))
-
-;; @r{After evaluation of the preceding definition, @kbd{M-x ask}}
-;;   @r{causes the following prompt to appear in the echo area:}
address@hidden group
-
address@hidden
----------- Echo area ----------
-Do you need a lift? (y or n)
----------- Echo area ----------
address@hidden group
-
-;; @r{If the user then types @kbd{q}, the following appears:}
-
address@hidden
----------- Echo area ----------
-Please answer y or n.  Do you need a lift? (y or n)
----------- Echo area ----------
address@hidden group
-
-;; @r{When the user types a valid answer,}
-;;   @r{it is displayed after the question:}
-
address@hidden
----------- Echo area ----------
-Do you need a lift? (y or n) y
----------- Echo area ----------
address@hidden group
+hardwired, and are specified by the keymap @code{query-replace-map}
+(@pxref{Search and Replace}).  In particular, if the user enters the
+special responses @code{recenter}, @code{scroll-up},
address@hidden, @code{scroll-other-window}, or
address@hidden (respectively bound to @kbd{C-l},
address@hidden, @kbd{M-v}, @kbd{C-M-v} and @kbd{C-M-S-v} in
address@hidden), this function performs the specified window
+recentering or scrolling operation, and poses the question again.
 @end smallexample
 
 @noindent

=== modified file 'doc/lispref/searching.texi'
--- a/doc/lispref/searching.texi        2012-05-27 01:34:14 +0000
+++ b/doc/lispref/searching.texi        2012-09-09 06:43:47 +0000
@@ -1796,7 +1796,13 @@
 it.
 
 @item recenter
-Redisplay and center the window, then ask the same question again.
address@hidden scroll-up
address@hidden scroll-down
address@hidden scroll-other-window
address@hidden scroll-other-window-down
+Perform the specified window scroll operation, then ask the same
+question again.  Only @code{y-or-n-p} and related functions use this
+answer.
 
 @item quit
 Perform a quit right away.  Only @code{y-or-n-p} and related functions

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2012-09-08 20:09:06 +0000
+++ b/etc/NEWS  2012-09-09 06:43:47 +0000
@@ -78,6 +78,10 @@
 
 * Changes in Emacs 24.3
 
+** You can now scroll the selected window in most y-or-n prompts.
+Typing C-v or M-v at a prompt scrolls forward or backward
+respectively, without leaving the y-or-n prompt.
+
 ** Help changes
 
 *** `C-h f' (describe-function) can now perform autoloading.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-09 05:50:43 +0000
+++ b/lisp/ChangeLog    2012-09-09 06:43:47 +0000
@@ -1,5 +1,20 @@
 2012-09-09  Chong Yidong  <address@hidden>
 
+       * replace.el (query-replace-map): Bind four new symbols for
+       requesting window scrolling.
+
+       * subr.el (y-or-n-p): Handle the window-scrolling bindings in
+       query-replace-map (Bug#8948).
+
+       * custom.el (custom-theme-load-confirm): Use y-or-n-p.
+
+       * emacs-lisp/map-ynp.el (map-y-or-n-p): Don't bind scrolling keys
+       since they are now in query-replace-map.
+
+       * window.el (scroll-other-window-down): Make the arg optional.
+
+2012-09-09  Chong Yidong  <address@hidden>
+
        * files.el (hack-local-variables-confirm): Use quit-window to kill
        the *Local Variables* buffer.
 

=== modified file 'lisp/custom.el'
--- a/lisp/custom.el    2012-08-15 16:29:11 +0000
+++ b/lisp/custom.el    2012-09-09 06:43:47 +0000
@@ -1223,38 +1223,19 @@
   "Query the user about loading a Custom theme that may not be safe.
 The theme should be in the current buffer.  If the user agrees,
 query also about adding HASH to `custom-safe-themes'."
-  (if noninteractive
-      nil
-    (let ((exit-chars '(?y ?n ?\s))
-         window prompt char)
-      (save-window-excursion
-       (rename-buffer "*Custom Theme*" t)
-       (emacs-lisp-mode)
-       (setq window (display-buffer (current-buffer)))
-       (setq prompt
-             (format "Loading a theme can run Lisp code.  Really load?%s"
-                     (if (and window
-                              (< (line-number-at-pos (point-max))
-                                 (window-body-height)))
-                         " (y or n) "
-                       (push ?\C-v exit-chars)
-                       "\nType y or n, or C-v to scroll: ")))
-       (goto-char (point-min))
-       (while (null char)
-         (setq char (read-char-choice prompt exit-chars))
-         (when (eq char ?\C-v)
-           (if window
-               (with-selected-window window
-                 (condition-case nil
-                     (scroll-up)
-                   (error (goto-char (point-min))))))
-           (setq char nil)))
-       (when (memq char '(?\s ?y))
-         ;; Offer to save to `custom-safe-themes'.
-         (and (or custom-file user-init-file)
-              (y-or-n-p "Treat this theme as safe in future sessions? ")
-              (customize-push-and-save 'custom-safe-themes (list hash)))
-         t)))))
+  (unless noninteractive
+    (save-window-excursion
+      (rename-buffer "*Custom Theme*" t)
+      (emacs-lisp-mode)
+      (setq window (pop-to-buffer (current-buffer)))
+      (goto-char (point-min))
+      (prog1 (when (y-or-n-p "Loading a theme can run Lisp code.  Really load? 
")
+              ;; Offer to save to `custom-safe-themes'.
+              (and (or custom-file user-init-file)
+                   (y-or-n-p "Treat this theme as safe in future sessions? ")
+                   (customize-push-and-save 'custom-safe-themes (list hash)))
+              t)
+       (quit-window)))))
 
 (defun custom-theme-name-valid-p (name)
   "Return t if NAME is a valid name for a Custom theme, nil otherwise.

=== modified file 'lisp/emacs-lisp/map-ynp.el'
--- a/lisp/emacs-lisp/map-ynp.el        2012-07-18 11:44:13 +0000
+++ b/lisp/emacs-lisp/map-ynp.el        2012-09-09 06:43:47 +0000
@@ -123,16 +123,6 @@
            map
             (let ((map (make-sparse-keymap)))
               (set-keymap-parent map query-replace-map)
-              (define-key map [?\C-\M-v] 'scroll-other-window)
-              (define-key map [M-next] 'scroll-other-window)
-              (define-key map [?\C-\M-\S-v] 'scroll-other-window-down)
-              (define-key map [M-prior] 'scroll-other-window-down)
-              ;; The above are rather inconvenient, so maybe we should
-              ;; provide the non-other keys for the other-scroll as well.
-              ;; (define-key map [?\C-v] 'scroll-other-window)
-              ;; (define-key map [next] 'scroll-other-window)
-              ;; (define-key map [?\M-v] 'scroll-other-window-down)
-              ;; (define-key map [prior] 'scroll-other-window-down)
               (dolist (elt action-alist)
                 (define-key map (vector (car elt)) (vector (nth 1 elt))))
               map)))

=== modified file 'lisp/replace.el'
--- a/lisp/replace.el   2012-09-06 08:49:40 +0000
+++ b/lisp/replace.el   2012-09-09 06:43:47 +0000
@@ -1617,14 +1617,28 @@
     (define-key map "?" 'help)
     (define-key map "\C-g" 'quit)
     (define-key map "\C-]" 'quit)
-    (define-key map "\e" 'exit-prefix)
+    (define-key map "\C-v" 'scroll-up)
+    (define-key map "\M-v" 'scroll-down)
+    (define-key map [next] 'scroll-up)
+    (define-key map [prior] 'scroll-down)
+    (define-key map [?\C-\M-v] 'scroll-other-window)
+    (define-key map [M-next] 'scroll-other-window)
+    (define-key map [?\C-\M-\S-v] 'scroll-other-window-down)
+    (define-key map [M-prior] 'scroll-other-window-down)
+    ;; Binding ESC would prohibit the M-v binding.  Instead, callers
+    ;; should check for ESC specially.
+    ;; (define-key map "\e" 'exit-prefix)
     (define-key map [escape] 'exit-prefix)
     map)
-  "Keymap that defines the responses to questions in `query-replace'.
+  "Keymap of responses to questions posed by commands like `query-replace'.
 The \"bindings\" in this map are not commands; they are answers.
 The valid answers include `act', `skip', `act-and-show',
-`exit', `act-and-exit', `edit', `edit-replacement', `delete-and-edit',
-`recenter', `automatic', `backup', `exit-prefix', `quit', and `help'.")
+`act-and-exit', `exit', `exit-prefix', `recenter', `scroll-up',
+`scroll-down', `scroll-other-window', `scroll-other-window-down',
+`edit', `edit-replacement', `delete-and-edit', `automatic',
+`backup', `quit', and `help'.
+
+This keymap is used by `y-or-n-p' as well as `query-replace'.")
 
 (defvar multi-query-replace-map
   (let ((map (make-sparse-keymap)))

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2012-09-08 14:30:09 +0000
+++ b/lisp/subr.el      2012-09-09 06:43:47 +0000
@@ -2319,11 +2319,19 @@
 PROMPT is the string to display to ask the question.  It should
 end in a space; `y-or-n-p' adds \"(y or n) \" to it.
 
-No confirmation of the answer is requested; a single character is enough.
-Also accepts Space to mean yes, or Delete to mean no.  \(Actually, it uses
-the bindings in `query-replace-map'; see the documentation of that variable
-for more information.  In this case, the useful bindings are `act', `skip',
-`recenter', and `quit'.\)
+No confirmation of the answer is requested; a single character is
+enough.  SPC also means yes, and DEL means no.
+
+To be precise, this function translates user input into responses
+by consulting the bindings in `query-replace-map'; see the
+documentation of that variable for more information.  In this
+case, the useful bindings are `act', `skip', `recenter',
+`scroll-up', `scroll-down', and `quit'.
+An `act' response means yes, and a `skip' response means no.
+A `quit' response means to invoke `keyboard-quit'.
+If the user enters `recenter', `scroll-up', or `scroll-down'
+responses, perform the requested window recentering or scrolling
+and ask again.
 
 Under a windowing system a dialog box will be used if `last-nonmenu-event'
 is nil and `use-dialog-box' is non-nil."
@@ -2355,21 +2363,33 @@
                                "" " ")
                            "(y or n) "))
       (while
-          (let* ((key
+          (let* ((scroll-actions '(recenter scroll-up scroll-down
+                                  scroll-other-window 
scroll-other-window-down))
+                (key
                   (let ((cursor-in-echo-area t))
                     (when minibuffer-auto-raise
                       (raise-frame (window-frame (minibuffer-window))))
-                    (read-key (propertize (if (eq answer 'recenter)
+                    (read-key (propertize (if (memq answer scroll-actions)
                                               prompt
                                             (concat "Please answer y or n.  "
                                                     prompt))
                                           'face 'minibuffer-prompt)))))
             (setq answer (lookup-key query-replace-map (vector key) t))
             (cond
-             ((memq answer '(skip act)) nil)
-             ((eq answer 'recenter) (recenter) t)
-             ((memq answer '(exit-prefix quit)) (signal 'quit nil) t)
-             (t t)))
+            ((memq answer '(skip act)) nil)
+            ((eq answer 'recenter)
+             (recenter) t)
+            ((eq answer 'scroll-up)
+             (ignore-errors (scroll-up-command)) t)
+            ((eq answer 'scroll-down)
+             (ignore-errors (scroll-down-command)) t)
+            ((eq answer 'scroll-other-window)
+             (ignore-errors (scroll-other-window)) t)
+            ((eq answer 'scroll-other-window-down)
+             (ignore-errors (scroll-other-window-down)) t)
+            ((or (memq answer '(exit-prefix quit)) (eq key ?\e))
+             (signal 'quit nil) t)
+            (t t)))
         (ding)
         (discard-input))))
     (let ((ret (eq answer 'act)))

=== modified file 'lisp/window.el'
--- a/lisp/window.el    2012-09-08 13:28:11 +0000
+++ b/lisp/window.el    2012-09-09 06:43:47 +0000
@@ -6301,7 +6301,7 @@
 (put 'scroll-down-line 'scroll-command t)
 
 
-(defun scroll-other-window-down (lines)
+(defun scroll-other-window-down (&optional lines)
   "Scroll the \"other window\" down.
 For more details, see the documentation for `scroll-other-window'."
   (interactive "P")


reply via email to

[Prev in Thread] Current Thread [Next in Thread]