Abstract the parsing and creation of single lines

Don't use `replace-regexp-in-string' in so many places, use
`avandu--oneline'.
This commit is contained in:
Tom Willemsen 2012-08-07 09:49:08 +02:00
parent 2d67666547
commit e96da80199

View file

@ -259,8 +259,7 @@ with `auth-source-search' and then by asking the user."
"Insert the excerpt of an article." "Insert the excerpt of an article."
(let ((start-pos (point)) (let ((start-pos (point))
end-pos end-pos
(text (replace-regexp-in-string (text (avandu--oneline excerpt)))
"[ \t\n]*$" "" (avandu--clean-text excerpt))))
(unless (or (not text) (string= text "")) (unless (or (not text) (string= text ""))
(insert (insert
(propertize (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 "Insert a button with the label TITLE and store ID and LINK in
the article-id and link properties, respectively." the article-id and link properties, respectively."
(insert-button (insert-button
(replace-regexp-in-string "^[ \n\t]*\\|[ \n\t]*$" "" title) (avandu--oneline title)
'face 'avandu-overview-unread-article 'face 'avandu-overview-unread-article
'article-id id 'article-id id
'link link 'link link
@ -288,7 +287,7 @@ the article-id and link properties, respectively."
feed-id property." feed-id property."
(unless (eq (point) (point-min)) (insert-char ?\n 1)) (unless (eq (point) (point-min)) (insert-char ?\n 1))
(insert-button (insert-button
(replace-regexp-in-string "^[ \n\t]*\\|[ \n\t]*$" "" title) (avandu--oneline title)
'face 'avandu-overview-feed 'face 'avandu-overview-feed
'feed-id id 'feed-id id
'keymap avandu-feed-button-map 'keymap avandu-feed-button-map
@ -296,6 +295,10 @@ feed-id property."
(message "%s" (button-label button)))) (message "%s" (button-label button))))
(insert-char ?\n 2)) (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 () (defun avandu--password ()
"Get the password. This means either return `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." as-is, or if it's a function return the result of that function."