[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed 78d3855 026/389: subed-srt-move-to-subtitle-id: Use
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed 78d3855 026/389: subed-srt-move-to-subtitle-id: Use let instead of setq |
Date: |
Fri, 3 Dec 2021 10:59:50 -0500 (EST) |
branch: elpa/subed
commit 78d38559ac5d56b479ee83313ac6ea5cae674d73
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>
subed-srt-move-to-subtitle-id: Use let instead of setq
---
subed/subed-srt.el | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/subed/subed-srt.el b/subed/subed-srt.el
index 52ee70c..c3500de 100644
--- a/subed/subed-srt.el
+++ b/subed/subed-srt.el
@@ -124,26 +124,27 @@ Return point or nil if no subtitle ID could be found."
(interactive)
(if sub-id
(progn
- ;; Start on the first ID and search forward for a line that contains
- ;; only the ID, preceded by one or more blank lines.
- (save-excursion
- (goto-char (point-min))
- (setq regex (format
"\\(\\([[:blank:]]*\n\\)+[[:blank:]]*\n\\|\\`\\)%d$" sub-id))
- (setq match-found (re-search-forward regex nil t)))
- (when match-found
- (goto-char (match-end 0))
- (beginning-of-line)
- (point)))
+ ;; Look for a line that contains only the ID, preceded by one or more
+ ;; blank lines or the beginning of the buffer.
+ (let* ((orig-point (point))
+ (regex (format "\\(%s\\|\\`\\)\\(%d\\)$"
subed-srt--regexp-separator sub-id))
+ (match-found (progn (goto-char (point-min))
+ (re-search-forward regex nil t))))
+ (goto-char orig-point)
+ (when match-found
+ (goto-char (match-beginning 3)))))
(progn
;; Find one or more blank lines.
(re-search-forward "\\([[:blank:]]*\n\\)+" nil t)
;; Find two or more blank lines or the beginning of the buffer, followed
;; by line composed of only digits.
- (re-search-backward (concat "\\(" subed-srt--regexp-separator
"\\|\\`\\)[0-9]+$") nil t)
- (goto-char (match-end 0))
- (beginning-of-line)
- (when (looking-at "^\\([0-9]+\\)$")
- (point)))))
+ (let* ((regex (concat "\\(" subed-srt--regexp-separator
"\\|\\`\\)\\([0-9]+\\)$"))
+ (match-found (re-search-backward regex nil t)))
+ (when match-found
+ (goto-char (match-beginning 3))))))
+ ;; Make extra sure we're on an ID, return nil if we're not
+ (when (looking-at "^\\([0-9]+\\)$")
+ (point)))
(defun subed-srt-move-to-subtitle-id-at-msecs (msecs)
"Move point to the ID of the subtitle that is playing at MSECS.
- [nongnu] elpa/subed 7d4caaa 018/389: Move time adjustment tests, (continued)
- [nongnu] elpa/subed 7d4caaa 018/389: Move time adjustment tests, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed f8a7c6a 029/389: Fix test that failed because of lexical scoping, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b3f2776 032/389: Adjust some test descriptions and apply cosmetics, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 4b16d97 033/389: Trying to do more resilient srt parsing, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 63f0ef5 040/389: In general, subtitle separator must be two or more newlines, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 52ee2ac 006/389: Be more robust when getting subtitle's relative point, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5131bc4 009/389: Add subed-srt-forward/backward-subtitle-end functions, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed c04670a 007/389: Adjust some docstrimgs, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed c5dcb73 010/389: Make closing parens spoon each other, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 8a39911 024/389: Use let instead of setq, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 78d3855 026/389: subed-srt-move-to-subtitle-id: Use let instead of setq,
ELPA Syncer <=
- [nongnu] elpa/subed c895b91 012/389: Add test for sanitizing on empty subtitle texts, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6797d10 028/389: Use lexical scoping, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 7939e0a 022/389: Move function to have same order as tests, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 31f8255 016/389: README: Turns out spaces are not the issue, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 27c8141 014/389: Some work on README, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6b97e24 023/389: Fix test's description, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 7e04e16 013/389: Use C-u ... when inserting subtitles, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 005c0cc 027/389: Remove TODO for C-u N M-k, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed fd737b7 035/389: Use save-excursion in subed--save-excursion, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 0815e10 047/389: Simplify subed-srt--regexp-duration, ELPA Syncer, 2021/12/03