summaryrefslogtreecommitdiffhomepage
path: root/init.org
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-04-08 17:16:43 +0100
committerjao <jao@gnu.org>2021-04-08 17:16:43 +0100
commit3512562be70369611bd6e3ac796d17297a6c38a7 (patch)
tree0a6de1d239ab2b4d164506dc52a4e4fcf6fbcc83 /init.org
parent7250b0f436ce31f2cf75dbaf9f00972dc4ad0b4b (diff)
downloadelibs-3512562be70369611bd6e3ac796d17297a6c38a7.tar.gz
elibs-3512562be70369611bd6e3ac796d17297a6c38a7.tar.bz2
better detection of rss feeds
Diffstat (limited to 'init.org')
-rw-r--r--init.org29
1 files changed, 14 insertions, 15 deletions
diff --git a/init.org b/init.org
index 0056220..ebe6580 100644
--- a/init.org
+++ b/init.org
@@ -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