From e96da80199dd9b38c513bf57bb43aebf8b34920a Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Aug 2012 09:49:08 +0200 Subject: [PATCH] Abstract the parsing and creation of single lines Don't use `replace-regexp-in-string' in so many places, use `avandu--oneline'. --- avandu.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/avandu.el b/avandu.el index db3bbf7..62f5966 100644 --- a/avandu.el +++ b/avandu.el @@ -259,8 +259,7 @@ with `auth-source-search' and then by asking the user." "Insert the excerpt of an article." (let ((start-pos (point)) end-pos - (text (replace-regexp-in-string - "[ \t\n]*$" "" (avandu--clean-text excerpt)))) + (text (avandu--oneline excerpt))) (unless (or (not text) (string= text "")) (insert (propertize @@ -274,7 +273,7 @@ with `auth-source-search' and then by asking the user." "Insert a button with the label TITLE and store ID and LINK in the article-id and link properties, respectively." (insert-button - (replace-regexp-in-string "^[ \n\t]*\\|[ \n\t]*$" "" title) + (avandu--oneline title) 'face 'avandu-overview-unread-article 'article-id id 'link link @@ -288,7 +287,7 @@ the article-id and link properties, respectively." feed-id property." (unless (eq (point) (point-min)) (insert-char ?\n 1)) (insert-button - (replace-regexp-in-string "^[ \n\t]*\\|[ \n\t]*$" "" title) + (avandu--oneline title) 'face 'avandu-overview-feed 'feed-id id 'keymap avandu-feed-button-map @@ -296,6 +295,10 @@ feed-id property." (message "%s" (button-label button)))) (insert-char ?\n 2)) +(defun avandu--oneline (text) + "Make a single line out of and clean up TEXT." + (replace-regexp-in-string "[ \n\t]*$" "" (avandu--clean-text text))) + (defun avandu--password () "Get the password. This means either return `avandu-password' as-is, or if it's a function return the result of that function."