From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitri Paduchikh Newsgroups: gmane.emacs.devel Subject: Re: bug#25365: 25.1; Coding system for bookmarks and desktop Date: Sun, 08 Jan 2017 14:39:26 +0500 Message-ID: <87d1fxzy9d.fsf@gmail.com> References: <87mvf57kdx.fsf@gmail.com> <83pojzavhg.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1483868426 22380 195.159.176.226 (8 Jan 2017 09:40:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 8 Jan 2017 09:40:26 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 08 10:40:19 2017 Return-path: Envelope-to: ged-emacs-devel@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 1cQ9xS-0003wM-Av for ged-emacs-devel@m.gmane.org; Sun, 08 Jan 2017 10:40:10 +0100 Original-Received: from localhost ([::1]:60829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQ9xW-0005wC-IC for ged-emacs-devel@m.gmane.org; Sun, 08 Jan 2017 04:40:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQ9wv-0005w4-0n for emacs-devel@gnu.org; Sun, 08 Jan 2017 04:39:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQ9wt-0002bU-Qa for emacs-devel@gnu.org; Sun, 08 Jan 2017 04:39:37 -0500 Original-Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]:33986) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cQ9wp-0002YX-TT; Sun, 08 Jan 2017 04:39:32 -0500 Original-Received: by mail-lf0-x22d.google.com with SMTP id v186so24069505lfa.1; Sun, 08 Jan 2017 01:39:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:message-id:user-agent :mime-version:content-transfer-encoding; bh=avdOsYskrXuP19IGaHP3a0RrxtYtDdywxumk095fzqQ=; b=VDWm0qd6SsKcFNkRGViC3aChHqHuTGP0M4hIf4GPsaJ4VTjnDKnJ7I3nY/AQ1O57Iw 0CPDPatm/3IYaHE1Q84e3ZwK8KrI2jS+snhZABx8UTLXd3rIPokahnAZ/dRlqf6IfqcZ H9kiRCIboBQsNW4mZkQGs9IsXykbDQ9Kh4C/ve58Hv3UMboQlQGGkDsusnlYOLcBpYBY YXbKwcwU0+g9eWAfuNMJAkgSJlAhT8rzRDUdu3ECDWSNXpbvDq3k7iMziML/tatUsCD2 cKAmUdn3UK0m2+26R+hP5EkASQa/j5tN+Rg2i0kaJBkN6aFfiKL7zTrxSC3svZNxu2Uq thjw== 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:message-id :user-agent:mime-version:content-transfer-encoding; bh=avdOsYskrXuP19IGaHP3a0RrxtYtDdywxumk095fzqQ=; b=A7SVhuXIdpb1DylsXHi8xnuCuRK75IlQXiFp5JItFZowQAV+P01mAypdGNMWdw6PqK zdPBcOz1+blprgnpILdMjKWUaTXZ+MhdyorutacKTFX7dHeoYkEglxxRlGrE5j6GTBrm OWoM0LvcIslm5JiD0TgHeq7zpSG0oimmXYxuAKaAfkDaiiCjxyt3rYciRiJbNFVMQ2Ou s0FZnffGoD30smDJGxWWfZR8vEVmTl9XpY7wA6G6ejt+UgWMDPpDhKFNDkE4jzaAS7Hw KkrrSnZlyWD6ZJgckpLIU1IFWBXZUB0+ARNMuH8B7Da2MXhsOiNlRhwVZo0tOxuEyDIy qlxg== X-Gm-Message-State: AIkVDXLF75wpIdG+GntICmieLmK5Lnr7GEjTqtvyPMvaHIId1QBetnr8dOIAFEqNK+2U9w== X-Received: by 10.25.39.211 with SMTP id n202mr30033001lfn.90.1483868368526; Sun, 08 Jan 2017 01:39:28 -0800 (PST) Original-Received: from gmail.com ([46.48.49.226]) by smtp.gmail.com with ESMTPSA id 9sm20558465ljn.20.2017.01.08.01.39.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Jan 2017 01:39:27 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211161 Archived-At: Eli Zaretskii wrote: >> 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. Thank you for taking a look. As far as I understand bookmark.el may load bookmarks from several files. Using the coding system from last read file makes the choice of coding system for future write dependent on the order of bookmark load and thus difficult to keep track for user. Also setting coding system through coding-system-for-write will make non-encodable characters replaced by spaces. The safety check is being done somewhere else - I am not familiar with the exact details yet. Hopefully you have taken this into account. As I am concerned these complications are not needed at all. Encoding arbitrary data when writing a file (i.e. with utf-8-emacs) and specifying coding system in the file header for the data to be correctly decoded back - is all that is needed in my opinion. [...] > 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. Will check it out. Though I think that the situation will not repeat after I have fixed my configuration. >> 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. I am worried by its ability to encode arbitrary characters after switch to UTF-8. If there are such characters which emacs-mule does not encode they can be silently replaced by spaces upon writing of desktop data. PS. Not sure whether it makes sense to send messages to a closed bug, and so continuing in emacs-devel. With best regards Dmitri Paduchikh