app/twitter: add +twitter/ace-link command

This commit is contained in:
Henrik Lissner 2018-05-12 23:17:48 +02:00
parent daf4c93e36
commit 5a13c436ff
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -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))))