diff options
Diffstat (limited to 'emacs/.emacs.d/lisp/my/my-web.el')
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-web.el | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-web.el b/emacs/.emacs.d/lisp/my/my-web.el index 95592fd..f33f30c 100644 --- a/emacs/.emacs.d/lisp/my/my-web.el +++ b/emacs/.emacs.d/lisp/my/my-web.el @@ -180,6 +180,19 @@ e.g. https://news.ycombinator.com/item?id=42505454" (and (equal "news.ycombinator.com" (url-host urlobj)) (string-match-p "^/item\\?id=[0-9]+$" (url-filename urlobj))))) +(defvar my-newscorp-au-amp-nk nil) +(defun my-open-newscorp-au (url) + (interactive "sNews Corp AU link: ") + (pcase-let* ((urlobj (url-generic-parse-url url)) + (`(,path . _) (url-path-and-query urlobj))) + (setf (url-filename urlobj) + (format "%s?amp&nk=%s" path my-newscorp-au-amp-nk)) + (browse-url-firefox (url-recreate-url urlobj)))) + +(defun my-newscorp-au-url-p (url) + (string-match-p "^\\(www\\.\\)?\\(heraldsun\\|theaustralian\\)\\.com\\.au$" + (url-host (url-generic-parse-url url)))) + (defun my-stack-overflow-url-p (url) "Guess whether a url stack overflow question e.g. @@ -193,8 +206,8 @@ https://emacs.stackexchange.com/questions/40887/in-org-mode-how-do-i-link-to-int ;; (message "GOT %s" files) (dolist (var files) (let ((fname (expand-file-name (car var)))) - (when (string-match ".*/\\(https?:/\\)" fname) - (browse-url (replace-match "\\1/" nil nil fname)) + (when (string-match ".*/?\\(https?:\\)/+" fname) + (browse-url (replace-match "\\1//" nil nil fname)) (setq files (delq var files))))) (apply orig-fun files client args)) |