1 ;; Compatibility functions for emacs 23 and 24 pre 24.4
3 ;; The functions in this file are copied from eamcs 24.4 and are
4 ;; Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2014 Free Software
7 (if (fboundp 'setq-local)
8 (defalias 'notmuch-setq-local 'setq-local)
9 (defmacro notmuch-setq-local (var val)
10 "Set variable VAR to value VAL in current buffer.
12 Backport of setq-local for emacs without setq-local (pre 24.3)."
13 `(set (make-local-variable ',var) ,val)))
15 (if (fboundp 'read-char-choice)
16 (defalias 'notmuch-read-char-choice 'read-char-choice)
17 (defun notmuch-read-char-choice (prompt chars &optional inhibit-keyboard-quit)
18 "Read and return one of CHARS, prompting for PROMPT.
19 Any input that is not one of CHARS is ignored.
21 If optional argument INHIBIT-KEYBOARD-QUIT is non-nil, ignore
22 keyboard-quit events while waiting for a valid input.
24 This is an exact copy of this function from emacs 24 for use on
25 emacs 23, except with the one emacs 24 only function it calls
28 (error "Called `read-char-choice' without valid char choices"))
29 (let (char done show-help (helpbuf " *Char Help*"))
30 (let ((cursor-in-echo-area t)
31 (executing-kbd-macro executing-kbd-macro)
33 (save-window-excursion ; in case we call help-form-show
35 (unless (get-text-property 0 'face prompt)
36 (setq prompt (propertize prompt 'face 'minibuffer-prompt)))
37 (setq char (let ((inhibit-quit inhibit-keyboard-quit))
39 (and show-help (buffer-live-p (get-buffer helpbuf))
40 (kill-buffer helpbuf))
42 ((not (numberp char)))
43 ;; If caller has set help-form, that's enough.
44 ;; They don't explicitly have to add help-char to chars.
48 ;; This is an inlined copy of help-form-show as that
49 ;; was introduced in emacs 24 too.
50 (let ((msg (eval help-form)))
52 (with-output-to-temp-buffer " *Char Help*"
56 ((and executing-kbd-macro (= char -1))
57 ;; read-event returns -1 if we are in a kbd macro and
58 ;; there are no more events in the macro. Attempt to
59 ;; get an event interactively.
60 (setq executing-kbd-macro nil))
61 ((not inhibit-keyboard-quit)
63 ((and (null esc-flag) (eq char ?\e))
65 ((memq char '(?\C-g ?\e))
66 (keyboard-quit))))))))
67 ;; Display the question with the answer. But without cursor-in-echo-area.
68 (message "%s%s" prompt (char-to-string char))
71 ;; End of compatibility functions
73 (provide 'notmuch-compat)