diff options
Diffstat (limited to 'init.org')
-rw-r--r-- | init.org | 60 |
1 files changed, 55 insertions, 5 deletions
@@ -2055,11 +2055,14 @@ #+end_src *** Helpers #+BEGIN_SRC emacs-lisp - (defun jao-url-around-point () - (or (and (fboundp 'w3m-anchor) (w3m-anchor)) - (shr-url-at-point nil) - (ffap-url-at-point) - (thing-at-point 'url))) + (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--fln (url) (shell-quote-argument @@ -2218,6 +2221,50 @@ (setq browse-url-browser-function jao-browse-url-function) #+END_SRC +*** Subscribe rss using r2e + #+begin_src emacs-lisp + (defconst jao-rss--rss-rx + (concat "type=\"application/\\(?:atom\\|rss\\)\\+xml\" +" + "\\(?:title=\"\\([^\n\"]+\\)\" +\\)?href=\"\\([^\n\"]+\\)\"")) + + (autoload 'View-quit "view") + + (defun jao-rss--find-url () + (when (derived-mode-p 'w3m-mode 'eww-mode) + (save-excursion + (if (derived-mode-p 'w3m-mode) + (w3m-view-source) + (eww-view-source)) + (goto-char (point-min)) + (let* ((m (re-search-forward jao-rss--rss-rx nil t)) + (url (and m (match-string 2))) + (title (and m (match-string 1)))) + (if (derived-mode-p 'w3m-mode) + (w3m-view-source) + (View-quit)) + (when url (cons url (or title ""))))))) + + (defun jao-rss-subscribe () + (interactive) + (let* ((url (or (jao-rss--find-url) + (jao-url-around-point) + (read-string "Feed URL: "))) + (url+title (if url (cons url "") (jao-rss--find-url))) + (url (car url+title)) + (title (cdr url+title))) + (if url + (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 "Name: " title)) + (cat (completing-read "Category: " + (jao-list-mailboxes "feeds") + nil t))) + (shell-command + (format "r2e add %s %s jao+feeds_%s@localhost && r2e run %s" + name url cat name))))) + (message "No feeds found")))) + #+end_src *** emacs-w3m #+begin_src emacs-lisp (jao-load-org "w3m") @@ -2228,6 +2275,9 @@ :custom ((jao-eww-session-duplicate-tabs 'ask) (jao-eww-session-file "~/.emacs.d/eww-session.el"))) + (require 'eww) + (define-key eww-mode-map "x" #'jao-rss-subscribe) + (defun jao-eww-browse-url (url &rest r) "Browse URL using eww." (jao-afio--goto-www) |