[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed beda7dc 371/389: Add functions to insert HTML-like t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed beda7dc 371/389: Add functions to insert HTML-like tags |
Date: |
Fri, 3 Dec 2021 11:01:00 -0500 (EST) |
branch: elpa/subed
commit beda7dc5e75333832e44b778335876a7e5d6d195
Author: Marcin Borkowski <mbork@mbork.pl>
Commit: Marcin Borkowski <mbork@mbork.pl>
Add functions to insert HTML-like tags
---
subed/subed-common.el | 37 +++++++++++++++++++++++++++++++++++++
subed/subed-config.el | 5 +++++
subed/subed.el | 2 ++
3 files changed, 44 insertions(+)
diff --git a/subed/subed-common.el b/subed/subed-common.el
index 0c80cf5..bc74217 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -1028,6 +1028,43 @@ Return nil if function `buffer-file-name' returns nil."
(when (file-exists-p file-stem-video)
(throw 'found-videofile file-stem-video))))))))
+;;; Inserting HTML-like tags
+
+(defvar subed--html-tag-history nil
+ "History of HTML-like tags in subtitles.")
+(defvar subed--html-attr-history nil
+ "History of HTML-like attributes in subtitles.")
+
+(defun subed-insert-html-tag (begin end tag &optional attributes)
+ "Insert a pair of HTML-like tags around the region.
+If region is not active, insert a pair of tags and put the point
+between them. If called with a prefix argument, also ask for
+attribute(s)."
+ (interactive (let* ((region-p (use-region-p))
+ (begin (if region-p (region-beginning) (point)))
+ (end (if region-p (region-end) (point)))
+ (tag (read-string "Tag: " nil 'subed--html-tag-history))
+ (attributes (when current-prefix-arg
+ (read-string "Attribute(s): " nil
'subed--html-attr-history))))
+ (list begin end tag attributes)))
+ (save-excursion
+ (push (point) buffer-undo-list)
+ (goto-char end)
+ (insert "</" tag ">")
+ (goto-char begin)
+ (insert-before-markers "<" tag)
+ (when attributes (insert-before-markers " " attributes))
+ (insert-before-markers ">")))
+
+(defun subed-insert-default-html-tag (begin end)
+ "Insert a pair of default tags at point or around the region.
+See `subed-insert-html-tag' and `subed-default-html-tag'."
+ (interactive (let* ((region-p (use-region-p))
+ (begin (if region-p (region-beginning) (point)))
+ (end (if region-p (region-end) (point))))
+ (list begin end)))
+ (subed-insert-html-tag begin end subed-default-html-tag))
+
;;; Characters per second computation
(defun subed-show-cps-p ()
diff --git a/subed/subed-config.el b/subed/subed-config.el
index f2f62d8..3416ee6 100644
--- a/subed/subed-config.el
+++ b/subed/subed-config.el
@@ -199,6 +199,11 @@ remembers whether it was originally enabled by the user.")
:type 'file
:group 'subed)
+(defcustom subed-default-html-tag "i"
+ "Default HTML-like tag."
+ :type 'string
+ :group 'subed)
+
(defcustom subed-mpv-arguments '("--osd-level=2" "--osd-fractions")
"Additional arguments for \"mpv\".
The options --input-ipc-server=SRTEDIT-MPV-SOCKET and --idle are
diff --git a/subed/subed.el b/subed/subed.el
index f95d5e0..f68b54b 100644
--- a/subed/subed.el
+++ b/subed/subed.el
@@ -71,6 +71,8 @@
(define-key subed-mode-map (kbd "C-c ]")
#'subed-copy-player-pos-to-stop-time)
(define-key subed-mode-map (kbd "C-c .")
#'subed-toggle-sync-point-to-player)
(define-key subed-mode-map (kbd "C-c ,")
#'subed-toggle-sync-player-to-point)
+ (define-key subed-mode-map (kbd "C-c C-t") #'subed-insert-html-tag)
+ (define-key subed-mode-map (kbd "C-c C-e") #'subed-insert-default-html-tag)
subed-mode-map))
;;;###autoload
- [nongnu] elpa/subed 7665826 248/389: Add tests for copying player position to start/stop time, (continued)
- [nongnu] elpa/subed 7665826 248/389: Add tests for copying player position to start/stop time, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed a280e89 251/389: Add more text to README, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 311f4af 331/389: Require Emacs 25.1, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed fc7a12d 335/389: Fix mpv arguments, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d9c41ba 345/389: Add test for validation fix, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 8bdec56 356/389: Move subed-split-subtitle to "Inserting" section, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b28f528 364/389: Revert indentation changes, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5b868c3 366/389: Fix minor issues in README.org added in last commit, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6949622 365/389: Adopt REUSE standard for copyright and licensing, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 9f55817 369/389: Wrap start/stop calculating functions in `ignore-errors', ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed beda7dc 371/389: Add functions to insert HTML-like tags,
ELPA Syncer <=
- [nongnu] elpa/subed c23dd84 373/389: Add info about the new features to README.org, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6a5802c 374/389: Add video movement per frame, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 828764f 375/389: Change keybindings and use a transient keymap, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5de6f21 377/389: Add msecs-to-timestamp as a common function, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b42f563 378/389: Add audio extensions, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6b1a6f2 367/389: Add computing and displaying characters per second, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3ba295b 336/389: Fix "service name too long", ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 961e5eb 343/389: More subed-vtt fixes: require subed-vtt, validate better, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 87b3823 353/389: subed-split-subtitle works at the beginning or end of subtitle text, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3b4b56a 384/389: Merge pull request #49 from sachac/fix-vtt-spaces, ELPA Syncer, 2021/12/03