Add excerpt to articles
* avandu.el (avandu-overview-excerpt): New face. (avandu--insert-feed-title): Replace `newline' with `insert-char' to prevent newlines from continuing indentation. (avandu--insert-article-title): Replace `newline' with `insert-char'. (avandu--insert-article-excerpt): New function. (avandu-list): Ask tt-rss to send along an excerpt of each article and print this excerpt after the article's title.
This commit is contained in:
parent
a0882bf8da
commit
529c17e7c1
1 changed files with 28 additions and 6 deletions
34
avandu.el
34
avandu.el
|
@ -62,6 +62,11 @@
|
||||||
"Face for read article titles in avandu overview."
|
"Face for read article titles in avandu overview."
|
||||||
:group 'avandu)
|
:group 'avandu)
|
||||||
|
|
||||||
|
(defface avandu-overview-excerpt
|
||||||
|
'((t (:inherit shadow :slant italic)))
|
||||||
|
"Face for article excerpts in avandu overview."
|
||||||
|
:group 'avandu)
|
||||||
|
|
||||||
(defvar avandu--session-id nil
|
(defvar avandu--session-id nil
|
||||||
"*internal* Session id for avandu.")
|
"*internal* Session id for avandu.")
|
||||||
|
|
||||||
|
@ -274,7 +279,7 @@ feeds."
|
||||||
(defun avandu--insert-feed-title (id title)
|
(defun avandu--insert-feed-title (id title)
|
||||||
"Insert a button with the label TITLE and store ID in the
|
"Insert a button with the label TITLE and store ID in the
|
||||||
feed-id property."
|
feed-id property."
|
||||||
(unless (eq (point) (point-min)) (newline))
|
(unless (eq (point) (point-min)) (insert-char ?\n 1))
|
||||||
(insert-button
|
(insert-button
|
||||||
(replace-regexp-in-string "^[ \n\t]*\\|[ \n\t]*$" "" title)
|
(replace-regexp-in-string "^[ \n\t]*\\|[ \n\t]*$" "" title)
|
||||||
'face 'avandu-overview-feed
|
'face 'avandu-overview-feed
|
||||||
|
@ -282,8 +287,7 @@ feed-id property."
|
||||||
'keymap avandu-feed-button-map
|
'keymap avandu-feed-button-map
|
||||||
'action #'(lambda (button)
|
'action #'(lambda (button)
|
||||||
(message "%s" (button-label button))))
|
(message "%s" (button-label button))))
|
||||||
(newline)
|
(insert-char ?\n 2))
|
||||||
(newline))
|
|
||||||
|
|
||||||
(defun avandu-browse-article ()
|
(defun avandu-browse-article ()
|
||||||
"Browse the current button's article url."
|
"Browse the current button's article url."
|
||||||
|
@ -303,7 +307,22 @@ the article-id and link properties, respectively."
|
||||||
'keymap avandu-article-button-map
|
'keymap avandu-article-button-map
|
||||||
'action #'(lambda (button)
|
'action #'(lambda (button)
|
||||||
(message "%s" (button-get button 'link))))
|
(message "%s" (button-get button 'link))))
|
||||||
(newline))
|
(insert-char ?\n 1))
|
||||||
|
|
||||||
|
(defun avandu--insert-article-excerpt (excerpt)
|
||||||
|
"Insert the excerpt of an article."
|
||||||
|
(let ((start-pos (point))
|
||||||
|
end-pos)
|
||||||
|
(insert
|
||||||
|
(propertize
|
||||||
|
(replace-regexp-in-string
|
||||||
|
"…" "..."
|
||||||
|
(replace-regexp-in-string "\\`[ \t\n]*\\|[ \t\n]*$" ""
|
||||||
|
excerpt))
|
||||||
|
'face 'avandu-overview-excerpt))
|
||||||
|
(indent-region start-pos (point) tab-width)
|
||||||
|
(fill-region start-pos (point)))
|
||||||
|
(insert-char ?\n 1))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun avandu-list ()
|
(defun avandu-list ()
|
||||||
|
@ -314,7 +333,8 @@ by feed."
|
||||||
(let ((buffer (get-buffer-create "*avandu-overview*"))
|
(let ((buffer (get-buffer-create "*avandu-overview*"))
|
||||||
(result (avandu-send-command '((op . "getHeadlines")
|
(result (avandu-send-command '((op . "getHeadlines")
|
||||||
(feed_id . -4)
|
(feed_id . -4)
|
||||||
(view_mode . "unread"))))
|
(view_mode . "unread")
|
||||||
|
(show_excerpt . t))))
|
||||||
feed-id)
|
feed-id)
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(setq buffer-read-only nil)
|
(setq buffer-read-only nil)
|
||||||
|
@ -329,7 +349,9 @@ by feed."
|
||||||
(avandu--insert-article-title
|
(avandu--insert-article-title
|
||||||
(cdr (assq 'id elt))
|
(cdr (assq 'id elt))
|
||||||
(cdr (assq 'link elt))
|
(cdr (assq 'link elt))
|
||||||
(cdr (assq 'title elt))))
|
(cdr (assq 'title elt)))
|
||||||
|
(avandu--insert-article-excerpt
|
||||||
|
(cdr (assq 'excerpt elt))))
|
||||||
(cdr (assq 'content result)))
|
(cdr (assq 'content result)))
|
||||||
(setq buffer-read-only t)
|
(setq buffer-read-only t)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
|
|
Loading…
Reference in a new issue