diff options
author | Kyle Meyer <kyle@kyleam.com> | 2015-05-30 02:47:55 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2015-05-30 02:47:55 -0400 |
commit | 7e4b45ada37f902d71e9a9d84aab89dc43534430 (patch) | |
tree | dcfc7c167c077ca6efd3e44072f4f808575cc59f /lisp/init-ace.el | |
parent | 6e317ca15c1608b007df0fc216ed778098b9cca6 (diff) | |
download | emacs.d-7e4b45ada37f902d71e9a9d84aab89dc43534430.tar.gz |
Add ace-link-widget command
Diffstat (limited to 'lisp/init-ace.el')
-rw-r--r-- | lisp/init-ace.el | 34 |
1 files changed, 34 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)) |