summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-05-30 02:47:55 -0400
committerKyle Meyer <kyle@kyleam.com>2015-05-30 02:47:55 -0400
commit7e4b45ada37f902d71e9a9d84aab89dc43534430 (patch)
treedcfc7c167c077ca6efd3e44072f4f808575cc59f /lisp
parent6e317ca15c1608b007df0fc216ed778098b9cca6 (diff)
downloademacs.d-7e4b45ada37f902d71e9a9d84aab89dc43534430.tar.gz
Add ace-link-widget command
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-ace.el34
-rw-r--r--lisp/init-mail.el5
2 files changed, 39 insertions, 0 deletions
diff --git a/lisp/init-ace.el b/lisp/init-ace.el
index d033e52..9ec2727 100644
--- a/lisp/init-ace.el
+++ b/lisp/init-ace.el
@@ -36,6 +36,40 @@
(push it points)))
(nreverse points))))
+(defun km/ace-link-widget ()
+ "Press a widget that is visible in the current buffer.
+This can be used in place of `ace-link-gnus' and has the
+advantage of working for gwene buffers in addition to normal mail
+buffers working to normal mail buffers because it doesn't rely on
+the 'gnus-string' text property."
+ (interactive)
+ (when (eq major-mode 'gnus-summary-mode)
+ (gnus-summary-widget-forward 1))
+ (let ((res (avy--with-avy-keys km/ace-link-widget
+ (avy--process
+ (km/ali--widget-collect-references)
+ #'avy--overlay-post))))
+ (when res
+ (goto-char (1+ res))
+ (widget-button-press (point)))))
+
+(defun km/ali--widget-collect-references ()
+ "Collect the positions of visible widgets in buffer."
+ (require 'wid-edit)
+ (let (candidates pt)
+ (save-excursion
+ (save-restriction
+ (narrow-to-region
+ (window-start)
+ (window-end))
+ (goto-char (point-min))
+ (setq pt (point))
+ (while (progn (ignore-errors (widget-forward 1))
+ (> (point) pt))
+ (setq pt (point))
+ (push (point) candidates))
+ (nreverse candidates)))))
+
(ace-link-setup-default)
(after 'org
(define-key org-mode-map (kbd "C-c m o") 'ace-link-org))
diff --git a/lisp/init-mail.el b/lisp/init-mail.el
index e385e82..7b7990f 100644
--- a/lisp/init-mail.el
+++ b/lisp/init-mail.el
@@ -173,10 +173,13 @@ to group buffer instead of moving to next group."
(define-key gnus-summary-mode-map "c" 'km/gnus-summary-catchup)
(define-key gnus-summary-mode-map "e" 'gnus-summary-scroll-up)
(define-key gnus-summary-mode-map "j" 'km/gnus-avy-goto-subword-and-select)
+(define-key gnus-summary-mode-map "o" 'km/ace-link-widget)
(define-key gnus-article-mode-map
(kbd "C-c l") 'km/gnus-follow-last-message-link)
(define-key gnus-article-mode-map "e" 'km/shr-browse-url-and-goto-next)
+;; This overrides `gnus-summary-save-article', which is also on 'O o'.
+(define-key gnus-article-mode-map "o" 'km/ace-link-widget)
(define-prefix-command 'km/gnus-summary-prefix-map)
(define-key gnus-summary-mode-map (kbd "C-c m") 'km/gnus-summary-prefix-map)
@@ -342,6 +345,8 @@ has an effect if Gnus is not currently open."
(define-key notmuch-show-mode-map (kbd "C-c C-c") 'km/notmuch-goto-message-in-gnus)
(define-key gnus-group-mode-map "GG" 'notmuch-search)
+(define-key notmuch-hello-mode-map "o" 'km/ace-link-widget)
+
(define-key km/mail-map "n" 'notmuch-search)
(define-prefix-command 'km/notmuch-show-prefix-map)