unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#35918: [PATCH] bookmark.el: Make bookmark-maybe-message obsolete
@ 2019-05-26 12:45 Stefan Kangas
  2019-05-30 12:44 ` Basil L. Contovounesios
  2019-06-09 23:40 ` Paul Eggert
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Kangas @ 2019-05-26 12:45 UTC (permalink / raw)
  To: 35918


[-- Attachment #1.1: Type: text/plain, Size: 246 bytes --]

The `bookmark-maybe-message' function checks the `baud-rate' variable before
displaying a message.  I don't believe this is necessary nowadays.

I therefore suggest that we make it an obsolete function alias for
`message'.

Thanks,
Stefan Kangas

[-- Attachment #1.2: Type: text/html, Size: 318 bytes --]

[-- Attachment #2: 0001-Make-bookmark-maybe-message-obsolete.patch --]
[-- Type: text/x-patch, Size: 2570 bytes --]

From a030df951f35f9accc9138728c3968f512084efe Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sun, 26 May 2019 14:32:55 +0200
Subject: [PATCH] Make bookmark-maybe-message obsolete

* bookmark.el (bookmark-maybe-message): Redefine as obsolete function
alias for `message'.
---
 lisp/bookmark.el | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index b1fe690dac..9b93c099af 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -745,16 +745,10 @@ bookmark-insert-file-format-version-stamp
 ;;; end file-format stuff
 
 \f
-;;; 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)))
-
-\f
 ;;; Core code:
 
+(define-obsolete-function-alias 'bookmark-maybe-message 'message "27.1")
+
 (defvar bookmark-minibuffer-read-name-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map minibuffer-local-map)
@@ -1429,7 +1423,7 @@ bookmark-save
 \f
 (defun bookmark-write-file (file)
   "Write `bookmark-alist' to FILE."
-  (bookmark-maybe-message "Saving bookmarks to file %s..." file)
+  (message "Saving bookmarks to file %s..." file)
   (with-current-buffer (get-buffer-create " *Bookmarks*")
     (goto-char (point-min))
     (delete-region (point-min) (point-max))
@@ -1468,8 +1462,7 @@ bookmark-write-file
           (file-error (message "Can't write %s" file)))
         (setq bookmark-file-coding-system coding-system-for-write)
         (kill-buffer (current-buffer))
-        (bookmark-maybe-message
-         "Saving bookmarks to file %s...done" file)))))
+        (message "Saving bookmarks to file %s...done" file)))))
 
 
 (defun bookmark-import-new-list (new-list)
@@ -1527,7 +1520,7 @@ bookmark-load
   (if (not (file-readable-p file))
       (error "Cannot read bookmark file %s" file)
     (if (null no-msg)
-        (bookmark-maybe-message "Loading bookmarks from %s..." file))
+        (message "Loading bookmarks from %s..." file))
     (with-current-buffer (let ((enable-local-variables nil))
                            (find-file-noselect file))
       (goto-char (point-min))
@@ -1553,7 +1546,7 @@ bookmark-load
           (error "Invalid bookmark list in %s" file)))
       (kill-buffer (current-buffer)))
     (if (null no-msg)
-        (bookmark-maybe-message "Loading bookmarks from %s...done" file))))
+        (message "Loading bookmarks from %s...done" file))))
 
 
 \f
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#35918: [PATCH] bookmark.el: Make bookmark-maybe-message obsolete
  2019-05-26 12:45 bug#35918: [PATCH] bookmark.el: Make bookmark-maybe-message obsolete Stefan Kangas
@ 2019-05-30 12:44 ` Basil L. Contovounesios
  2019-05-30 19:51   ` Stefan Kangas
  2019-06-09 23:40 ` Paul Eggert
  1 sibling, 1 reply; 4+ messages in thread
From: Basil L. Contovounesios @ 2019-05-30 12:44 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 35918

Stefan Kangas <stefan@marxist.se> writes:

> The `bookmark-maybe-message' function checks the `baud-rate' variable before
> displaying a message.  I don't believe this is necessary nowadays.
>
> I therefore suggest that we make it an obsolete function alias for `message'.

I agree with making it an obsolete function alias of message, but
instead of replacing its calls with message, why not use a progress
reporter?

Thanks,

-- 
Basil





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#35918: [PATCH] bookmark.el: Make bookmark-maybe-message obsolete
  2019-05-30 12:44 ` Basil L. Contovounesios
@ 2019-05-30 19:51   ` Stefan Kangas
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Kangas @ 2019-05-30 19:51 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 35918

[-- Attachment #1: Type: text/plain, Size: 267 bytes --]

Basil L. Contovounesios <contovob@tcd.ie> writes:
> I agree with making it an obsolete function alias of message, but
> instead of replacing its calls with message, why not use a progress
> reporter?

Good idea.  Please see this updated patch.

Thanks,
Stefan Kangas

[-- Attachment #2: 0001-Make-bookmark-maybe-message-obsolete.patch --]
[-- Type: text/x-patch, Size: 8383 bytes --]

From a405b7252736b664f8865925913b2e8323a0a022 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sun, 26 May 2019 14:32:55 +0200
Subject: [PATCH] Make bookmark-maybe-message obsolete

* 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.
---
 lisp/bookmark.el | 147 +++++++++++++++++++++++++++----------------------------
 1 file changed, 71 insertions(+), 76 deletions(-)

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index b1fe690dac..1de5480733 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -745,16 +745,10 @@ bookmark-insert-file-format-version-stamp
 ;;; end file-format stuff
 
 \f
-;;; 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)))
-
-\f
 ;;; Core code:
 
+(define-obsolete-function-alias 'bookmark-maybe-message 'message "27.1")
+
 (defvar bookmark-minibuffer-read-name-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map minibuffer-local-map)
@@ -1429,47 +1423,46 @@ bookmark-save
 \f
 (defun bookmark-write-file (file)
   "Write `bookmark-alist' to FILE."
-  (bookmark-maybe-message "Saving bookmarks to file %s..." file)
-  (with-current-buffer (get-buffer-create " *Bookmarks*")
-    (goto-char (point-min))
-    (delete-region (point-min) (point-max))
-    (let ((coding-system-for-write
-           (or coding-system-for-write
-               bookmark-file-coding-system 'utf-8-emacs))
-          (print-length nil)
-          (print-level nil)
-          ;; See bug #12503 for why we bind `print-circle'.  Users
-          ;; can define their own bookmark types, which can result in
-          ;; arbitrary Lisp objects being stored in bookmark records,
-          ;; and some users create objects containing circularities.
-          (print-circle t))
-      (insert "(")
-      ;; Rather than a single call to `pp' we make one per bookmark.
-      ;; Apparently `pp' has a poor algorithmic complexity, so this
-      ;; scales a lot better.  bug#4485.
-      (dolist (i bookmark-alist) (pp i (current-buffer)))
-      (insert ")")
-      ;; Make sure the specified encoding can safely encode the
-      ;; bookmarks.  If it cannot, suggest utf-8-emacs as default.
-      (with-coding-priority '(utf-8-emacs)
-        (setq coding-system-for-write
-              (select-safe-coding-system (point-min) (point-max)
-                                         (list t coding-system-for-write))))
+  (let ((reporter (make-progress-reporter (format "Saving bookmarks to file %s..." file))))
+    (with-current-buffer (get-buffer-create " *Bookmarks*")
       (goto-char (point-min))
-      (bookmark-insert-file-format-version-stamp coding-system-for-write)
-      (let ((version-control
-             (cond
-              ((null bookmark-version-control) nil)
-              ((eq 'never bookmark-version-control) 'never)
-              ((eq 'nospecial bookmark-version-control) version-control)
-              (t t))))
-        (condition-case nil
-            (write-region (point-min) (point-max) file)
-          (file-error (message "Can't write %s" file)))
-        (setq bookmark-file-coding-system coding-system-for-write)
-        (kill-buffer (current-buffer))
-        (bookmark-maybe-message
-         "Saving bookmarks to file %s...done" file)))))
+      (delete-region (point-min) (point-max))
+      (let ((coding-system-for-write
+             (or coding-system-for-write
+                 bookmark-file-coding-system 'utf-8-emacs))
+            (print-length nil)
+            (print-level nil)
+            ;; See bug #12503 for why we bind `print-circle'.  Users
+            ;; can define their own bookmark types, which can result in
+            ;; arbitrary Lisp objects being stored in bookmark records,
+            ;; and some users create objects containing circularities.
+            (print-circle t))
+        (insert "(")
+        ;; Rather than a single call to `pp' we make one per bookmark.
+        ;; Apparently `pp' has a poor algorithmic complexity, so this
+        ;; scales a lot better.  bug#4485.
+        (dolist (i bookmark-alist) (pp i (current-buffer)))
+        (insert ")")
+        ;; Make sure the specified encoding can safely encode the
+        ;; bookmarks.  If it cannot, suggest utf-8-emacs as default.
+        (with-coding-priority '(utf-8-emacs)
+          (setq coding-system-for-write
+                (select-safe-coding-system (point-min) (point-max)
+                                           (list t coding-system-for-write))))
+        (goto-char (point-min))
+        (bookmark-insert-file-format-version-stamp coding-system-for-write)
+        (let ((version-control
+               (cond
+                ((null bookmark-version-control) nil)
+                ((eq 'never bookmark-version-control) 'never)
+                ((eq 'nospecial bookmark-version-control) version-control)
+                (t t))))
+          (condition-case nil
+              (write-region (point-min) (point-max) file)
+            (file-error (message "Can't write %s" file)))
+          (setq bookmark-file-coding-system coding-system-for-write)
+          (kill-buffer (current-buffer))
+          (progress-reporter-done reporter))))))
 
 
 (defun bookmark-import-new-list (new-list)
@@ -1526,34 +1519,36 @@ bookmark-load
   (setq file (abbreviate-file-name (expand-file-name file)))
   (if (not (file-readable-p file))
       (error "Cannot read bookmark file %s" file)
-    (if (null no-msg)
-        (bookmark-maybe-message "Loading bookmarks from %s..." file))
-    (with-current-buffer (let ((enable-local-variables nil))
-                           (find-file-noselect file))
-      (goto-char (point-min))
-      (bookmark-maybe-upgrade-file-format)
-      (let ((blist (bookmark-alist-from-buffer)))
-        (if (listp blist)
-            (progn
-              (if overwrite
-                  (progn
-                    (setq bookmark-alist blist)
-                    (setq bookmark-alist-modification-count 0))
-                ;; else
-                (bookmark-import-new-list blist)
-                (setq bookmark-alist-modification-count
-                      (1+ bookmark-alist-modification-count)))
-              (if (string-equal
-                   (abbreviate-file-name
-                    (expand-file-name bookmark-default-file))
-                   file)
-                  (setq bookmarks-already-loaded t))
-              (bookmark-bmenu-surreptitiously-rebuild-list)
-              (setq bookmark-file-coding-system buffer-file-coding-system))
-          (error "Invalid bookmark list in %s" file)))
-      (kill-buffer (current-buffer)))
-    (if (null no-msg)
-        (bookmark-maybe-message "Loading bookmarks from %s...done" file))))
+    (let ((reporter
+           (when (null no-msg)
+             (make-progress-reporter
+              (format "Loading bookmarks from %s..." file)))))
+      (with-current-buffer (let ((enable-local-variables nil))
+                             (find-file-noselect file))
+        (goto-char (point-min))
+        (bookmark-maybe-upgrade-file-format)
+        (let ((blist (bookmark-alist-from-buffer)))
+          (if (listp blist)
+              (progn
+                (if overwrite
+                    (progn
+                      (setq bookmark-alist blist)
+                      (setq bookmark-alist-modification-count 0))
+                  ;; else
+                  (bookmark-import-new-list blist)
+                  (setq bookmark-alist-modification-count
+                        (1+ bookmark-alist-modification-count)))
+                (if (string-equal
+                     (abbreviate-file-name
+                      (expand-file-name bookmark-default-file))
+                     file)
+                    (setq bookmarks-already-loaded t))
+                (bookmark-bmenu-surreptitiously-rebuild-list)
+                (setq bookmark-file-coding-system buffer-file-coding-system))
+            (error "Invalid bookmark list in %s" file)))
+        (kill-buffer (current-buffer)))
+      (when (null no-msg)
+        (progress-reporter-done reporter)))))
 
 
 \f
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#35918: [PATCH] bookmark.el: Make bookmark-maybe-message obsolete
  2019-05-26 12:45 bug#35918: [PATCH] bookmark.el: Make bookmark-maybe-message obsolete Stefan Kangas
  2019-05-30 12:44 ` Basil L. Contovounesios
@ 2019-06-09 23:40 ` Paul Eggert
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Eggert @ 2019-06-09 23:40 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 35918-done

Thanks, I installed that. Working my way through your patches....






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-09 23:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-26 12:45 bug#35918: [PATCH] bookmark.el: Make bookmark-maybe-message obsolete Stefan Kangas
2019-05-30 12:44 ` Basil L. Contovounesios
2019-05-30 19:51   ` Stefan Kangas
2019-06-09 23:40 ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).