[Emacs] Fix eros mode advice so values are always returned

This commit is contained in:
Ivan Malison 2016-12-31 14:19:06 -08:00
parent df58c8dfac
commit b79d1f3faf
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -1656,29 +1656,22 @@ https://github.com/alpaker/Fill-Column-Indicator/issues/21 for more details
(defun imalison:set-highlight-indent-guides-faces (&rest args) (defun imalison:set-highlight-indent-guides-faces (&rest args)
(interactive) (interactive)
(require 'highlight-indent-guides)
(let ((bg-color (face-background 'default))) (let ((bg-color (face-background 'default)))
(set-face-background 'highlight-indent-guides-odd-face (when bg-color
(imalison:modify-hsv (set-face-background 'highlight-indent-guides-odd-face
bg-color (imalison:modify-hsv
(imalison:build-safe-change-hsv-value bg-color
(* -1 imalison:hsv-value-delta)))) (imalison:build-safe-change-hsv-value
(set-face-background 'highlight-indent-guides-even-face (* -1 imalison:hsv-value-delta))))
(imalison:modify-hsv (set-face-background 'highlight-indent-guides-even-face
bg-color (imalison:modify-hsv
(imalison:build-safe-change-hsv-value bg-color
imalison:hsv-value-delta))))) (imalison:build-safe-change-hsv-value
imalison:hsv-value-delta))))))
;; XXX: This hacks around the fact that (face-background 'default) is nil at
;; the time of load-theme
(defun imalison:set-highlight-indent-guides-faces-load-theme (&rest args)
(if (face-background 'default)
(progn
(require 'highlight-indent-guides)
(imalison:set-highlight-indent-guides-faces))
(run-at-time "1 sec" nil 'imalison:set-highlight-indent-guides-faces-load-theme)))
(advice-add 'load-theme (advice-add 'load-theme
:after 'imalison:set-highlight-indent-guides-faces-load-theme) :after 'imalison:set-highlight-indent-guides-faces)
(add-hook 'prog-mode-hook 'highlight-indent-guides-mode)) (add-hook 'prog-mode-hook 'highlight-indent-guides-mode))
:config :config
@ -2512,15 +2505,22 @@ Reduce indentation for some functions
(advice-add 'eval-last-sexp :around 'eros-around-eval-last-sexp)) (advice-add 'eval-last-sexp :around 'eros-around-eval-last-sexp))
:preface :preface
(progn (progn
(defvar eros-mode nil)
(defun eros-around-eval-last-sexp (fn &rest args) (defun eros-around-eval-last-sexp (fn &rest args)
(eros--eval-overlay (apply fn args) (point))) (let ((result (apply fn args)))
(when eros-mode
(eros--eval-overlay result (point)))
result))
(defun eros-around-eval-defun (fn &rest args) (defun eros-around-eval-defun (fn &rest args)
(eros--eval-overlay (let ((result (apply fn args)))
(apply fn args) (when eros-mode
(save-excursion (eros--eval-overlay
(end-of-defun) result
(point)))) (save-excursion
(end-of-defun)
(point))))
result))
(add-hook 'emacs-lisp-mode-hook 'eros-mode))) (add-hook 'emacs-lisp-mode-hook 'eros-mode)))
#+END_SRC #+END_SRC