From: "Drew Adams" <drew.adams@oracle.com>
To: "'John Wiegley'" <johnw@newartisans.com>, <emacs-devel@gnu.org>
Subject: RE: Unable to scroll from y-or-n-p prompt
Date: Tue, 26 Jun 2012 07:54:43 -0700 [thread overview]
Message-ID: <910E8B50016B43749AAB700663140FC4@us.oracle.com> (raw)
In-Reply-To: <m2txxypgyj.fsf@newartisans.com>
> > 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.
prev parent reply other threads:[~2012-06-26 14:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=910E8B50016B43749AAB700663140FC4@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=johnw@newartisans.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.