aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-tl.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-07 21:14:51 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-07 21:14:51 +0200
commit025d9945a5d3bdc9077095c772adef257c4e6e2f (patch)
treed9fadb50e1bf7278b33fe9557a069ad52ce76fdd /lisp/mastodon-tl.el
parentc7afbef1ce48ba829b078388cbda5f79103f89c4 (diff)
refactor next/prev tab item
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r--lisp/mastodon-tl.el26
1 files changed, 9 insertions, 17 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 3d6f7cf..ecefa66 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -279,7 +279,7 @@ than `switch-to-buffer'."
;;; NAV
-(defun mastodon-tl--next-tab-item ()
+(defun mastodon-tl--next-tab-item (&optional previous)
"Move to the next interesting item.
This could be the next toot, link, or image; whichever comes first.
Don't move if nothing else to move to is found, i.e. near the end of the buffer.
@@ -287,11 +287,14 @@ This also skips tab items in invisible text, i.e. hidden spoiler text."
(interactive)
(let (next-range
(search-pos (point)))
- (while (and (setq next-range (mastodon-tl--find-next-or-previous-property-range
- 'mastodon-tab-stop search-pos nil))
+ (while (and (setq next-range
+ (mastodon-tl--find-next-or-previous-property-range
+ 'mastodon-tab-stop search-pos previous))
(get-text-property (car next-range) 'invisible)
- (setq search-pos (1+ (cdr next-range))))
- ;; do nothing, all the action in in the while condition
+ (setq search-pos (if previous
+ (1- (car next-range))
+ (1+ (cdr next-range)))))
+ ;; do nothing, all the action is in the while condition
)
(if (null next-range)
(message "Nothing else here.")
@@ -305,18 +308,7 @@ first. Don't move if nothing else to move to is found, i.e. near
the start of the buffer. This also skips tab items in invisible
text, i.e. hidden spoiler text."
(interactive)
- (let (next-range
- (search-pos (point)))
- (while (and (setq next-range (mastodon-tl--find-next-or-previous-property-range
- 'mastodon-tab-stop search-pos t))
- (get-text-property (car next-range) 'invisible)
- (setq search-pos (1- (car next-range))))
- ;; do nothing, all the action in in the while condition
- )
- (if (null next-range)
- (message "Nothing else before this.")
- (goto-char (car next-range))
- (message "%s" (mastodon-tl--property 'help-echo :no-move)))))
+ (mastodon-tl--next-tab-item :previous))
(defun mastodon-tl--goto-toot-pos (find-pos refresh &optional pos)
"Search for toot with FIND-POS.