From 5a13c436ff2e73a37e235f22a3ded2c55e57f112 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 12 May 2018 23:17:48 +0200 Subject: [PATCH] app/twitter: add +twitter/ace-link command --- modules/app/twitter/autoload.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/app/twitter/autoload.el b/modules/app/twitter/autoload.el index 54267d3d9..883390363 100644 --- a/modules/app/twitter/autoload.el +++ b/modules/app/twitter/autoload.el @@ -63,3 +63,26 @@ that works with the feature/popup module." (twittering-rerender-timeline-all buf) (setq-local line-spacing 0.2) (goto-line 0 buf)))) + +;;;###autoload +(defun +twitter/ace-link () + "Open a visible link, username or hashtag in a `twittering-mode' buffer." + (interactive) + (let ((pt (avy-with +twitter/ace-link + (avy--process + (+twitter--collect-links) + (avy--style-fn avy-style))))) + (when (number-or-marker-p pt) + (goto-char pt) + (let ((uri (get-text-property (point) 'uri))) + (if uri (browse-url uri)))))) + +(defun +twitter--collect-links () + (let ((end (window-end)) + points) + (save-excursion + (goto-char (window-start)) + (while (and (< (point) end) + (ignore-errors (twittering-goto-next-thing) t)) + (push (point) points)) + (nreverse points))))