GNU bug report logs - #25365
25.1; Coding system for bookmarks and desktop

Previous Next

Package: emacs;

Reported by: Dmitri Paduchikh <dpaduchikh <at> gmail.com>

Date: Thu, 5 Jan 2017 12:38:02 UTC

Severity: minor

Found in version 25.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dmitri Paduchikh <dpaduchikh <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25365 <at> debbugs.gnu.org
Subject: bug#25365: 25.1; Coding system for bookmarks and desktop
Date: Mon, 09 Jan 2017 22:07:49 +0500
Eli Zaretskii <eliz <at> gnu.org> wrote:

[...]

>> Also setting coding system through coding-system-for-write will make
>> non-encodable characters replaced by spaces.

EZ> This option exists for users who really know what they are doing; the
EZ> default utf-8-emacs encoding is safe for any and all characters Emacs
EZ> supports.

It may be hard to know what is happening if it is designed to happen
automatically. So, if you insist on supporting user choice here, please
consider the following patch. It adds the check of workability of the chosen
codec unless it is given directly by user in which case the usual procedure
applies, or the codec is omnipotent. In the case of encodability problems it
will fallback to utf-8-emacs.

I hope it is trivial enough as I did not sign papers.

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index e18362bca9..87638cdf1e 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1432,13 +1432,21 @@ for a file, defaulting to the file defined by variable
           ;; arbitrary Lisp objects being stored in bookmark records,
           ;; and some users create objects containing circularities.
           (print-circle t))
-      (bookmark-insert-file-format-version-stamp coding-system-for-write)
       (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 ")")
+      ;; Check that coding system is safe unless it is given directly by
+      ;; user or is omnipotent. Silently fallback to utf-8-emacs in a case.
+      (unless (or coding-system-require-warning ; coding is given by user
+                  (memq 'emacs (coding-system-charset-list coding-system-for-write)))
+        (setq coding-system-for-write
+              (select-safe-coding-system (point-min) (point-max)
+                                         (list coding-system-for-write 'utf-8-emacs) t)))
+      (goto-char (point-min))
+      (bookmark-insert-file-format-version-stamp coding-system-for-write)
       (let ((version-control
              (cond
               ((null bookmark-version-control) nil)

With best regards
Dmitri Paduchikh







This bug report was last modified 8 years and 185 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.