summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2023-10-16 10:50:55 -0400
committerSacha Chua <sacha@sachachua.com>2023-10-16 10:50:55 -0400
commit227fe1a45398ebf3f0663bf8c73cd4d7e431b38a (patch)
tree2a1bb7e66b213c3a2c674341985a19d646b34cab
parent8ee0e58cf9703e56d3ceca605796f5e2f16419fa (diff)
downloademacsconf-el-227fe1a45398ebf3f0663bf8c73cd4d7e431b38a.tar.xz
emacsconf-el-227fe1a45398ebf3f0663bf8c73cd4d7e431b38a.zip
emacsconf-subed: add splitting
-rw-r--r--emacsconf-subed.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/emacsconf-subed.el b/emacsconf-subed.el
index f82e557..6369cdd 100644
--- a/emacsconf-subed.el
+++ b/emacsconf-subed.el
@@ -293,5 +293,34 @@ Create it if necessary."
(error "Duration %d is less than minimum" (- (subed-subtitle-msecs-stop) (subed-subtitle-msecs-start))))
(or (subed-forward-subtitle-text) (goto-char (point-max)))))
+(defun emacsconf-subed-split-at-mouse (event)
+ "Split at the word clicked on."
+ (interactive "e")
+ (goto-char (posn-point (event-start event)))
+ (skip-syntax-backward "w")
+ (subed-split-subtitle))
+
+(defun emacsconf-subed-merge-and-fill ()
+ "Merge this subtitle with the next one."
+ (interactive)
+ (subed-merge-with-next)
+ (fill-paragraph))
+
+(defun emacsconf-subed-split ()
+ "Transient map for splitting subtitles."
+ (interactive)
+ (set-transient-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [down-mouse-1] #'emacsconf-subed-split-at-mouse)
+ (define-key map [mouse-1] #'ignore)
+ (define-key map [up-1] #'ignore)
+ (define-key map [drag-mouse-1] #'ignore)
+ (define-key map [mouse-movement] #'ignore)
+ (define-key map "q" #'fill-paragraph)
+ (define-key map "." #'emacsconf-subed-merge-and-fill)
+ (define-key map (kbd "SPC") #'scroll-up)
+ map)
+ t))
+
(provide 'emacsconf-subed)
;;; emacsconf-subed.el ends here