Last active
January 10, 2019 18:49
-
-
Save harizvi/97ee5564047206d6014301c3911d8fbb to your computer and use it in GitHub Desktop.
Gnus setup for opening urls from nntp headers added by various RSS feeds / mailing lists.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; user Return key to pull up the page in browser | |
(defun browse-nnrss-url( arg ) | |
(interactive "p") | |
(let ((url (assq nnrss-url-field | |
(mail-header-extra | |
(gnus-data-header | |
(assq (gnus-summary-article-number) | |
gnus-newsgroup-data)))))) | |
(if url | |
(progn | |
(if (string-match "\\.sfdc\\.net" (cdr url)) | |
(my-browse-url-in-chrome-bg (cdr url)) | |
(my-browse-url-in-bg (cdr url))) | |
(gnus-summary-mark-as-read-forward 1)) | |
(gnus-summary-scroll-up arg)))) | |
;; (defun browse-nnrss-url( arg ) | |
;; (interactive "p") | |
;; (let ((url (assq nnrss-url-field | |
;; (mail-header-extra | |
;; (gnus-data-header | |
;; (assq (gnus-summary-article-number) | |
;; gnus-newsgroup-data)))))) | |
;; (if url | |
;; (progn | |
;; (my-browse-url-in-bg (cdr url)) | |
;; (gnus-summary-mark-as-read-forward 1)) | |
;; (gnus-summary-scroll-up arg)))) | |
(add-to-list 'nnmail-extra-headers nnrss-url-field) | |
(defun hr/gnus-browse-archived-at () | |
"Browse \"Archived-at\" URL of the current article." | |
(interactive) | |
(let (url) | |
(with-current-buffer gnus-original-article-buffer | |
(setq url (gnus-fetch-field "Archived-at"))) | |
(if (not (stringp url)) | |
(gnus-message 1 "No \"Archived-at\" header found.") | |
(setq url (gnus-replace-in-string url "^<\\|>$" "")) | |
(my-browse-url-in-bg url)))) | |
(defun hr/gnus-browse-messageid-ibmconnections () | |
"Build a IBM Connections url from \"Message-id\" of the current article." | |
(interactive) | |
(let (url message-id) | |
(with-current-buffer gnus-original-article-buffer | |
(setq message-id (gnus-fetch-field "Message-ID"))) | |
(if (not (stringp message-id)) | |
(gnus-message 1 "No \"Message-ID\" header found.") | |
(setq message-id (gnus-replace-in-string message-id "^<\\|@forums\.ibm\.com>$" "")) | |
(setq url (concat "https://w3-connections.ibm.com/forums/html/topic?id=" message-id)) | |
(browse-url url)))) | |
;; if X-SA-messageid is CN_2800, url is article, url is http://seekingalpha.com/article/X_SA_workid | |
;; else if X_SA_messageid is CN_2900, url is http://seekingalpha.com/currents/post/X_SA_workid | |
(defun hr/gnus-browse-said-seekingalpha () | |
"Build a url from \"X-SA-workid\" of the current article." | |
(interactive) | |
(let (url message-id work-id) | |
(with-current-buffer gnus-original-article-buffer | |
(setq work-id (gnus-fetch-field "X-SA-workid")) | |
(setq message-id (gnus-fetch-field "X-SA-messageid"))) | |
(if (not (stringp work-id)) | |
(gnus-message 1 "No \"X-SA-workid\" header found.") | |
(cond ((string-match "2800\\|N_2800" message-id) | |
(setq url (concat "http://seekingalpha.com/article/" work-id))) | |
((string-match "2900\\|N_2900\\|FN_2900" message-id) | |
(setq url (concat "http://seekingalpha.com/currents/post/" work-id)))) | |
(my-browse-url-in-bg url)))) | |
(defun hr/gnus-browse-phpbb () | |
"Build a url from a phpbb article." | |
(interactive) | |
(let (url message-id work-id) | |
(with-current-buffer gnus-original-article-buffer | |
(gnus-summary-show-article '(4)) | |
(switch-to-buffer gnus-original-article-buffer) | |
(goto-char (point-min)) | |
; (re-search-forward "^If you want to view the newest post made .+$") | |
(re-search-forward "^\\(https:.+\\)$") | |
(my-browse-url-in-bg (match-string 1)) | |
(gnus-summary-show-article)))) | |
(defun my-gnus-browse-gwene () | |
"Start a browser for current gwene article" | |
(interactive) | |
(dolist (buf (buffer-list)) | |
(with-current-buffer buf | |
(when (eq major-mode 'gnus-article-mode) | |
(gnus-summary-show-article '(4)) | |
(switch-to-buffer buf) | |
(goto-char (point-min)) | |
(re-search-forward "^Archived-at: <\\(.*\\)>$") | |
(my-browse-url-in-bg (match-string 1)) | |
(gnus-summary-show-article))))) | |
(defun my-gnus-browse (arg) | |
(interactive "p") | |
(cond ((string-match "\\(gwene\\|gmane\\)\\." gnus-newsgroup-name) | |
(hr/gnus-browse-archived-at)) | |
((string-match "^nnreddit:" gnus-newsgroup-name) | |
(hr/gnus-browse-archived-at)) | |
((string-match "^nnrss\." gnus-newsgroup-name) | |
(browse-nnrss-url arg)) | |
((string-match "^w3Forums\\|CommunitiesCategory\\|MyForums" gnus-newsgroup-name) | |
(hr/gnus-browse-messageid-ibmconnections)) | |
((string-match "seekingalpha" (mail-header-from gnus-current-headers)) | |
(hr/gnus-browse-said-seekingalpha)) | |
((string-match "diehards" (mail-header-from gnus-current-headers)) | |
(hr/gnus-browse-phpbb)) | |
)) | |
(defun my-gnus-browse-with-default-browser (arg) | |
(interactive "p") | |
(let ((browse-url-browser-function 'browse-url-default-macosx-browser)) | |
(my-gnus-browse arg)) | |
) | |
(defun my-gnus-summary-setup () | |
"Setup keymap in gnus-summary-mode" | |
(interactive) | |
(gnus-define-keys gnus-summary-mode-map | |
"f" gnus-summary-followup-with-original | |
"r" gnus-summary-reply-with-original | |
"v" my-gnus-article-fill-cited-article | |
"w" gnus-article-fill-cited-article | |
"z" gnus-article-hide-citation | |
; "d" gnus-move-to-trash | |
"H" gnus-article-wash-html | |
";" my-gnus-browse | |
":" my-gnus-browse-with-default-browser | |
) | |
(setq fill-column 75) | |
) | |
(add-hook 'gnus-summary-mode-hook 'my-gnus-summary-setup) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment