all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Dmitri Paduchikh <dpaduchikh@gmail.com>
Cc: 25365@debbugs.gnu.org
Subject: bug#25365: 25.1; Coding system for bookmarks and desktop
Date: Tue, 10 Jan 2017 17:49:57 +0200	[thread overview]
Message-ID: <83a8ayewyi.fsf@gnu.org> (raw)
In-Reply-To: <87tw98x99x.fsf@gmail.com> (message from Dmitri Paduchikh on Tue,  10 Jan 2017 01:34:18 +0500)

> From: Dmitri Paduchikh <dpaduchikh@gmail.com>
> Cc: 25365@debbugs.gnu.org
> Date: Tue, 10 Jan 2017 01:34:18 +0500
> 
> EZ> E.g., set a bookmark in TUTORIAL.ru, and then try saving the
> EZ> bookmark file using the Latin-1 encoding. I just tried something
> EZ> like that, and the effect was exactly as I expected: Emacs requested
> EZ> me to provide another encoding.
> 
> Try this in different order. Assuming your patch applied, save bookmarks
> using latin-1. Suppose this operation passes successfully and bookmarks
> have been saved using latin-1. Then bookmark TUTORIAL.ru and save again
> not specifying encoding.

Ah, OK.  Then the attached additional change should handle that use
case.

Thanks.

commit 560a384038845e37228226313eccfc8d70132553
Author:     Eli Zaretskii <eliz@gnu.org>
AuthorDate: Tue Jan 10 17:47:10 2017 +0200

    Don't use unsafe encoding for the bookmark file
    
    * lisp/bookmark.el (bookmark-write-file): Handle the case when the
    explicitly specified encoding of the bookmark file cannot encode the
    additional bookmarks just added.  (Bug#25365)

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index e18362b..02dd8a9 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1432,13 +1432,20 @@ bookmark-write-file
           ;; 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 ")")
+      ;; 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)





      reply	other threads:[~2017-01-10 15:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05 12:37 bug#25365: 25.1; Coding system for bookmarks and desktop Dmitri Paduchikh
2017-01-06 14:56 ` Dmitri Paduchikh
2017-01-07 12:46 ` Eli Zaretskii
2017-01-08  9:39   ` Dmitri Paduchikh
2017-01-08 15:45     ` Eli Zaretskii
2017-01-09 17:07       ` Dmitri Paduchikh
2017-01-09 18:49         ` Eli Zaretskii
2017-01-09 20:34           ` Dmitri Paduchikh
2017-01-10 15:49             ` Eli Zaretskii [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83a8ayewyi.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=25365@debbugs.gnu.org \
    --cc=dpaduchikh@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.