[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed f8793fb 330/389: Move motion hooks from subed-config
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed f8793fb 330/389: Move motion hooks from subed-config.el to subed-common.el |
Date: |
Fri, 3 Dec 2021 11:00:51 -0500 (EST) |
branch: elpa/subed
commit f8793fb5ecebddec2f91abbba1b03fbd42285b1b
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>
Move motion hooks from subed-config.el to subed-common.el
---
subed/subed-common.el | 29 +++++++++++++++++++++++++++++
subed/subed-config.el | 26 --------------------------
2 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/subed/subed-common.el b/subed/subed-common.el
index 0e63686..0de7101 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -112,6 +112,35 @@ Before BODY is run, point is placed on the subtitle's ID."
(concat string (make-string (- length (length string)) fillchar)))
+;;; Hooks for point motion and subtitle motion
+
+(defvar-local subed--current-point -1)
+(defvar-local subed--current-subtitle-id -1)
+(defun subed--post-command-handler ()
+ "Detect point motion and user entering text and signal hooks."
+ ;; Check for point motion first to avoid expensive calls to subed-subtitle-id
+ ;; as often as possible.
+ (let ((new-point (point)))
+ (when (and new-point subed--current-point
+ (not (= new-point subed--current-point)))
+
+ ;; If point is synced to playback position, temporarily disable that so
+ ;; that manual moves aren't cancelled immediately by automated moves.
+ (subed-disable-sync-point-to-player-temporarily)
+
+ ;; Store new point and fire signal.
+ (setq subed--current-point new-point)
+ (run-hooks 'subed-point-motion-hook)
+
+ ;; Check if point moved across subtitle boundaries.
+ (let ((new-sub-id (subed-subtitle-id)))
+ (when (and new-sub-id subed--current-subtitle-id
+ (not (= new-sub-id subed--current-subtitle-id)))
+ ;; Store new ID and fire signal.
+ (setq subed--current-subtitle-id new-sub-id)
+ (run-hooks 'subed-subtitle-motion-hook))))))
+
+
;;; Adjusting start/stop time individually
(defun subed-adjust-subtitle-time-start (msecs &optional
diff --git a/subed/subed-config.el b/subed/subed-config.el
index 6660784..6daadd6 100644
--- a/subed/subed-config.el
+++ b/subed/subed-config.el
@@ -222,32 +222,6 @@ The functions are called with the subtitle's start time."
(defvar-local subed-subtitle-motion-hook nil
"Functions to call after current subtitle changed.")
-(defvar-local subed--status-point 1
- "Keeps track of `(point)' to detect changes.")
-
-(defvar-local subed--status-subtitle-id 1
- "Keeps track of `(subed-subtitle-id)' to detect changes.")
-
-(defun subed--post-command-handler ()
- "Detect point motion and user entering text and signal hooks."
- ;; Check for point motion first; skip checking for other changes if it didn't
- (let ((new-point (point)))
- (when (and new-point subed--status-point
- (not (= new-point subed--status-point)))
-
- ;; If point is synced to playback position, temporarily prevent
unexpected
- ;; movement of the cursor.
- (subed-disable-sync-point-to-player-temporarily)
-
- (setq subed--status-point new-point)
- ;; Signal point motion
- (run-hooks 'subed-point-motion-hook)
- (let ((new-sub-id (subed-subtitle-id)))
- (when (and new-sub-id subed--status-subtitle-id
- (not (= subed--status-subtitle-id new-sub-id)))
- (setq subed--status-subtitle-id new-sub-id)
- ;; Signal motion between subtitles
- (run-hooks 'subed-subtitle-motion-hook))))))
(provide 'subed-config)
;;; subed-config.el ends here
- [nongnu] elpa/subed 49ddccc 359/389: Move subed--init-alist to subed.el, (continued)
- [nongnu] elpa/subed 49ddccc 359/389: Move subed--init-alist to subed.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 8263b33 360/389: subed-split-subtitle: Use offset or text fraction, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 1c52f1b 361/389: Add tests for splitting subtitles and handle more cases, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e065632 362/389: Fix previous commit for subed-set-subtitle-text, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ec7b222 368/389: Enable CPS showing by default and improve CPS toggling functions, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed f28ad22 379/389: Make subed-mpv-jump-to-current-subtitle interactive, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed c76ba50 387/389: Prompt for playback speed factor, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 9d0aa0f 388/389: Make make-subtitle a generic function, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d0dfa1a 389/389: Preliminary support for .ass files (Advanced SubStation Alpha), ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed f30780e 249/389: Default keybinding: C-M-i -> subed-insert-subtitle-adjacent, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed f8793fb 330/389: Move motion hooks from subed-config.el to subed-common.el,
ELPA Syncer <=
- [nongnu] elpa/subed 31556c6 372/389: Add functions for bold and italic and change keybindings, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ba22919 289/389: Add subed-mpv-jump-to-current-subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 14ebbbb 293/389: subed-srt--subtitle-id-at-msecs: Return nil if no matching subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 2e18727 294/389: Pause video initially, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3d5902b 295/389: Reword comment, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3baf5c1 296/389: subed-mpv--client-filter: Store process mark in variable, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 08d5033 301/389: Remove unused variable subed-mode--enabled-p, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 070384b 302/389: subed--set-subtitle-loop: Don't croak on empty file, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 89df304 304/389: subed-srt--sanitize: Don't insert newline in empty buffer, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b0a4ff0 307/389: Fix parentheses, ELPA Syncer, 2021/12/03