changeset 66835:96e7147004a8

* bookmark.el (bookmark-maybe-message): New function to reduce code duplication: invokes `message' iff baud-rate is high enough. (bookmark-write-file): Use above instead of an inline conditional. (bookmark-load): Same.
author Karl Fogel <kfogel@red-bean.com>
date Sat, 12 Nov 2005 20:46:10 +0000
parents 871ff6d80553
children 4542eb0122f7
files lisp/ChangeLog lisp/bookmark.el
diffstat 2 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Nov 12 20:30:22 2005 +0000
+++ b/lisp/ChangeLog	Sat Nov 12 20:46:10 2005 +0000
@@ -1,3 +1,10 @@
+2005-11-12  Karl Fogel  <kfogel@red-bean.com>
+	
+	* bookmark.el (bookmark-maybe-message): New function to reduce
+	code duplication: invokes `message' iff baud-rate is high enough. 
+	(bookmark-write-file): Use above instead of an inline conditional.
+	(bookmark-load): Same.
+	
 2005-11-12  Karl Fogel  <kfogel@red-bean.com>
 
 	* bookmark.el (bookmark-write-file): Don't visit the destination
--- a/lisp/bookmark.el	Sat Nov 12 20:30:22 2005 +0000
+++ b/lisp/bookmark.el	Sat Nov 12 20:46:10 2005 +0000
@@ -717,6 +717,14 @@
 ;;; end file-format stuff
 
 
+;;; Generic helpers.
+
+(defun bookmark-maybe-message (fmt &rest args)
+  "Apply `message' to FMT and ARGS, but only if the display is fast enough."
+  (if (>= baud-rate 9600)
+      (apply 'message fmt args)))
+
+
 ;;; Core code:
 
 ;;;###autoload
@@ -1350,8 +1358,7 @@
 (defun bookmark-write-file (file)
   (save-excursion
     (save-window-excursion
-      (if (>= baud-rate 9600)
-          (message "Saving bookmarks to file %s..." file))
+      (bookmark-maybe-message "Saving bookmarks to file %s..." file)
       (set-buffer (get-buffer-create " *Bookmarks*"))
       (goto-char (point-min))
       (delete-region (point-min) (point-max))
@@ -1370,8 +1377,8 @@
               (write-region (point-min) (point-max) file)
             (file-error (message "Can't write %s" file)))
 	  (kill-buffer (current-buffer))
-	  (if (>= baud-rate 9600)
-	      (message "Saving bookmarks to file %s...done" file)))))))
+          (bookmark-maybe-message
+           "Saving bookmarks to file %s...done" file))))))
 
 
 (defun bookmark-import-new-list (new-list)
@@ -1437,8 +1444,8 @@
   (if (file-readable-p file)
       (save-excursion
         (save-window-excursion
-          (if (and (null no-msg) (>= baud-rate 9600))
-              (message "Loading bookmarks from %s..." file))
+          (if (null no-msg)
+              (bookmark-maybe-message "Loading bookmarks from %s..." file))
           (set-buffer (let ((enable-local-variables nil))
                         (find-file-noselect file)))
           (goto-char (point-min))
@@ -1461,8 +1468,8 @@
                   (bookmark-bmenu-surreptitiously-rebuild-list))
               (error "Invalid bookmark list in %s" file)))
           (kill-buffer (current-buffer)))
-	(if (and (null no-msg) (>= baud-rate 9600))
-            (message "Loading bookmarks from %s...done" file)))
+	(if (null no-msg)
+            (bookmark-maybe-message "Loading bookmarks from %s...done" file)))
     (error "Cannot read bookmark file %s" file)))