aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-07-26 00:49:18 +0200
committerGravatar Tom Willemsen2012-07-26 00:49:18 +0200
commit529c17e7c1f5427ce6ef8dd0527495f0103279f7 (patch)
treea15687802e05c016064a94133f8b0f842ac196d9
parenta0882bf8da5385c80c238fa85f2d065fcc1451cd (diff)
downloadavandu-529c17e7c1f5427ce6ef8dd0527495f0103279f7.tar.gz
avandu-529c17e7c1f5427ce6ef8dd0527495f0103279f7.zip
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.
-rw-r--r--avandu.el34
1 files changed, 28 insertions, 6 deletions
diff --git a/avandu.el b/avandu.el
index 992b871..11a1688 100644
--- a/avandu.el
+++ b/avandu.el
@@ -62,6 +62,11 @@
"Face for read article titles in avandu overview."
: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
"*internal* Session id for avandu.")
@@ -274,7 +279,7 @@ feeds."
(defun avandu--insert-feed-title (id title)
"Insert a button with the label TITLE and store ID in the
feed-id property."
- (unless (eq (point) (point-min)) (newline))
+ (unless (eq (point) (point-min)) (insert-char ?\n 1))
(insert-button
(replace-regexp-in-string "^[ \n\t]*\\|[ \n\t]*$" "" title)
'face 'avandu-overview-feed
@@ -282,8 +287,7 @@ feed-id property."
'keymap avandu-feed-button-map
'action #'(lambda (button)
(message "%s" (button-label button))))
- (newline)
- (newline))
+ (insert-char ?\n 2))
(defun avandu-browse-article ()
"Browse the current button's article url."
@@ -303,7 +307,22 @@ the article-id and link properties, respectively."
'keymap avandu-article-button-map
'action #'(lambda (button)
(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
(defun avandu-list ()
@@ -314,7 +333,8 @@ by feed."
(let ((buffer (get-buffer-create "*avandu-overview*"))
(result (avandu-send-command '((op . "getHeadlines")
(feed_id . -4)
- (view_mode . "unread"))))
+ (view_mode . "unread")
+ (show_excerpt . t))))
feed-id)
(with-current-buffer buffer
(setq buffer-read-only nil)
@@ -329,7 +349,9 @@ by feed."
(avandu--insert-article-title
(cdr (assq 'id 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)))
(setq buffer-read-only t)
(goto-char (point-min))