diff options
| author | Sacha Chua <sacha@sachachua.com> | 2025-12-20 18:28:13 -0500 |
|---|---|---|
| committer | Sacha Chua <sacha@sachachua.com> | 2025-12-20 18:29:05 -0500 |
| commit | b9f9e355dd4ff8ae06170a346de0b7a07cabdd42 (patch) | |
| tree | 54e01a211426bf86f41a411920567e1f187d043a /emacsconf-subed.el | |
| parent | 146a316a706dbab81ef594372e9fd45e09be2c54 (diff) | |
| download | emacsconf-el-b9f9e355dd4ff8ae06170a346de0b7a07cabdd42.tar.xz emacsconf-el-b9f9e355dd4ff8ae06170a346de0b7a07cabdd42.zip | |
New command emacsconf-subed-copy-current-chapter-text
* emacsconf-subed.el (emacsconf-subed-copy-current-chapter-text):
New command.
Diffstat (limited to '')
| -rw-r--r-- | emacsconf-subed.el | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/emacsconf-subed.el b/emacsconf-subed.el index 82a07ad..43f28f4 100644 --- a/emacsconf-subed.el +++ b/emacsconf-subed.el @@ -169,7 +169,32 @@ TYPE can be 'end if you want the match end instead of the beginning." subtitles) (nreverse (cons current result)))) -(defun emacsconf-subed-mark-chapter (chapter-name) +(defun emacsconf-subed-copy-current-chapter-text (&optional only-from-point) + "Copy text between NOTE and NOTE chapter comments." + (interactive (list current-prefix-arg)) + (let* ((start (cond + (only-from-point (save-excursion (subed-jump-to-subtitle-start-pos))) + ((save-excursion (re-search-backward "^NOTE[ \n]" nil t)) + (match-beginning 0)) + (t + (point-min)))) + (end (cond + ((looking-at "^NOTE[ \n]") (match-beginning 0)) + ((save-excursion (re-search-forward "^NOTE[ \n]" nil t)) + (match-beginning 0)) + (t + (point-max)))) + (s (string-trim + (replace-regexp-in-string + "\n" " " + (subed-subtitle-list-text (subed-subtitle-list start end)))))) + (message "%s" s) + (kill-new s) + s)) + +(defun emacsconf-subed-set-chapter (chapter-name) + "I think this adds a chapter heading for the region. +Use `subed-set-subtitle-comment' and `emacsconf-subed-make-chapter-file-based-on-comments' or `subed-section-comments-as-chapters' instead." (interactive "MChapter: ") (let ((start (subed-subtitle-msecs-start))) (save-excursion |
