From unknown Thu Aug 14 12:25:29 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#25365 <25365@debbugs.gnu.org> To: bug#25365 <25365@debbugs.gnu.org> Subject: Status: 25.1; Coding system for bookmarks and desktop Reply-To: bug#25365 <25365@debbugs.gnu.org> Date: Thu, 14 Aug 2025 19:25:29 +0000 retitle 25365 25.1; Coding system for bookmarks and desktop reassign 25365 emacs submitter 25365 Dmitri Paduchikh severity 25365 minor thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 05 07:37:50 2017 Received: (at submit) by debbugs.gnu.org; 5 Jan 2017 12:37:50 +0000 Received: from localhost ([127.0.0.1]:41801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cP7Ik-00034o-7F for submit@debbugs.gnu.org; Thu, 05 Jan 2017 07:37:50 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35395) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cP7Ii-00034a-MJ for submit@debbugs.gnu.org; Thu, 05 Jan 2017 07:37:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cP7Ic-00070e-KL for submit@debbugs.gnu.org; Thu, 05 Jan 2017 07:37:43 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:58479) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cP7Ic-00070Z-HC for submit@debbugs.gnu.org; Thu, 05 Jan 2017 07:37:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cP7Ib-0006wT-DE for bug-gnu-emacs@gnu.org; Thu, 05 Jan 2017 07:37:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cP7IW-0006zL-Fh for bug-gnu-emacs@gnu.org; Thu, 05 Jan 2017 07:37:41 -0500 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]:35530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cP7IW-0006yw-7s for bug-gnu-emacs@gnu.org; Thu, 05 Jan 2017 07:37:36 -0500 Received: by mail-lf0-x22b.google.com with SMTP id m78so12617106lfg.2 for ; Thu, 05 Jan 2017 04:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version :content-transfer-encoding; bh=hBFO6f7Vwubr/G8zENDQYj3yrLwyojL8mdHMdFysPrc=; b=OYelozLkk68IyiK7uW1mNWO+YTb779nQhPUyNcNZfiv9QdzCEM0n2h/nMleauEknlr u0dx6dSGEK24vUHy8LgmPF80dTnEjjntexT5ZNTes91BiGRKt1vYPg+xq75XrdizbZtX sbmaWF8fTJQUURLrmPkLpB75s9Vk7aTKhNc3KOQZi4Pd+LVZ3qXJp+tL8dfhgxl3msxk 8ykrNhVyCTYteTFx/WgTkUFi8GKMbj5PEF6sRTkq7i+EkNGOauBo9iagpVv8skg01pps r70/LEjOZwpuRI8huTKd7RLqpCyrMgffP8QXabRXhfBEHUs7uWkcXjTKxLGuPNcm1/74 iSKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-transfer-encoding; bh=hBFO6f7Vwubr/G8zENDQYj3yrLwyojL8mdHMdFysPrc=; b=S9c1jxtv+pvnvXppKjZEahtR4sD91Q1hIBaJgKZoVzw6iCzyRrVNjQ6iuN5qyVW8fG X5yiuOw3B1CKcQpR9J4asYINSPlEw0fYNzpUdKJ10458kiyQ7PGmvETZg+8f2ZGudffu JlQyqHnFEo3da5zadTGEiXwJIPM0219LxKptsBNrvTTDoCp5DgW6b7bj5u1SXbbEBMdC KSUt1Avop3VI4ssZ3KkpIX12rZhLeGeoUjFNbXiOUagP9pcSuQffoyD2bX3Uw7ZiVKB9 M3BEr7085IoFIsQDnCIiY+Nt30xAad2HugTutj+5BZWfYNjeOILhO4BfvUXyYoZBATxP nWcg== X-Gm-Message-State: AIkVDXKLHfP7hK4syF1RtkeRlOPPOBreWpZO/EcVNe/66XrCFGAu4sVzkMK6s+fcYkICIA== X-Received: by 10.25.56.65 with SMTP id d1mr24075510lfj.171.1483619852794; Thu, 05 Jan 2017 04:37:32 -0800 (PST) Received: from gmail.com ([46.48.49.226]) by smtp.gmail.com with ESMTPSA id h15sm1419900ljb.46.2017.01.05.04.37.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jan 2017 04:37:31 -0800 (PST) From: Dmitri Paduchikh To: bug-gnu-emacs@gnu.org Subject: 25.1; Coding system for bookmarks and desktop Date: Thu, 05 Jan 2017 17:37:30 +0500 Message-ID: <87mvf57kdx.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hello, It appears that all Cyrillic text in my bookmarks file has been corrupted. I wasn't able to reproduce such a corruption using emacsš-Q, so probably this is due to interference with my settings which I will have to investigate. But in my opinion there is a problem with bookmark.el as well since it ignores completely coding system when saving bookmarks. Thus I have written the following two advices to fix its behavior. It seems that they work as needed. (advice-add 'bookmark-write-file :around #'(lambda (f &rest args) (let ((coding-system-for-write (or coding-system-for-write 'utf-8-emacs))) (apply f args))) '((name . "coding"))) (advice-add 'bookmark-insert-file-format-version-stamp :before #'(lambda (&rest args) (when coding-system-for-write (insert (format "\ ;;;; Emacs Bookmark Format Version %d ;;;; ;;; -*- coding: %S -*-\n" bookmark-file-format-version coding-system-for-write)))) '((name . "coding"))) Besides, although desktop.el specifies coding system in its file, it is old one - emacs-mule. Shouldn't this be utf-8-emacs these days instead? With best regards Dmitri Paduchikh In GNU Emacs 25.1.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.5) of 2016-12-23 built on juergen From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 06 09:56:36 2017 Received: (at 25365) by debbugs.gnu.org; 6 Jan 2017 14:56:36 +0000 Received: from localhost ([127.0.0.1]:45248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPVwa-0004m6-Mb for submit@debbugs.gnu.org; Fri, 06 Jan 2017 09:56:36 -0500 Received: from mail-lf0-f48.google.com ([209.85.215.48]:35247) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPVwZ-0004lq-C9 for 25365@debbugs.gnu.org; Fri, 06 Jan 2017 09:56:35 -0500 Received: by mail-lf0-f48.google.com with SMTP id m78so34054604lfg.2 for <25365@debbugs.gnu.org>; Fri, 06 Jan 2017 06:56:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=041mTKfzAdwx41eTafOI/abWoAIvTKpqzbbmihx+gGU=; b=lsIg9xSd18VOO0SMqZyoxdnGk7UgPkvFNWGgMYzf3Xi3pj2MJ/LnyARgrEZwv+8WZS YNnsT6SO+noHHlZ6DlsvmlpkbSnH1eUoAhHNhBxqCx4RkF0n1ALj9+Zh4eKGdVIpZ9qP 3wEfPXlnfFIQz14zcC8KHwZqo641iNZ8Thx4PG7pAC8/1lnDoZ+aFZ0zYx9MbnRin+FV kFQm6YB48l2fzBH44ivZqOvq2uVNeh9hIwQM8pKKJv05xD6XV5p8qvCVsei1LG+Z2HKF HV6UYi1m2wBybJMuw+O+4DScYYQenPn+Pj6XQcy3EjNbqqfcfDS+YJFEtEEDTuNUsBF2 VJ3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=041mTKfzAdwx41eTafOI/abWoAIvTKpqzbbmihx+gGU=; b=hfdQS5T5X1Bc6FdJajscin8pAqEC1Jk9rNG3D2/f8NtjzVLu+QB92xLBRKL0sd+7ea 5NmsHwUzD+IqYgEkdIsyZSF8fRZHLcN8TjlVXLkxAhZXUjVW5X2o6+3iSifvSB3zR67K V9oCD8dSQZ/L4Xldwu+PvVtDLREnMm2vRy/VXV6eQjHZhaDHYd0wz25eWNNUrMAXxjDw ZjbaZeBK5IzTJkebD13IZQVdGXoNXCQyBBVuWtSFktJ/tj+e8TaDYUlh64HCSDEOKxhZ hdO8n2CYFSj3hoLF5Ad/T/wEmH2jdh3bZElZ4s2JvH/DxkvzlmzSt2z3fmutkm6/JPhq uzpw== X-Gm-Message-State: AIkVDXKBAi7szICzvmIzs8FrGuw1TdcYuovA6T+ido4CZ1v7LyzEZvyVlBrSqyLD+oYsoQ== X-Received: by 10.46.83.77 with SMTP id t13mr773958ljd.20.1483714589117; Fri, 06 Jan 2017 06:56:29 -0800 (PST) Received: from gmail.com ([46.48.49.226]) by smtp.gmail.com with ESMTPSA id t16sm1738459ljd.18.2017.01.06.06.56.27 for <25365@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Jan 2017 06:56:27 -0800 (PST) From: Dmitri Paduchikh To: 25365@debbugs.gnu.org Subject: Re: bug#25365: 25.1; Coding system for bookmarks and desktop References: <87mvf57kdx.fsf@gmail.com> Date: Fri, 06 Jan 2017 19:56:27 +0500 In-Reply-To: <87mvf57kdx.fsf@gmail.com> (Dmitri Paduchikh's message of "Thu, 05 Jan 2017 17:37:30 +0500") Message-ID: <87o9zkz17o.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 25365 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Indeed, the corruption was due to bit rot in my configuration. Still I think that it is safer to specify coding system explicitly when saving bookmarks. With best regards Dmitri Paduchikh From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 07 07:46:10 2017 Received: (at 25365-done) by debbugs.gnu.org; 7 Jan 2017 12:46:10 +0000 Received: from localhost ([127.0.0.1]:45704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPqNu-0002UX-0h for submit@debbugs.gnu.org; Sat, 07 Jan 2017 07:46:10 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46672) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPqNr-0002UC-UQ for 25365-done@debbugs.gnu.org; Sat, 07 Jan 2017 07:46:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPqNi-0008EW-He for 25365-done@debbugs.gnu.org; Sat, 07 Jan 2017 07:46:02 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46809) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPqNi-0008ES-DD; Sat, 07 Jan 2017 07:45:58 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2365 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cPqNh-0003Mh-NX; Sat, 07 Jan 2017 07:45:58 -0500 Date: Sat, 07 Jan 2017 14:46:19 +0200 Message-Id: <83pojzavhg.fsf@gnu.org> From: Eli Zaretskii To: Dmitri Paduchikh In-reply-to: <87mvf57kdx.fsf@gmail.com> (message from Dmitri Paduchikh on Thu, 05 Jan 2017 17:37:30 +0500) Subject: Re: bug#25365: 25.1; Coding system for bookmarks and desktop References: <87mvf57kdx.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -8.2 (--------) X-Debbugs-Envelope-To: 25365-done Cc: 25365-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -8.2 (--------) > From: Dmitri Paduchikh > Date: Thu, 05 Jan 2017 17:37:30 +0500 > > It appears that all Cyrillic text in my bookmarks file has been > corrupted. I wasn't able to reproduce such a corruption using emacsš-Q, > so probably this is due to interference with my settings which I will > have to investigate. But in my opinion there is a problem with > bookmark.el as well since it ignores completely coding system when > saving bookmarks. Thus I have written the following two advices to fix > its behavior. It seems that they work as needed. > > (advice-add 'bookmark-write-file :around > #'(lambda (f &rest args) > (let ((coding-system-for-write (or coding-system-for-write 'utf-8-emacs))) > (apply f args))) > '((name . "coding"))) Thanks, I used something similar in the patch below, except that I think we should honor the existing coding cookie in the bookmark file, instead of forcing the user to override the default each time the file is saved. So we should record the encoding when we load the file, and apply it when saving. This way, the user could specify the non-default encoding only once, using "C-x RET c", and have that value honored by Emacs thereafter. > (advice-add 'bookmark-insert-file-format-version-stamp :before > #'(lambda (&rest args) > (when coding-system-for-write > (insert (format "\ > ;;;; Emacs Bookmark Format Version %d ;;;; > ;;; -*- coding: %S -*-\n" > bookmark-file-format-version > coding-system-for-write)))) > '((name . "coding"))) This is not quite right, as coding-system-for-write could be something inappropriate, like undecided or prefer-utf-8. And again, we should honor the existing encoding. So I modified this part to support that. I installed the patch below on the master branch. Please try it (after removing your advices) and see if it gives good results. If you see problems, please reopen this bug with the details. Thanks. > Besides, although desktop.el specifies coding system in its file, it is > old one - emacs-mule. Shouldn't this be utf-8-emacs these days instead? I'm not sure how many users share the desktop files with older Emacs versions that didn't support utf-8-emacs. There's nothing wrong with using emacs-mule in recent Emacs versions, for files that aren't supposed to be read by programs that are not Emacs. commit e272032769178768cf970839a9c22aba1f5b572e Author: Eli Zaretskii Date: Sat Jan 7 14:33:41 2017 +0200 Specify encoding of the bookmark file * lisp/bookmark.el (bookmark-insert-file-format-version-stamp): Accept an argument CODING and include a 'coding:' cookie in the bookmark file preamble. (bookmark-upgrade-file-format-from-0): Call 'bookmark-insert-file-format-version-stamp' with the file buffer's encoding, as detected when it was read. (bookmark-file-coding-system): New variable. (bookmark-load): Set bookmark-file-coding-system to the encoding of the loaded file. (bookmark-write-file): Bind coding-system-for-write to either the user setting via "C-x RET c" or to the existing file encoding, defaulting to 'utf-8-emacs'. Update the value of bookmark-file-coding-system. (Bug#25365) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 3440a52..e18362b 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -267,6 +267,8 @@ bookmark-alist (defvar bookmarks-already-loaded nil "Non-nil if and only if bookmarks have been loaded from `bookmark-default-file'.") +(defvar bookmark-file-coding-system nil + "The coding-system of the last loaded or saved bookmark file.") ;; more stuff added by db. @@ -689,7 +691,7 @@ bookmark-upgrade-file-format-from-0 (let* ((old-list (bookmark-alist-from-buffer)) (new-list (bookmark-upgrade-version-0-alist old-list))) (delete-region (point-min) (point-max)) - (bookmark-insert-file-format-version-stamp) + (bookmark-insert-file-format-version-stamp buffer-file-coding-system) (pp new-list (current-buffer)) (save-buffer)) (goto-char (point-min)) @@ -726,11 +728,14 @@ bookmark-maybe-upgrade-file-format (error "Bookmark file format version strangeness"))))) -(defun bookmark-insert-file-format-version-stamp () - "Insert text indicating current version of bookmark file format." +(defun bookmark-insert-file-format-version-stamp (coding) + "Insert text indicating current version of bookmark file format. +CODING is the symbol of the coding-system in which the file is encoded." + (if (memq (coding-system-base coding) '(undecided prefer-utf-8)) + (setq coding 'utf-8-emacs)) (insert - (format ";;;; Emacs Bookmark Format Version %d ;;;;\n" - bookmark-file-format-version)) + (format ";;;; Emacs Bookmark Format Version %d ;;;; -*- coding: %S -*- \n" + bookmark-file-format-version (coding-system-base coding))) (insert ";;; This format is meant to be slightly human-readable;\n" ";;; nevertheless, you probably don't want to edit it.\n" ";;; " @@ -1417,14 +1422,17 @@ bookmark-write-file (with-current-buffer (get-buffer-create " *Bookmarks*") (goto-char (point-min)) (delete-region (point-min) (point-max)) - (let ((print-length nil) + (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)) - (bookmark-insert-file-format-version-stamp) + (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 @@ -1440,6 +1448,7 @@ bookmark-write-file (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))))) @@ -1521,7 +1530,8 @@ bookmark-load (expand-file-name bookmark-default-file)) file) (setq bookmarks-already-loaded t)) - (bookmark-bmenu-surreptitiously-rebuild-list)) + (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) From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 09 12:07:59 2017 Received: (at 25365) by debbugs.gnu.org; 9 Jan 2017 17:07:59 +0000 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 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 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) 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) From: Dmitri Paduchikh To: Eli Zaretskii Subject: Re: bug#25365: 25.1; Coding system for bookmarks and desktop References: <87mvf57kdx.fsf@gmail.com> <83pojzavhg.fsf@gnu.org> <87d1fxzy9d.fsf@gmail.com> <83k2a5blo9.fsf@gnu.org> Date: Mon, 09 Jan 2017 22:07:49 +0500 In-Reply-To: <83k2a5blo9.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 08 Jan 2017 17:45:10 +0200") Message-ID: <874m18yxei.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25365 Cc: 25365@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 09 13:49:48 2017 Received: (at 25365) by debbugs.gnu.org; 9 Jan 2017 18:49:48 +0000 Received: from localhost ([127.0.0.1]:48043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQf0u-00033U-Lf for submit@debbugs.gnu.org; Mon, 09 Jan 2017 13:49:48 -0500 Received: from eggs.gnu.org ([208.118.235.92]:58053) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQf0t-00033H-Mb for 25365@debbugs.gnu.org; Mon, 09 Jan 2017 13:49:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQf0l-0005gl-Bb for 25365@debbugs.gnu.org; Mon, 09 Jan 2017 13:49:42 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:47116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQf0l-0005gg-8K; Mon, 09 Jan 2017 13:49:39 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1431 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cQf0k-0000d0-GO; Mon, 09 Jan 2017 13:49:38 -0500 Date: Mon, 09 Jan 2017 20:49:35 +0200 Message-Id: <83eg0cdq68.fsf@gnu.org> From: Eli Zaretskii To: Dmitri Paduchikh In-reply-to: <874m18yxei.fsf@gmail.com> (message from Dmitri Paduchikh on Mon, 09 Jan 2017 22:07:49 +0500) Subject: Re: bug#25365: 25.1; Coding system for bookmarks and desktop References: <87mvf57kdx.fsf@gmail.com> <83pojzavhg.fsf@gnu.org> <87d1fxzy9d.fsf@gmail.com> <83k2a5blo9.fsf@gnu.org> <874m18yxei.fsf@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -8.2 (--------) X-Debbugs-Envelope-To: 25365 Cc: 25365@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -8.2 (--------) > From: Dmitri Paduchikh > Cc: 25365@debbugs.gnu.org > Date: Mon, 09 Jan 2017 22:07:49 +0500 > > 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. With the proposed patch, the fallback utf-8-emacs will happen silently, so the user will have no idea that her selected encoding was ignored, isn't it so? If so, I don't think it's a good idea to do that, when the user explicitly asks for a particular encoding. Come to think of that, I actually don't understand why anything is needed in addition to the current code: if the user-chosen encoding cannot safely encode the bookmark file, Emacs will refuse to save the file, and will insist on the user providing a safe encoding. E.g., set a bookmark in TUTORIAL.ru, and then try saving the bookmark file using the Latin-1 encoding. I just tried something like that, and the effect was exactly as I expected: Emacs requested me to provide another encoding. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 09 15:34:28 2017 Received: (at 25365) by debbugs.gnu.org; 9 Jan 2017 20:34:28 +0000 Received: from localhost ([127.0.0.1]:48102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQgeC-0005cS-HK for submit@debbugs.gnu.org; Mon, 09 Jan 2017 15:34:28 -0500 Received: from mail-lf0-f47.google.com ([209.85.215.47]:35054) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQgeB-0005cF-3c for 25365@debbugs.gnu.org; Mon, 09 Jan 2017 15:34:27 -0500 Received: by mail-lf0-f47.google.com with SMTP id m78so81009564lfg.2 for <25365@debbugs.gnu.org>; Mon, 09 Jan 2017 12:34:27 -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=v3wzDsg7WtNUnC2w5mZ3QFG6HB6LqhZEe9Wj/yH+dC4=; b=srgWl89pK5xCiA36RKKQbvLydYkQxmoctoJLhvmFbe/7L7OQAOi7ABIMknjyM+bIFa icKWdMQ9p4eRMoibkD0PLaqU7fWFDFLgDM4GiNUoD6j16LT3ed6E+facWtsmCStUwjfM XwqtCVboNioGlo5RzbtKZxJpPVIvJ7J/sPD0aqL4GRLwN/jxeX1BBe83mnbHUdBKhUk+ YaYJ8h2j9/P/ekkcpdcQ3RDh53GNveQYPT6JM7Fnkzt0Q5bBr0e0AgL26ilWcFbvyx1B 2ew4cH4OJEfnHLuFhG1CIwKscrRpeQ0RMJY8yM9iOWSJaMsEj7jHTQ8zd2iEwEJlA6gF PrZg== 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=v3wzDsg7WtNUnC2w5mZ3QFG6HB6LqhZEe9Wj/yH+dC4=; b=bJF0KCUoW+hPkHgTnjycvXc1bXdsxAjWvbvRRr0PJkbYX6QtK+enyIUxTikIwi2yKs +zPnYgPlxGGeqoEJY33ZIjm8J/l0daJ9ZgQ6bMxxeUTVojnJCXmTHNoXLbuvT7JDIsvd SfDN+oAHuer5SIqshhPLPUJaF/z9eD/5Bd7geE4HqVtCQx1dk/IS80wl+q+907Xz/Ktz dsgutM5cOeMRhM7eGSrIAkRgLJQZKeJdqLfjP62hDa3FHzmwO9fJfA+Rtdsq4voA4jKK bot8vfEbNPkrQmVrMmDSenrlE3ASsjIB+bk4dmSbcCssIx7HO9gwdKdQ+TxnwteMT0my y2RA== X-Gm-Message-State: AIkVDXJOiwuky5xHZHyjEeA+uEFpzt3LccbFeQj4KFLFryKMAzp4YHDg6pKBAwxWVGizeA== X-Received: by 10.25.157.146 with SMTP id g140mr1634678lfe.123.1483994061026; Mon, 09 Jan 2017 12:34:21 -0800 (PST) Received: from gmail.com ([46.48.49.226]) by smtp.gmail.com with ESMTPSA id b76sm21443720lfg.41.2017.01.09.12.34.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2017 12:34:19 -0800 (PST) From: Dmitri Paduchikh To: Eli Zaretskii Subject: Re: bug#25365: 25.1; Coding system for bookmarks and desktop 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> Date: Tue, 10 Jan 2017 01:34:18 +0500 In-Reply-To: <83eg0cdq68.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 09 Jan 2017 20:49:35 +0200") Message-ID: <87tw98x99x.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25365 Cc: 25365@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Eli Zaretskii wrote: >> From: Dmitri Paduchikh >> Cc: 25365@debbugs.gnu.org >> Date: Mon, 09 Jan 2017 22:07:49 +0500 >> >> 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. EZ> With the proposed patch, the fallback utf-8-emacs will happen EZ> silently, so the user will have no idea that her selected encoding was EZ> ignored, isn't it so? If so, I don't think it's a good idea to do EZ> that, when the user explicitly asks for a particular encoding. It is a choice between data loss (see below) and using another encoding. The former seems worse to me. EZ> Come to think of that, I actually don't understand why anything is EZ> needed in addition to the current code: if the user-chosen encoding EZ> cannot safely encode the bookmark file, Emacs will refuse to save the EZ> file, and will insist on the user providing a safe encoding. Only when user is specifying encoding through C-x RET c right now. Next time, when the encoding is chosen automatically this check won't be done. Try the following experiment: mark some non-ASCII character and evaluate this form by M-:. (let ((coding-system-for-write 'us-ascii)) (shell-command-on-region (region-beginning) (region-end) "od -A n -t x1")) The output is " 3f". I guess that exact choice of a replacement character depends on the coding system. 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. With best regards Dmitri Paduchikh From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 10 10:50:09 2017 Received: (at 25365) by debbugs.gnu.org; 10 Jan 2017 15:50:09 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 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 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 Date: Tue, 10 Jan 2017 17:49:57 +0200 Message-Id: <83a8ayewyi.fsf@gnu.org> From: Eli Zaretskii To: Dmitri Paduchikh In-reply-to: <87tw98x99x.fsf@gmail.com> (message from Dmitri Paduchikh on Tue, 10 Jan 2017 01:34:18 +0500) Subject: Re: bug#25365: 25.1; Coding system for bookmarks and desktop 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> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -8.2 (--------) X-Debbugs-Envelope-To: 25365 Cc: 25365@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -8.2 (--------) > 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) From unknown Thu Aug 14 12:25:29 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 08 Feb 2017 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator