[Top][All Lists]

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

Re: Strange use of (run-with-timer 0 nil #'foo args) in do-after-load-ev

From: Juri Linkov
Subject: Re: Strange use of (run-with-timer 0 nil #'foo args) in do-after-load-evaluation
Date: Mon, 28 Oct 2019 00:29:56 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

> Why y-or-n-p doesn't use normal minibuffer functions?
> It can finely use read-from-minibuffer with a keymap where
> 'y' and 'n' keys are bound to minibuffer-exiting commands.
> Then history commands will be available for free, so you don't need
> to re-implement minibuffer history commands with `read-char-with-history'.

I meant something like

(defvar y-n-p-map
  (let ((map (make-sparse-keymap)))
    (set-keymap-parent map minibuffer-local-map)
    (define-key map "y" (lambda ()
                          (insert "y")
    (define-key map "n" (lambda ()
                          (insert "n")

(defun y-n-p (prompt)
  (read-from-minibuffer prompt nil y-n-p-map nil 'y-n-p-history))

(y-n-p "Please type y or n: ")

Then all history commands are available, e.g. 'M-p' or the up arrow.

reply via email to

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