From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#25365: 25.1; Coding system for bookmarks and desktop Date: Tue, 10 Jan 2017 17:49:57 +0200 Message-ID: <83a8ayewyi.fsf@gnu.org> References: <87mvf57kdx.fsf@gmail.com> <83pojzavhg.fsf@gnu.org> <87d1fxzy9d.fsf@gmail.com> <83k2a5blo9.fsf@gnu.org> <874m18yxei.fsf@gmail.com> <83eg0cdq68.fsf@gnu.org> <87tw98x99x.fsf@gmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1484063474 12611 195.159.176.226 (10 Jan 2017 15:51:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 10 Jan 2017 15:51:14 +0000 (UTC) Cc: 25365@debbugs.gnu.org To: Dmitri Paduchikh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 10 16:51:09 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQyhY-0002nu-98 for geb-bug-gnu-emacs@m.gmane.org; Tue, 10 Jan 2017 16:51:08 +0100 Original-Received: from localhost ([::1]:48111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQyhc-0003BX-QO for geb-bug-gnu-emacs@m.gmane.org; Tue, 10 Jan 2017 10:51:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQyhW-0003BS-Sv for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 10:51:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQyhS-0001J9-Dt for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 10:51:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33656) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cQyhS-0001J3-AG for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 10:51:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cQyhS-00055l-1w for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2017 10:51:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Jan 2017 15:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25365 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25365-submit@debbugs.gnu.org id=B25365.148406340919511 (code B ref 25365); Tue, 10 Jan 2017 15:51:02 +0000 Original-Received: (at 25365) by debbugs.gnu.org; 10 Jan 2017 15:50:09 +0000 Original-Received: from localhost ([127.0.0.1]:49054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQyga-00054c-O9 for submit@debbugs.gnu.org; Tue, 10 Jan 2017 10:50:08 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:52661) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQygY-00054B-Lz for 25365@debbugs.gnu.org; Tue, 10 Jan 2017 10:50:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQygQ-00010P-AU for 25365@debbugs.gnu.org; Tue, 10 Jan 2017 10:50:01 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:60908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQygQ-00010L-6b; Tue, 10 Jan 2017 10:49:58 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2143 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cQygP-0005xa-FM; Tue, 10 Jan 2017 10:49:57 -0500 In-reply-to: <87tw98x99x.fsf@gmail.com> (message from Dmitri Paduchikh on Tue, 10 Jan 2017 01:34:18 +0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:127963 Archived-At: > From: Dmitri Paduchikh > 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 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)