summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--view-conf.el37
1 files changed, 22 insertions, 15 deletions
diff --git a/view-conf.el b/view-conf.el
index 69f52a5..5e6b5aa 100644
--- a/view-conf.el
+++ b/view-conf.el
@@ -236,21 +236,28 @@ options to choose from."
(defun durand-convert-youtube-video-to-url (video-name)
"Convert VIDEO-NAME to its original url."
(interactive (list (read-string "Video name: ")))
- (cond
- ((string-match "\\.[^.]+$" video-name)
- ;; with extension
- (kill-new
- (concat
- "https://www.youtube.com/watch?v="
- (substring-no-properties
- video-name
- (- (match-beginning 0) 11)
- (match-beginning 0)))))
- (t
- ;; no extension
- (kill-new
- (concat "https://www.youtube.com/watch?v="
- (substring-no-properties video-name -11))))))
+ (save-match-data
+ (cond
+ ((string-match (rx "[" (group (1+ (not "]"))) "].")
+ video-name)
+ (kill-new
+ (concat
+ "https://www.youtube.com/watch?v="
+ (match-string 1 video-name))))
+ ((string-match "\\.[^.]+$" video-name)
+ ;; with extension
+ (kill-new
+ (concat
+ "https://www.youtube.com/watch?v="
+ (substring-no-properties
+ video-name
+ (- (match-beginning 0) 11)
+ (match-beginning 0)))))
+ (t
+ ;; no extension
+ (kill-new
+ (concat "https://www.youtube.com/watch?v="
+ (substring-no-properties video-name -11)))))))
;;; moving by paragraphs