Domanda

I'm looking for an example, please, of setting a run-with-timer for the following choice scenario -- e.g., (defvar git-window-options-timer 2-seconds) -- if no selection has been made within 2 seconds, then automatically select option ?n. [The functionality would be similar to Grub or rEFIt.]

(let* (
    (git-window-options (read-char-exclusive))
    (target-window (get-buffer-window git-status-buffer)))
  (cond
    ((eq git-window-options ?d)
      (with-current-buffer (get-buffer git-status-buffer)
        (delete-window target-window)))
    ((eq git-window-options ?k)
      (with-current-buffer (get-buffer git-status-buffer)
        (delete-window target-window)
        (kill-buffer (get-buffer git-status-buffer))))
    ((eq git-window-options ?n)
      (message "Done!"))
    (t (message "You have exited the sub-function.")) ))
È stato utile?

Soluzione

The SECONDS option of read-char-exclusive as in

...
(git-window-options (or (read-char-exclusive nil nil git-window-options-timer) ?n))
...

should do the trick. Please, confer with the documentation of read-char-exclusive.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top