[Misc] Enable ‘lispy’ only when available

To ensure that Emacs is still largely responsive without it.
This commit is contained in:
dbo 2019-03-02 11:14:37 +01:00
parent e2522bdbd0
commit a83608e686
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
2 changed files with 16 additions and 5 deletions

13
init.el
View File

@ -133,9 +133,11 @@
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(add-hook 'prog-mode-hook 'page-break-lines-mode)
(add-hook 'lisp-mode-hook 'turn-on-lispy-when-available)
(when (<= 24 emacs-major-version)
(add-hook 'prog-mode-hook 'electric-indent-local-mode))
(add-hook 'lisp-mode-hook 'lispy-mode)
(unless (eq system-type 'windows-nt)
;; flyspell doesnt work on windows right now, need to further investigate
;; what is happening here
@ -544,6 +546,7 @@ search commands like `db/helm-shortcuts."
db/hex-to-ascii
db/ascii-to-hex
conditionally-enable-lispy
turn-on-lispy-when-available
db/sort-nsm-permanent-settings
db/update-cert-file-directory
endless/colorize-compilation
@ -2201,7 +2204,7 @@ search commands like `db/helm-shortcuts."
(use-package elisp-mode
:defer t
:config (progn
(add-hook 'emacs-lisp-mode-hook 'lispy-mode)
(add-hook 'emacs-lisp-mode-hook 'turn-on-lispy-when-available)
(add-hook 'emacs-lisp-mode-hook 'db/add-use-package-to-imenu)))
(use-package geiser
@ -2225,7 +2228,7 @@ search commands like `db/helm-shortcuts."
cider-cljs-lein-repl "(cemerick.piggieback/cljs-repl (cljs.repl.rhino/repl-env))")
:config (progn
(add-hook 'cider-repl-mode-hook 'subword-mode)
(add-hook 'cider-repl-mode-hook 'lispy-mode)
(add-hook 'cider-repl-mode-hook 'turn-on-lispy-when-available)
(add-hook 'cider-repl-mode-hook 'cider-repl-toggle-pretty-printing)
(add-hook 'cider-repl-mode-hook 'company-mode)))
@ -2236,7 +2239,7 @@ search commands like `db/helm-shortcuts."
(forall 'defun)
(exists 'defun)
(dopar 'defun))
(add-hook 'clojure-mode-hook 'lispy-mode)
(add-hook 'clojure-mode-hook 'turn-on-lispy-when-available)
(add-hook 'clojure-mode-hook 'clj-refactor-mode)
(add-hook 'clojure-mode-hook 'yas-minor-mode)
(add-hook 'clojure-mode-hook 'company-mode)))
@ -2269,7 +2272,7 @@ search commands like `db/helm-shortcuts."
(use-package hy-mode
:commands (hy-mode)
:config (progn
(add-hook 'hy-mode-hook 'lispy-mode)
(add-hook 'hy-mode-hook 'turn-on-lispy-when-available)
(add-hook 'hy-mode-hook 'inferior-lisp)))

View File

@ -226,6 +226,14 @@ lispy."
(eq this-command 'pp-eval-expression)))
(lispy-mode 1)))
(defun turn-on-lispy-when-available ()
"Activate `lispy in current buffer when possible.
Will print a warning in case of failure."
(interactive)
(with-demoted-errors "Cannot activate lispy: %s"
(require 'lispy)
(lispy-mode)))
(defun db/sort-nsm-permanent-settings ()
"Sort values in `nsm-permanent-host-settings."
(setq nsm-permanent-host-settings