branch: elpa/subed commit 4e507962eb02f4422e02d402d57b08cbf746d264 Author: Random User <rnd...@posteo.de> Commit: Random User <rnd...@posteo.de>
Fix subed-srt-backward-subtitle-id Point wasn't preserved if there was no previous subtitle, and it always ended up at the current subtitle ID. --- subed/subed-srt.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/subed/subed-srt.el b/subed/subed-srt.el index d289185..a117b40 100644 --- a/subed/subed-srt.el +++ b/subed/subed-srt.el @@ -229,13 +229,15 @@ Return point or nil if there is no next subtitle." (defun subed-srt-backward-subtitle-id () "Move point to previous subtitle's ID. -Return point or nil if point didn't change (e.g. if called on the -first subtitle)." +Return point or nil if there is no previous subtitle." (interactive) - (when (subed-srt-move-to-subtitle-id) - (let ((orig-point (point))) + (let ((orig-point (point)) + (orig-sub-id (subed-srt--subtitle-id))) + (when (subed-srt-move-to-subtitle-id) (forward-line -1) - (unless (= (point) orig-point) + (if (= (subed-srt--subtitle-id) orig-sub-id) + (progn (goto-char orig-point) + nil) (subed-srt-move-to-subtitle-id))))) (defun subed-srt-forward-subtitle-text ()