From c3d4505b5a8bf55044a1f40da5018e83a43157ff Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 26 Jan 2015 12:48:44 +1100 Subject: [PATCH] * lisp/net/eww.el (eww-add-bookmark): Fix prompt And clean up the code slightly. --- lisp/ChangeLog | 5 +++++ lisp/net/eww.el | 25 ++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 70293af2725..044c2999396 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2015-01-26 Lars Ingebrigtsen + + * net/eww.el (eww-add-bookmark): Fix prompt and clean up the code + slightly. + 2015-01-25 Stefan Monnier * emacs-lisp/cl-generic.el (cl--generic-no-next-method-function): New fun. diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 879eb53115e..ec7a0baacf6 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -1430,24 +1430,23 @@ Differences in #targets are ignored." (defvar eww-bookmarks nil) (defun eww-add-bookmark () - "Add the current page to the bookmarks." + "Bookmark the current page." (interactive) (eww-read-bookmarks) (dolist (bookmark eww-bookmarks) (when (equal (plist-get eww-data :url) (plist-get bookmark :url)) (user-error "Already bookmarked"))) - (if (y-or-n-p "bookmark this page? ") - (progn - (let ((title (replace-regexp-in-string "[\n\t\r]" " " - (plist-get eww-data :title)))) - (setq title (replace-regexp-in-string "\\` +\\| +\\'" "" title)) - (push (list :url (plist-get eww-data :url) - :title title - :time (current-time-string)) - eww-bookmarks)) - (eww-write-bookmarks) - (message "Bookmarked %s (%s)" (plist-get eww-data :url) - (plist-get eww-data :title))))) + (when (y-or-n-p "Bookmark this page?") + (let ((title (replace-regexp-in-string "[\n\t\r]" " " + (plist-get eww-data :title)))) + (setq title (replace-regexp-in-string "\\` +\\| +\\'" "" title)) + (push (list :url (plist-get eww-data :url) + :title title + :time (current-time-string)) + eww-bookmarks)) + (eww-write-bookmarks) + (message "Bookmarked %s (%s)" (plist-get eww-data :url) + (plist-get eww-data :title)))) (defun eww-write-bookmarks () (with-temp-file (expand-file-name "eww-bookmarks" eww-bookmarks-directory) -- 2.39.5