summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-02-28 23:52:43 -0500
committerKyle Meyer <kyle@kyleam.com>2017-03-01 00:00:42 -0500
commitf63ab8705efc5d6e3794ab83492812600cabbb38 (patch)
tree45e10421264fa78c7fadc5c465f7842ddfee27af /lisp
parent6b0b7ca514c96fca3ec0165aa17f03331c7789be (diff)
downloademacs.d-f63ab8705efc5d6e3794ab83492812600cabbb38.tar.gz
Use macro for custom avy-goto-subword-1 commands
Diffstat (limited to 'lisp')
-rw-r--r--lisp/km-avy.el38
1 files changed, 19 insertions, 19 deletions
diff --git a/lisp/km-avy.el b/lisp/km-avy.el
index bfed3e1..cc733e3 100644
--- a/lisp/km-avy.el
+++ b/lisp/km-avy.el
@@ -21,58 +21,58 @@
;;; Code:
(require 'avy)
+(require 'cl-macs)
+
+(defmacro km/avy-after-goto (&rest body)
+ (declare (indent defun) (debug (body)))
+ (let ((result (cl-gensym)))
+ `(let ((,result
+ (let ((avy-all-windows nil))
+ (call-interactively #'avy-goto-subword-1))))
+ (when (integerp ,result)
+ ,@body))))
(declare-function occur-mode-display-occurrence "replace")
;;;###autoload
(defun km/occur-avy-goto-subword-1 ()
"Like `avy-goto-subword-1', but display occurence."
(interactive)
- (let (avy-all-windows)
- (call-interactively #'avy-goto-subword-1))
- (occur-mode-display-occurrence))
+ (km/avy-after-goto (occur-mode-display-occurrence)))
(declare-function compilation-display-error "compile")
;;;###autoload
(defun km/grep-avy-goto-subword-1 ()
"Like `avy-goto-subword-1', but call `compilation-display-error'."
(interactive)
- (let (avy-all-windows)
- (call-interactively #'avy-goto-subword-1))
- (compilation-display-error))
+ (km/avy-after-goto (compilation-display-error)))
(declare-function org-agenda-do-context-action "org-agenda")
;;;###autoload
(defun km/org-agenda-avy-goto-subword-1 ()
(interactive)
- (let (avy-all-windows)
- (call-interactively #'avy-goto-subword-1))
- (org-agenda-do-context-action))
+ (km/avy-after-goto (org-agenda-do-context-action)))
(declare-function magit-diff-show-or-scroll-up "magit-diff")
;;;###autoload
(defun km/magit-avy-goto-subword-1 ()
"Like `km/avy-goto-subword-1', but maybe show commit and limit to window."
(interactive)
- (let (avy-all-windows)
- (call-interactively #'avy-goto-subword-1))
- (when (derived-mode-p 'magit-log-mode)
- (magit-diff-show-or-scroll-up)))
+ (km/avy-after-goto
+ (when (derived-mode-p 'magit-log-mode)
+ (magit-diff-show-or-scroll-up))))
(declare-function gnus-summary-scroll-up "gnus-sum" (lines))
;;;###autoload
(defun km/gnus-avy-goto-subword-and-select ()
(interactive)
- (let (avy-all-windows)
- (call-interactively #'avy-goto-subword-1))
- (gnus-summary-scroll-up 0))
+ (km/avy-after-goto (gnus-summary-scroll-up 0)))
(declare-function elfeed-search-show-entry "elfeed-search" (entry))
;;;###autoload
(defun km/elfeed-avy-goto-subword-1 ()
(interactive)
- (let (avy-all-windows)
- (call-interactively #'avy-goto-subword-1))
- (call-interactively #'elfeed-search-show-entry))
+ (km/avy-after-goto
+ (call-interactively #'elfeed-search-show-entry)))
(provide 'km-avy)
;;; km-avy.el ends here