diff options
| author | Karl Fogel | 2005-11-12 20:46:10 +0000 |
|---|---|---|
| committer | Karl Fogel | 2005-11-12 20:46:10 +0000 |
| commit | 9a9f1fddff04cc77b4ecba74efc79b7edc54c570 (patch) | |
| tree | ed119ae84429a1c64f0e17f9ee707ba335fcc779 | |
| parent | a506054af7cd86a63fda996056c09310966f32ef (diff) | |
| download | emacs-9a9f1fddff04cc77b4ecba74efc79b7edc54c570.tar.gz emacs-9a9f1fddff04cc77b4ecba74efc79b7edc54c570.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/bookmark.el | 23 |
2 files changed, 22 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bc3bca39cc6..ad73cf38f39 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,4 +1,11 @@ | |||
| 1 | 2005-11-12 Karl Fogel <kfogel@red-bean.com> | 1 | 2005-11-12 Karl Fogel <kfogel@red-bean.com> |
| 2 | |||
| 3 | * bookmark.el (bookmark-maybe-message): New function to reduce | ||
| 4 | code duplication: invokes `message' iff baud-rate is high enough. | ||
| 5 | (bookmark-write-file): Use above instead of an inline conditional. | ||
| 6 | (bookmark-load): Same. | ||
| 7 | |||
| 8 | 2005-11-12 Karl Fogel <kfogel@red-bean.com> | ||
| 2 | 9 | ||
| 3 | * bookmark.el (bookmark-write-file): Don't visit the destination | 10 | * bookmark.el (bookmark-write-file): Don't visit the destination |
| 4 | file, just write the data to it using write-region. This is | 11 | file, just write the data to it using write-region. This is |
diff --git a/lisp/bookmark.el b/lisp/bookmark.el index de1bb4f6a6c..31616469454 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el | |||
| @@ -717,6 +717,14 @@ This expects to be called from `point-min' in a bookmark file." | |||
| 717 | ;;; end file-format stuff | 717 | ;;; end file-format stuff |
| 718 | 718 | ||
| 719 | 719 | ||
| 720 | ;;; Generic helpers. | ||
| 721 | |||
| 722 | (defun bookmark-maybe-message (fmt &rest args) | ||
| 723 | "Apply `message' to FMT and ARGS, but only if the display is fast enough." | ||
| 724 | (if (>= baud-rate 9600) | ||
| 725 | (apply 'message fmt args))) | ||
| 726 | |||
| 727 | |||
| 720 | ;;; Core code: | 728 | ;;; Core code: |
| 721 | 729 | ||
| 722 | ;;;###autoload | 730 | ;;;###autoload |
| @@ -1350,8 +1358,7 @@ for a file, defaulting to the file defined by variable | |||
| 1350 | (defun bookmark-write-file (file) | 1358 | (defun bookmark-write-file (file) |
| 1351 | (save-excursion | 1359 | (save-excursion |
| 1352 | (save-window-excursion | 1360 | (save-window-excursion |
| 1353 | (if (>= baud-rate 9600) | 1361 | (bookmark-maybe-message "Saving bookmarks to file %s..." file) |
| 1354 | (message "Saving bookmarks to file %s..." file)) | ||
| 1355 | (set-buffer (get-buffer-create " *Bookmarks*")) | 1362 | (set-buffer (get-buffer-create " *Bookmarks*")) |
| 1356 | (goto-char (point-min)) | 1363 | (goto-char (point-min)) |
| 1357 | (delete-region (point-min) (point-max)) | 1364 | (delete-region (point-min) (point-max)) |
| @@ -1370,8 +1377,8 @@ for a file, defaulting to the file defined by variable | |||
| 1370 | (write-region (point-min) (point-max) file) | 1377 | (write-region (point-min) (point-max) file) |
| 1371 | (file-error (message "Can't write %s" file))) | 1378 | (file-error (message "Can't write %s" file))) |
| 1372 | (kill-buffer (current-buffer)) | 1379 | (kill-buffer (current-buffer)) |
| 1373 | (if (>= baud-rate 9600) | 1380 | (bookmark-maybe-message |
| 1374 | (message "Saving bookmarks to file %s...done" file))))))) | 1381 | "Saving bookmarks to file %s...done" file)))))) |
| 1375 | 1382 | ||
| 1376 | 1383 | ||
| 1377 | (defun bookmark-import-new-list (new-list) | 1384 | (defun bookmark-import-new-list (new-list) |
| @@ -1437,8 +1444,8 @@ method buffers use to resolve name collisions." | |||
| 1437 | (if (file-readable-p file) | 1444 | (if (file-readable-p file) |
| 1438 | (save-excursion | 1445 | (save-excursion |
| 1439 | (save-window-excursion | 1446 | (save-window-excursion |
| 1440 | (if (and (null no-msg) (>= baud-rate 9600)) | 1447 | (if (null no-msg) |
| 1441 | (message "Loading bookmarks from %s..." file)) | 1448 | (bookmark-maybe-message "Loading bookmarks from %s..." file)) |
| 1442 | (set-buffer (let ((enable-local-variables nil)) | 1449 | (set-buffer (let ((enable-local-variables nil)) |
| 1443 | (find-file-noselect file))) | 1450 | (find-file-noselect file))) |
| 1444 | (goto-char (point-min)) | 1451 | (goto-char (point-min)) |
| @@ -1461,8 +1468,8 @@ method buffers use to resolve name collisions." | |||
| 1461 | (bookmark-bmenu-surreptitiously-rebuild-list)) | 1468 | (bookmark-bmenu-surreptitiously-rebuild-list)) |
| 1462 | (error "Invalid bookmark list in %s" file))) | 1469 | (error "Invalid bookmark list in %s" file))) |
| 1463 | (kill-buffer (current-buffer))) | 1470 | (kill-buffer (current-buffer))) |
| 1464 | (if (and (null no-msg) (>= baud-rate 9600)) | 1471 | (if (null no-msg) |
| 1465 | (message "Loading bookmarks from %s...done" file))) | 1472 | (bookmark-maybe-message "Loading bookmarks from %s...done" file))) |
| 1466 | (error "Cannot read bookmark file %s" file))) | 1473 | (error "Cannot read bookmark file %s" file))) |
| 1467 | 1474 | ||
| 1468 | 1475 | ||