aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2019-06-09 16:38:31 -0700
committerPaul Eggert2019-06-09 16:38:59 -0700
commitd11dd6a90c1ccee5f635d752d98a98b1c7adbe03 (patch)
tree3a08a7e77de8b6405ed67ea2cdff1bbfa2c2095f
parent9816aba5185dd95ca0981cf2b35ce2b1024ca497 (diff)
downloademacs-d11dd6a90c1ccee5f635d752d98a98b1c7adbe03.tar.gz
emacs-d11dd6a90c1ccee5f635d752d98a98b1c7adbe03.zip
Make bookmark-maybe-message obsolete (Bug#35918)
* lisp/bookmark.el (bookmark-maybe-message): Redefine as obsolete function alias for 'message'. (bookmark-write-file): Use a progress reporter. (bookmark-load-file): Use a progress reporter.
-rw-r--r--lisp/bookmark.el148
1 files changed, 72 insertions, 76 deletions
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index d4fe2d9050c..00884506e4d 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -741,16 +741,10 @@ CODING is the symbol of the coding-system in which the file is encoded."
741;;; end file-format stuff 741;;; end file-format stuff
742 742
743 743
744;;; Generic helpers.
745
746(defun bookmark-maybe-message (fmt &rest args)
747 "Apply `message' to FMT and ARGS, but only if the display is fast enough."
748 (if (>= baud-rate 9600)
749 (apply 'message fmt args)))
750
751
752;;; Core code: 744;;; Core code:
753 745
746(define-obsolete-function-alias 'bookmark-maybe-message 'message "27.1")
747
754(defvar bookmark-minibuffer-read-name-map 748(defvar bookmark-minibuffer-read-name-map
755 (let ((map (make-sparse-keymap))) 749 (let ((map (make-sparse-keymap)))
756 (set-keymap-parent map minibuffer-local-map) 750 (set-keymap-parent map minibuffer-local-map)
@@ -1425,47 +1419,47 @@ for a file, defaulting to the file defined by variable
1425 1419
1426(defun bookmark-write-file (file) 1420(defun bookmark-write-file (file)
1427 "Write `bookmark-alist' to FILE." 1421 "Write `bookmark-alist' to FILE."
1428 (bookmark-maybe-message "Saving bookmarks to file %s..." file) 1422 (let ((reporter (make-progress-reporter
1429 (with-current-buffer (get-buffer-create " *Bookmarks*") 1423 (format "Saving bookmarks to file %s..." file))))
1430 (goto-char (point-min)) 1424 (with-current-buffer (get-buffer-create " *Bookmarks*")
1431 (delete-region (point-min) (point-max))
1432 (let ((coding-system-for-write
1433 (or coding-system-for-write
1434 bookmark-file-coding-system 'utf-8-emacs))
1435 (print-length nil)
1436 (print-level nil)
1437 ;; See bug #12503 for why we bind `print-circle'. Users
1438 ;; can define their own bookmark types, which can result in
1439 ;; arbitrary Lisp objects being stored in bookmark records,
1440 ;; and some users create objects containing circularities.
1441 (print-circle t))
1442 (insert "(")
1443 ;; Rather than a single call to `pp' we make one per bookmark.
1444 ;; Apparently `pp' has a poor algorithmic complexity, so this
1445 ;; scales a lot better. bug#4485.
1446 (dolist (i bookmark-alist) (pp i (current-buffer)))
1447 (insert ")")
1448 ;; Make sure the specified encoding can safely encode the
1449 ;; bookmarks. If it cannot, suggest utf-8-emacs as default.
1450 (with-coding-priority '(utf-8-emacs)
1451 (setq coding-system-for-write
1452 (select-safe-coding-system (point-min) (point-max)
1453 (list t coding-system-for-write))))
1454 (goto-char (point-min)) 1425 (goto-char (point-min))
1455 (bookmark-insert-file-format-version-stamp coding-system-for-write) 1426 (delete-region (point-min) (point-max))
1456 (let ((version-control 1427 (let ((coding-system-for-write
1457 (cond 1428 (or coding-system-for-write
1458 ((null bookmark-version-control) nil) 1429 bookmark-file-coding-system 'utf-8-emacs))
1459 ((eq 'never bookmark-version-control) 'never) 1430 (print-length nil)
1460 ((eq 'nospecial bookmark-version-control) version-control) 1431 (print-level nil)
1461 (t t)))) 1432 ;; See bug #12503 for why we bind `print-circle'. Users
1462 (condition-case nil 1433 ;; can define their own bookmark types, which can result in
1463 (write-region (point-min) (point-max) file) 1434 ;; arbitrary Lisp objects being stored in bookmark records,
1464 (file-error (message "Can't write %s" file))) 1435 ;; and some users create objects containing circularities.
1465 (setq bookmark-file-coding-system coding-system-for-write) 1436 (print-circle t))
1466 (kill-buffer (current-buffer)) 1437 (insert "(")
1467 (bookmark-maybe-message 1438 ;; Rather than a single call to `pp' we make one per bookmark.
1468 "Saving bookmarks to file %s...done" file))))) 1439 ;; Apparently `pp' has a poor algorithmic complexity, so this
1440 ;; scales a lot better. bug#4485.
1441 (dolist (i bookmark-alist) (pp i (current-buffer)))
1442 (insert ")")
1443 ;; Make sure the specified encoding can safely encode the
1444 ;; bookmarks. If it cannot, suggest utf-8-emacs as default.
1445 (with-coding-priority '(utf-8-emacs)
1446 (setq coding-system-for-write
1447 (select-safe-coding-system (point-min) (point-max)
1448 (list t coding-system-for-write))))
1449 (goto-char (point-min))
1450 (bookmark-insert-file-format-version-stamp coding-system-for-write)
1451 (let ((version-control
1452 (cond
1453 ((null bookmark-version-control) nil)
1454 ((eq 'never bookmark-version-control) 'never)
1455 ((eq 'nospecial bookmark-version-control) version-control)
1456 (t t))))
1457 (condition-case nil
1458 (write-region (point-min) (point-max) file)
1459 (file-error (message "Can't write %s" file)))
1460 (setq bookmark-file-coding-system coding-system-for-write)
1461 (kill-buffer (current-buffer))
1462 (progress-reporter-done reporter))))))
1469 1463
1470 1464
1471(defun bookmark-import-new-list (new-list) 1465(defun bookmark-import-new-list (new-list)
@@ -1522,34 +1516,36 @@ unique numeric suffixes \"<2>\", \"<3>\", etc."
1522 (setq file (abbreviate-file-name (expand-file-name file))) 1516 (setq file (abbreviate-file-name (expand-file-name file)))
1523 (if (not (file-readable-p file)) 1517 (if (not (file-readable-p file))
1524 (error "Cannot read bookmark file %s" file) 1518 (error "Cannot read bookmark file %s" file)
1525 (if (null no-msg) 1519 (let ((reporter
1526 (bookmark-maybe-message "Loading bookmarks from %s..." file)) 1520 (when (null no-msg)
1527 (with-current-buffer (let ((enable-local-variables nil)) 1521 (make-progress-reporter
1528 (find-file-noselect file)) 1522 (format "Loading bookmarks from %s..." file)))))
1529 (goto-char (point-min)) 1523 (with-current-buffer (let ((enable-local-variables nil))
1530 (bookmark-maybe-upgrade-file-format) 1524 (find-file-noselect file))
1531 (let ((blist (bookmark-alist-from-buffer))) 1525 (goto-char (point-min))
1532 (if (listp blist) 1526 (bookmark-maybe-upgrade-file-format)
1533 (progn 1527 (let ((blist (bookmark-alist-from-buffer)))
1534 (if overwrite 1528 (if (listp blist)
1535 (progn 1529 (progn
1536 (setq bookmark-alist blist) 1530 (if overwrite
1537 (setq bookmark-alist-modification-count 0)) 1531 (progn
1538 ;; else 1532 (setq bookmark-alist blist)
1539 (bookmark-import-new-list blist) 1533 (setq bookmark-alist-modification-count 0))
1540 (setq bookmark-alist-modification-count 1534 ;; else
1541 (1+ bookmark-alist-modification-count))) 1535 (bookmark-import-new-list blist)
1542 (if (string-equal 1536 (setq bookmark-alist-modification-count
1543 (abbreviate-file-name 1537 (1+ bookmark-alist-modification-count)))
1544 (expand-file-name bookmark-default-file)) 1538 (if (string-equal
1545 file) 1539 (abbreviate-file-name
1546 (setq bookmarks-already-loaded t)) 1540 (expand-file-name bookmark-default-file))
1547 (bookmark-bmenu-surreptitiously-rebuild-list) 1541 file)
1548 (setq bookmark-file-coding-system buffer-file-coding-system)) 1542 (setq bookmarks-already-loaded t))
1549 (error "Invalid bookmark list in %s" file))) 1543 (bookmark-bmenu-surreptitiously-rebuild-list)
1550 (kill-buffer (current-buffer))) 1544 (setq bookmark-file-coding-system buffer-file-coding-system))
1551 (if (null no-msg) 1545 (error "Invalid bookmark list in %s" file)))
1552 (bookmark-maybe-message "Loading bookmarks from %s...done" file)))) 1546 (kill-buffer (current-buffer)))
1547 (when (null no-msg)
1548 (progress-reporter-done reporter)))))
1553 1549
1554 1550
1555 1551