diff options
author | Yuchen Pei <id@ypei.org> | 2024-12-26 22:44:51 +1100 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2024-12-26 22:44:51 +1100 |
commit | f6b8f3d09dd1228858d4c07973f4330d671abe2a (patch) | |
tree | f596dc05b69feeafaa3a79dde0c9eb4ff1dbd16a /emacs/.emacs.d/lisp/my/my-web.el | |
parent | e79129bb75b2a63f82a99678d777872f124156df (diff) |
[emacs] web related changes in emacs
open newscorp au
update exitter submodule
use reddio for reddit
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)) |