diff options
Diffstat (limited to 'init.org')
-rw-r--r-- | init.org | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -2187,32 +2187,31 @@ #+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 (fboundp 'w3m-view-source) - (w3m-view-source) - (eww-view-source)) + (if (fboundp 'w3m-view-source) (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 (fboundp 'w3m-view-mode) - (w3m-view-source) - (View-quit)) - (when url (cons url (or title ""))))))) + (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)))) + (if (fboundp 'w3m-view-mode) (w3m-view-source) (View-quit)) + (when url (cons url (or title "")))))))) (defun jao-rss-subscribe () (interactive) (let* ((url (or (jao-url-around-point) + (jao-rss--find-url) (read-string "Feed URL: "))) - (url+title (if url (cons url "") (jao-rss--find-url))) + (url+title (if (consp url) url (cons url (read-string "Feed name: ")))) (url (car url+title)) (title (cdr url+title))) (if url |