diff options
Diffstat (limited to 'custom/jao-custom-browse.el')
-rw-r--r-- | custom/jao-custom-browse.el | 64 |
1 files changed, 3 insertions, 61 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 |