[Misc] Enable lispy in ‘eval-expression’ and the like only if loaded beforehand

This commit is contained in:
Daniel - 2018-01-13 14:19:12 +01:00
parent 14e84f92f5
commit 62ae309381
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
2 changed files with 14 additions and 8 deletions

12
init.el
View File

@ -613,7 +613,8 @@ _h_ _l_ _o_k _y_ank
db/run-or-hide-eshell
db/run-or-hide-ansi-term
db/helm-shortcuts
db/hex-to-ascii))
db/hex-to-ascii
conditionally-enable-lispy))
(use-package db-emacsclient)
@ -1046,13 +1047,8 @@ Certificates are assumed to be of the form *.crt."
;; General Stuff first
(use-package lispy
:commands (lispy-mode conditionally-enable-lispy)
:diminish lispy-mode
:config (progn
(defun conditionally-enable-lispy ()
(when (or (eq this-command 'eval-expression)
(eq this-command 'pp-eval-expression))
(lispy-mode 1)))))
:commands (lispy-mode)
:diminish lispy-mode)
(use-package eldoc
:commands (eldoc-mode)

View File

@ -189,6 +189,16 @@ If not given, FORMAT-STRING defaults to some ISO 8601-like format."
(format-time-string (or format-string "%Y-%m-%dT%H:%M:%S.%9NZ")
(list h l u p)))))
(defun conditionally-enable-lispy ()
"Enable lispy-mode when in `eval-expression or in
`pp-eval-expression. lispy must have been loaded for this
first, i.e., this function will not automatically load
lispy."
(when (and (featurep 'lispy)
(or (eq this-command 'eval-expression)
(eq this-command 'pp-eval-expression)))
(lispy-mode 1)))
;;; dired