diff options
author | jao <jao@gnu.org> | 2025-09-20 19:03:07 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2025-09-20 19:03:07 +0100 |
commit | abda6921e5a013051fc9fcd5de8d682be1a4d44d (patch) | |
tree | 4779d6a07912e62fb89a9d6a5a97d61786c22d8d /custom | |
parent | 889b21138993a67a286f380bbc6d4ca56e475b42 (diff) | |
download | elibs-abda6921e5a013051fc9fcd5de8d682be1a4d44d.tar.gz elibs-abda6921e5a013051fc9fcd5de8d682be1a4d44d.tar.bz2 |
jao-r2e: new package to handle rss2email subscriptions
Diffstat (limited to 'custom')
-rw-r--r-- | custom/jao-custom-browse.el | 64 | ||||
-rw-r--r-- | custom/jao-custom-completion.el | 4 | ||||
-rw-r--r-- | custom/jao-custom-eww.el | 4 | ||||
-rw-r--r-- | custom/jao-custom-notmuch.el | 5 | ||||
-rw-r--r-- | custom/jao-custom-w3m.el | 2 |
5 files changed, 10 insertions, 69 deletions
diff --git a/custom/jao-custom-browse.el b/custom/jao-custom-browse.el index 5c75f7f..ec5a000 100644 --- a/custom/jao-custom-browse.el +++ b/custom/jao-custom-browse.el @@ -1,5 +1,8 @@ ;; -*- lexical-binding: t -*- +;;; Deps +(require 'jao-url) + ;;; Browsing ;;;; variables (defvar jao-browse-doc-use-emacs-p (jao-is-linux)) @@ -7,14 +10,6 @@ (defvar jao-browse-url-external-function nil) ;;;; url around point -(defun jao-url-around-point (&optional current-url) - (or (and (fboundp 'w3m-anchor) (w3m-anchor)) - (shr-url-at-point nil) - (ffap-url-at-point) - (thing-at-point 'url) - (when current-url - (or (and (fboundp 'w3m-anchor) (w3m-anchor)) - (and (derived-mode-p 'eww-mode) (plist-get eww-data :url)))))) (defun jao--url-prompt (&optional prefix) (let* ((def (jao-url-around-point t)) @@ -191,59 +186,6 @@ (,(jao-wget--regexp) . jao-download) ("." . jao-browse-url-browse)))) -;;;; subscribe to rss using r2e -(autoload 'View-quit "view") - -(defun jao-rss--find-url () - (save-excursion - (when (derived-mode-p 'w3m-mode 'eww-mode) - (if (fboundp 'w3m-view-source) (w3m-view-source) (eww-view-source))) - (goto-char (point-min)) - (when (re-search-forward - "type=\"application/\\(?:atom\\|rss\\)\\+xml\" +" nil t) - (let ((url (save-excursion - (when (re-search-forward - "href=\"\\([^\n\"]+\\)\"" nil t) - (match-string-no-properties 1)))) - (title (when (re-search-forward - "\\(?:title=\"\\([^\n\"]+\\)\" +\\)" nil t) - (match-string-no-properties 1)))) - (cond ((derived-mode-p 'w3m-view-mode) (w3m-view-source)) - ((string-match-p ".*\\*eww-source\\b.*" (buffer-name)) - (View-quit))) - (when url (cons url (or title ""))))))) - -(defun jao-rss2e-append (name url mbox) - (with-current-buffer (find-file-noselect "~/.config/rss2email.cfg") - (goto-char (point-max)) - (insert "[feed." name "]\nurl = " url) - (insert "\nto = " mbox "+" name "@localhost") - (insert "\nmaildir-mailbox = " mbox "\n\n") - (save-buffer))) - -(defun jao-rss--feeds-dirs () - (mapcar (lambda (d) (cadr (split-string d "\\."))) - (directory-files "~/.emacs.d/gnus/Mail/" nil "^feeds"))) - -(defun jao-rss-subscribe (url) - "Subscribe to a given RSS URL. If URL not given, look for it." - (interactive (list (or (jao-url-around-point) - (jao-rss--find-url) - (read-string "Feed URL: ")))) - (let* ((url+title (ensure-list url)) - (url (car url+title)) - (title (cdr url+title))) - (unless url (error "No feeds found")) - (let ((url (if (string-match "^feed:" url) (substring url 5) url))) - (when (y-or-n-p (format "Subscribe to <%s>? " url)) - (let* ((name (read-string "Feed name: " title)) - (cats (cons "prog" (jao-notmuch--subtags "feeds"))) - (cat (completing-read "Category: " cats nil t)) - (subs (format "r2e add %s '%s' feeds.%s@localhost" - name url cat))) - ;; (jao-rss2e-append name url cat) - (shell-command-to-string subs) - (shell-command (format "r2e run %s" name))))))) (provide 'jao-custom-browse) ;;; jao-custom-browse.el ends here diff --git a/custom/jao-custom-completion.el b/custom/jao-custom-completion.el index 436a4db..98b853c 100644 --- a/custom/jao-custom-completion.el +++ b/custom/jao-custom-completion.el @@ -1,5 +1,7 @@ ;; -*- lexical-binding: t; -*- +(require 'jao-r2e) + ;;; builtin completion (setq tab-always-indent 'complete read-extended-command-predicate #'command-completion-default-include-p @@ -308,7 +310,7 @@ (define-key embark-url-map (kbd "RET") #'jao-embark-url) (define-key embark-url-map (kbd "f") #'browse-url-firefox) -(define-key embark-url-map (kbd "x") #'jao-rss-subscribe) +(define-key embark-url-map (kbd "x") #'jao-r2e-subscribe) (define-key embark-url-map (kbd "m") 'jao-browse-with-external-browser) (define-key embark-url-map (kbd "p") 'jao-mpc-add-or-play-url) diff --git a/custom/jao-custom-eww.el b/custom/jao-custom-eww.el index eb25013..beeb97e 100644 --- a/custom/jao-custom-eww.el +++ b/custom/jao-custom-eww.el @@ -1,5 +1,7 @@ ;; -*- lexical-binding: t -*- +(require 'jao-r2e) + ;;; integration with browse-url and afio (defun jao-eww-browse-url (url &rest _r) "Browse URL using eww." @@ -216,7 +218,7 @@ ("U" . jao-eww-reopen-new) ("w" . jao-eww-to-org) ("q" . jao-eww-close) - ("x" . jao-rss-subscribe) + ("x" . jao-r2e-subscribe) ("y" . jao-eww-copy-link) ("\\" . eww-view-source) ("C-c C-w" . jao-eww-close) diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el index 85150fa..a0dba56 100644 --- a/custom/jao-custom-notmuch.el +++ b/custom/jao-custom-notmuch.el @@ -185,11 +185,6 @@ '("new" "unread" "flagged" "signed" "sent" "attachment" "forwarded" "inbox" "encrypted" "gmane" "gnus" "feeds" "rss" "mce" "trove" "prog" "emacs")) -(defun jao-notmuch--subtags (tag &rest excl) - (let* ((cmd (concat "notmuch search --output=tags tag:" tag)) - (ts (split-string (shell-command-to-string cmd)))) - (seq-difference ts (append jao-notmuch--shared-tags (cons tag excl))))) - (setq notmuch-archive-tags '("+trove" "-new" "-drivel" "-words" "-inbox") notmuch-show-mark-read-tags '("-new" "-unread") notmuch-tag-formats diff --git a/custom/jao-custom-w3m.el b/custom/jao-custom-w3m.el index 43b9e2d..f532e8b 100644 --- a/custom/jao-custom-w3m.el +++ b/custom/jao-custom-w3m.el @@ -198,7 +198,7 @@ ("v" . jao-view-video) ("q" . w3m-delete-buffer) ("w" . org-w3m-copy-for-org-mode) - ("x" . jao-rss-subscribe) + ("x" . jao-r2e-subscribe) ("y" . w3m-print-current-url)))) ;;; textsec |