From ee77fcd68760dd826c174e3e22e93d6f1a6247c0 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 21 Feb 2023 16:28:54 +0800 Subject: view: repeat, lower-case open target, and conversion. * view-conf.el (durand-view-timers-or-temps): Make it repeating. (durand-open-targets): Use lower-case names so that the completion works better. (durand-convert-youtube-video-to-url): Return the converted YouTube address. --- view-conf.el | 60 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 25 deletions(-) (limited to 'view-conf.el') diff --git a/view-conf.el b/view-conf.el index 215644b..9837079 100644 --- a/view-conf.el +++ b/view-conf.el @@ -78,6 +78,11 @@ If ARG is '(16), view the battery information." (t (user-error "Unsupported ARG: %S" arg)))) +(put 'durand-view-timers-or-temps 'repeat-map + (let ((map (make-sparse-keymap))) + (define-key map (vector ?t) 'repeat) + map)) + (define-obsolete-function-alias 'durand-view-timers 'durand-view-timers-or-temps "2020-09-02" "View the list of timers.") @@ -146,7 +151,7 @@ See the documentation for `durand-open-object' for the formats of targets.") (setq durand-open-targets - (list (list "Safari" "open" "-a" "Safari" + (list (list "safari" "open" "-a" "Safari" (list "https://www.youtube.com" "https://www.gmail.com" "https://www.facebook.com" @@ -155,11 +160,11 @@ targets.") "https://dictionary.christian-steinert.de/#home" ;; "https://wmail1.cc.ntu.edu.tw/index.php?url=https%3A%2F%2Fwmail1.cc.ntu.edu.tw%2F" )) - (list "Terminal" "open" "-a" "Terminal" (list + (list "terminal" "open" "-a" "Terminal" (list "/Users/durand/Desktop/Centre/Vidéos/" "/Users/durand/Desktop/Centre/Musique/" "/Users/durand/Downloads/")) - (list "Messenger" "open" "-a" "Messenger") + (list "messenger" "open" "-a" "Messenger") (list "temp d'écran" "open" "-b" "com.apple.systempreferences" "/System/Library/PreferencePanes/ScreenTime.prefPane"))) @@ -242,28 +247,33 @@ 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: "))) - (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))))))) + (let (result) + (save-match-data + (cond + ((string-match (rx "[" (group (1+ (not "]"))) "].") + video-name) + (setq result (concat + "https://www.youtube.com/watch?v=" + (match-string 1 video-name))) + (kill-new result)) + ((string-match "\\.[^.]+$" video-name) + ;; with extension + (setq + result + (concat + "https://www.youtube.com/watch?v=" + (substring-no-properties + video-name + (- (match-beginning 0) 11) + (match-beginning 0)))) + (kill-new result)) + (t + ;; no extension + (setq result + (concat "https://www.youtube.com/watch?v=" + (substring-no-properties video-name -11))) + (kill-new result))) + result))) ;;; moving by paragraphs -- cgit v1.2.3-18-g5258