Xah Talk Show 2024-01-23 Ep533 Emacs Lisp Normalize YouTube Url, Open All File Paths, How to Choose a Mouse

vidthumb vXkXnpAOW-c

write a command to normalize YouTube url

(defun xah-html-youtube-normalize-url ()
  "Normalize YouTube URL.
Examples of youtube URL:
 https://www.youtube.com/watch?v=6_4mlsSxpuQ
 https://www.youtube.com/embed/scR9f6S_8_4
 https://youtu.be/hZboLF14Oeo
 https://www.youtube.com/live/6_4mlsSxpuQ?si=3qoSrXfbAicn8PFx

Version: 2024-01-23"
  (interactive)
  (let (xp1 xp2 xurl xvidID)
    ;; grab the current url under cursor
    ;; find the youtube id, 11 char sequence
    ;; delete current region
    ;; insert the normalized url string
    (let ((xboundaries (bounds-of-thing-at-point 'url)))
      (setq xp1 (car xboundaries)
            xp2 (cdr xboundaries)
            xurl (buffer-substring-no-properties xp1 xp2)))

    (setq xvidID (xah-html--get-youtube-id xurl))
    (delete-region xp1 xp2)
    (insert (format "https://www.youtube.com/watch?v=%s" xvidID))
    ;;
    ))

emacs lisp, open all file paths

emacs lisp, given a list of file paths under cursor, open them all

c:/Users/xah/web/xahlee_info/logo_design/perl_logo.html
c:/Users/xah/web/xahlee_info/comp/computer_languages_comparison_perl_python_ruby_javascript_php_lisp.html
c:/Users/xah/web/xahlee_info/comp/blog_past_2011-07.html
c:/Users/xah/web/xahlee_info/UnixResource_dir/writ/wall_stallman.html
c:/Users/xah/web/xahlee_info/UnixResource_dir/perlr.html
(defun xah-open-all-file-paths ()
  "Open all file paths under cursor, of current text block.
Created: 2024-01-23
Version: 2024-03-23"
  (interactive)
  (let (xbeg xend xtext xpaths)
    (seq-setq (xbeg xend) (if (region-active-p) (list (region-beginning) (region-end)) (list (save-excursion (if (re-search-backward "\n[ \t]*\n" nil 1) (match-end 0) (point))) (save-excursion (if (re-search-forward "\n[ \t]*\n" nil 1) (match-beginning 0) (point))))))
    (setq xtext (buffer-substring-no-properties xbeg xend)
          xpaths (split-string xtext "\n"))
    (mapc 'find-file xpaths)))