[Top][All Lists]

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

RE: Unable to scroll from y-or-n-p prompt

From: Drew Adams
Subject: RE: Unable to scroll from y-or-n-p prompt
Date: Tue, 26 Jun 2012 07:54:43 -0700

> > 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

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)
   (show            ; Entry for `show' action - use `C-l'
    (lambda ()
     (diredp-list-files files nil
                        (generate-new-buffer-name "*Files*")
    ?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.

reply via email to

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