Change everything.
[emacs.d.git] / lisp / smex-rc.el
blob636f4c83f2424a6db9f9befd475abbcfd967b223
1 ;;; Simple rc to configure smex.
3 (when (ignore-errors (yard-require 'smex))
4 ;; smex version 3.0 requires a newer `execute-extended-command', but
5 ;; loads even if it is not present (newer versions signal an error,
6 ;; in which case control flow will never reach this point). On the
7 ;; other hand, older versions of smex are happy with an older
8 ;; `execute-extended-command'. Since smex does not (has not
9 ;; historically) provid(ed) a means to get the version, one
10 ;; (inelegant) way to both always clobber M-x with a working `smex'
11 ;; and avoid clobbering with a non-working `smex' is to test `smex'
12 ;; directly.
13 (unless (condition-case nil
14 (yard-flet
15 ;; `smex' attempts to execute whatever
16 ;; `smex-completing-read' returns.’
17 ((smex-completing-read (choices &optional initial-selection)
18 (symbol-name 'yard-do-nothing)))
19 (smex))
20 (error t))
21 (global-set-key (kbd "M-x") 'smex)
22 (global-set-key (kbd "M-X") 'smex-major-mode-commands)))