diff options
Diffstat (limited to 'custom/jao-custom-gnus.el')
-rw-r--r-- | custom/jao-custom-gnus.el | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el index 70823ef..a7059c6 100644 --- a/custom/jao-custom-gnus.el +++ b/custom/jao-custom-gnus.el @@ -447,13 +447,19 @@ (use-package org-capture :config (add-to-list 'org-capture-templates + '("x" "arXiv" entry (file "notes/physics/arxiv.org") + "* %(jao-gnus-subject)\n\n %i\n %(jao-gnus-org-url)" + :immediate-finish t) + t) + (add-to-list 'org-capture-templates '("X" "arXiv" entry (file "notes/physics/arxiv.org") - "* %:subject\n\n(jao-gnus-org-paragraph \"%i\")" + "* %(jao-gnus-subject)\n\n%(jao-gnus-org-paragraph \"%i\")" :immediate-finish t) t) (org-capture-upgrade-templates org-capture-templates)) (defvar jao-gnus-org-url nil) +(defun jao-gnus-org-url () jao-gnus-org-url) (defun jao-gnus-org-paragraph (x) (with-temp-buffer (insert " " (string-trim (or x "")) "\n ") @@ -462,22 +468,27 @@ (goto-char (point-max)) (open-rectangle 0 (point)) (concat (buffer-string) "\n " (or jao-gnus-org-url "")))) +(defvar jao-gnus-subject nil) +(defun jao-gnus-subject () jao-gnus-subject) (defun jao-gnus-arXiv-capture () (interactive) (unless (derived-mode-p '(gnus-summary-mode)) (gnus-article-show-summary)) - (setq jao-subject (gnus-summary-article-subject)) + (setq jao-gnus-subject (gnus-summary-article-subject)) (gnus-summary-select-article-buffer) (gnus-article-goto-part 0) (setq-local transient-mark-mode 'lambda) (set-mark (point)) (forward-paragraph) - (save-excursion - (when (re-search-forward "^Link" nil t) - (beginning-of-line) - (setq jao-gnus-org-url (org-eww-url-below-point)))) - (org-capture nil "X") - (set-mark (point)) + (or (and (save-excursion + (when (re-search-forward "^Link" nil t) + (beginning-of-line) + (setq jao-gnus-org-url (org-eww-url-below-point)))) + (org-capture nil "X")) + (and (save-excursion + (when (re-search-forward "^URL: " nil t) + (setq jao-gnus-org-url (thing-at-point-url-at-point)))) + (org-capture nil "x"))) (gnus-article-show-summary)) ;;; article @@ -558,7 +569,7 @@ (save-excursion (goto-char (point-min)) (when (or (search-forward-regexp "^Via: h" nil t) - (search-forward-regexp "^URL: h" nil t) + (search-forward-regexp "^URL:[\n ]h" nil t) (and (search-forward-regexp "^Link$" nil t) (not (beginning-of-line)))) (cond (external (jao-browse-with-external-browser)) @@ -689,6 +700,7 @@ (jao-gnus--notify))) (add-hook 'gnus-summary-exit-hook #'jao-gnus--on-summary-exit) +(add-hook 'gnus-exit-group-hook #'jao-gnus--notify) ;;;; open mail file in gnus (defun jao-gnus-file-to-group (file &optional maildir newsdir m-server n-server) |