From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitri Paduchikh Newsgroups: gmane.emacs.bugs Subject: bug#25365: 25.1; Coding system for bookmarks and desktop Date: Mon, 09 Jan 2017 22:07:49 +0500 Message-ID: <874m18yxei.fsf@gmail.com> References: <87mvf57kdx.fsf@gmail.com> <83pojzavhg.fsf@gnu.org> <87d1fxzy9d.fsf@gmail.com> <83k2a5blo9.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1483982568 660 195.159.176.226 (9 Jan 2017 17:22:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 9 Jan 2017 17:22:48 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 25365@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 09 18:22:45 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 1cQdeb-0007tJ-Sq for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Jan 2017 18:22:42 +0100 Original-Received: from localhost ([::1]:41516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQdeg-0001AB-6c for geb-bug-gnu-emacs@m.gmane.org; Mon, 09 Jan 2017 12:22:46 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQdQV-00054D-5f for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2017 12:08:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQdQQ-0007jH-Uy for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2017 12:08:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60827) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cQdQQ-0007j7-Qk for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2017 12:08:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cQdQQ-0000ay-Fq for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2017 12:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitri Paduchikh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Jan 2017 17:08: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.14839816792278 (code B ref 25365); Mon, 09 Jan 2017 17:08:02 +0000 Original-Received: (at 25365) by debbugs.gnu.org; 9 Jan 2017 17:07:59 +0000 Original-Received: from localhost ([127.0.0.1]:47993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQdQN-0000ag-JS for submit@debbugs.gnu.org; Mon, 09 Jan 2017 12:07:59 -0500 Original-Received: from mail-lf0-f66.google.com ([209.85.215.66]:35958) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQdQL-0000aR-6Q for 25365@debbugs.gnu.org; Mon, 09 Jan 2017 12:07:57 -0500 Original-Received: by mail-lf0-f66.google.com with SMTP id j75so12349232lfe.3 for <25365@debbugs.gnu.org>; Mon, 09 Jan 2017 09:07:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=iZbfVHr6C7N+m6s+tBBuZLwPdhkD80Bte4u7DlRnu/A=; b=Q0pK3P4oIyIXOVs7RN+QSfT2qLtebZh+yhzhwL4t4Y/N5Q4+FzOHPijD86zaRH8wJX GLFJ401U05WcD34eZKYpVsfqF8Tl8CIEIutolVHyJRlgGeWgcplL4b1xkNl70R+Zpv7v tPJmK4GJcu31VPc6UQzrgUWjcVlN4yyrRXQvHak4L+q1xgUy/N0Jnc2JRlcS22yMcfce aOJJKk1YwK5XP2F0jXGfas5lOLJf1yu12JCVViuQsDtiXSFYp1ASW4CIrqzA0sfQC7m8 mdDLKsycg5H8hIrhwejXrMpagYlM1zs+1JQpvxDZtvhyH/HVsulpS0xLDyoTSlAoKZbI q4Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=iZbfVHr6C7N+m6s+tBBuZLwPdhkD80Bte4u7DlRnu/A=; b=BMHwQKistnuA4O/Do/pDfgoeYbRP+hkOoU+sUaqQVSCzHAT5qFGw1Whn9/ZSqGUX35 2l4ELeT8de7bGIDuyelsCD5V5pD5XKGB+uD8EDJd5TICykROFlmXLDPeVVO10IeHXwCb tdyBt2etoQMS8s7bLneY55Od0fRllNj+W42ma9wp7yNjEkGsgZE+m4UYsNqF0iERFF8R TYyul2U/TrFobX2pxQ+vYk+evyWrBXfdOI8i3tu7MYGBBDf68H0piOZC9zm8sBYq16zT pSKVRuJNDON+nLCoNQfqNO+5fA9xmP1LhupAWMf5Pjj3evYHJpGE7P2nM/mrD5Fl8sp9 6/Og== X-Gm-Message-State: AIkVDXI/BCW0DTicLdygG/864GXbUU5yqjKSixWbMoLAcF8AcasjP+n0OMEWHrwntmRizg== X-Received: by 10.25.24.156 with SMTP id 28mr24493303lfy.162.1483981671261; Mon, 09 Jan 2017 09:07:51 -0800 (PST) Original-Received: from gmail.com ([46.48.49.226]) by smtp.gmail.com with ESMTPSA id a71sm1210334lfe.36.2017.01.09.09.07.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2017 09:07:50 -0800 (PST) In-Reply-To: <83k2a5blo9.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 08 Jan 2017 17:45:10 +0200") 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:127937 Archived-At: Eli Zaretskii 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