all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Unable to scroll from y-or-n-p prompt
@ 2012-06-26  7:17 Thierry Volpiatto
  2012-06-26  9:20 ` John Wiegley
  0 siblings, 1 reply; 3+ messages in thread
From: Thierry Volpiatto @ 2012-06-26  7:17 UTC (permalink / raw
  To: emacs-devel

Hi,
I think I have reported this in the past, and it seem not fixed.
This patch fix it, please review.

--8<---------------cut here---------------start------------->8---
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2339,7 +2339,8 @@
                   (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 (or (eq answer 'recenter)
+                                                  (eq answer 'scroll))
                                               prompt
                                             (concat "Please answer y or n.  "
                                                     prompt))
@@ -2349,6 +2350,12 @@
              ((memq answer '(skip act)) nil)
              ((eq answer 'recenter) (recenter) t)
              ((memq answer '(exit-prefix quit)) (signal 'quit nil) t)
+             ((eq key ?\C-v)
+              (setq answer 'scroll)
+              (condition-case nil (scroll-up 1) (error nil)) t)
+             ((eq key ?\M-v)
+              (setq answer 'scroll)
+              (condition-case nil (scroll-down 1) (error nil)) t)
              (t t)))
         (ding)
         (discard-input))))
--8<---------------cut here---------------end--------------->8---

Thanks.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Unable to scroll from y-or-n-p prompt
  2012-06-26  7:17 Unable to scroll from y-or-n-p prompt Thierry Volpiatto
@ 2012-06-26  9:20 ` John Wiegley
  2012-06-26 14:54   ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: John Wiegley @ 2012-06-26  9:20 UTC (permalink / raw
  To: emacs-devel

>>>>> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> I think I have reported this in the past, and it seem not fixed.
> This patch fix it, please review.

Looks simple enough to me.  This allows scrolling of the minibuffer contents
after the question is asked?

John



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Unable to scroll from y-or-n-p prompt
  2012-06-26  9:20 ` John Wiegley
@ 2012-06-26 14:54   ` Drew Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2012-06-26 14:54 UTC (permalink / raw
  To: 'John Wiegley', emacs-devel

> > I think I have reported this in the past, and it seem not fixed.
> > This patch fix it, please review.
> 
> Looks simple enough to me.  This allows scrolling of the 
> minibuffer contents after the question is asked?

Even better might be to let `y-or-n-p' accept one or more args that let a caller
roll additional behavior into the mix.  IOW, scrolling, like recentering and
help, is just one alternative user event that someone might want to incorporate
here.

Otherwise, you have to roll your own when the need arises.  For example, in
Dired+ I have this:

,----
| diredp-y-or-n-files-p is a Lisp function in `dired+.el'.
| 
| (diredp-y-or-n-files-p PROMPT FILES &optional PREDICATE)
| 
| PROMPT user with a "y or n" question about a list of FILES.
| Return t if answer is "y".  Otherwise, return nil.
| 
| Like `y-or-n-p', but the user can also hit `l' to display the list of
| files that the confirmation is for, in buffer `*Files'.  When
| finished, buffer `*Files*' is killed if it was never shown, or is
| hidden and buried otherwise.  Thus, if it was shown then it is still
| available to revisit afterward (even if the user quit using `C-g').
| 
| PREDICATE is passed to `diredp-list-files', to list only file names
| for which it returns non-nil.
`----

The definition is about the same as `y-or-n-p', with the addition of recognition
of an `l' at the prompt to effect an interim action of displaying FILES and a
help key to show a help message.  Oh, and some unwind-protect cleanup.

In short, it does this temporarily:
(define-key query-replace-map "l" 'show)

and adds this to the `case' for the key typed:
(show  (dired-list-files files nil list-buffer predicate))

If `y-or-n-p' accepted some more args to incorporate the ability to recognize
other keys and effect their actions then the definition might be almost as
simple as this:

(defun diredp-y-or-n-files-p (prompt files &optional predicate)
  "..."
  (y-or-n-p
   prompt
   (show            ; Entry for `show' action - use `C-l'
    (lambda ()
     (diredp-list-files files nil
                        (generate-new-buffer-name "*Files*")
                        predicate)))
    ?l)             ; Key to bind to `show'
   (help            ; Entry for `help' action - use help keys
    (lambda ()
     (message "Use `l' to show file list") (sit-for 1)))))

Or we could use a macro etc.

It would be a little more complex than that - being able to tell `y-or-n-p'
about any unwind actions to take, for example (e.g. bury/kill buffer "*Files*").

But you get the idea.  Dunno whether others have found a similar need to allow
additional user events/actions during `y-or-n-p'.  If not, ignore.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-26 14:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-26  7:17 Unable to scroll from y-or-n-p prompt Thierry Volpiatto
2012-06-26  9:20 ` John Wiegley
2012-06-26 14:54   ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.