From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Karl Fogel Newsgroups: gmane.emacs.devel Subject: Re: bug#15329: saveplace restores dired positions to random places Date: Thu, 12 Sep 2013 11:12:58 -0500 Message-ID: <8761u6ow6t.fsf@kwarm.red-bean.com> References: Reply-To: Karl Fogel NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1379002419 8818 80.91.229.3 (12 Sep 2013 16:13:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Sep 2013 16:13:39 +0000 (UTC) Cc: 15329@debbugs.gnu.org To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 12 18:13:41 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VK9WC-0006Fb-SM for ged-emacs-devel@m.gmane.org; Thu, 12 Sep 2013 18:13:20 +0200 Original-Received: from localhost ([::1]:42753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK9WC-0007ZA-BZ for ged-emacs-devel@m.gmane.org; Thu, 12 Sep 2013 12:13:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK9W1-0007Wl-R5 for emacs-devel@gnu.org; Thu, 12 Sep 2013 12:13:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VK9Vt-0002AS-E8 for emacs-devel@gnu.org; Thu, 12 Sep 2013 12:13:09 -0400 Original-Received: from mail-oa0-x235.google.com ([2607:f8b0:4003:c02::235]:65133) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK9Vt-0002AM-86 for emacs-devel@gnu.org; Thu, 12 Sep 2013 12:13:01 -0400 Original-Received: by mail-oa0-f53.google.com with SMTP id k18so13968oag.12 for ; Thu, 12 Sep 2013 09:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:references:references :reply-to:date:message-id:user-agent:mime-version:content-type; bh=qs+BGgrAYpBNXFpxhdbpcLpmJ/SKaC55S5HOW0fi66A=; b=kQNGkKG7gBBceB8axprelQyUXl2ezDJWITnAQdi6AcYhC+lRcsHJUM8Qcf7poVJkev evtc5NndrLQ9vs83ehOQnXS7vQeZtmc1dzdaLDS6uhc+7rdyuOvR5/f+6eYsWzyjQV6o C6MfcVZ0ktdJADD4KdvudKOhj03c5a0pWibixUFsY2+jq+/ANmLJCvTCh5xgABGWsE7A oULDMcVcNBwHz/5YUgg51DLpv+pRDM7TnMyfZSZYhoOsBOClEXO7UHupXT//nM9zwd08 jilunJWfeJobwMyM5KOR5i6Osh7HG/bR4Hvv2hLvztIsI0hs2qx8kasU3RK8ApMNY0d4 8ulg== X-Received: by 10.60.116.170 with SMTP id jx10mr1146781oeb.98.1379002380679; Thu, 12 Sep 2013 09:13:00 -0700 (PDT) Original-Received: from kwarm.red-bean.com (74-92-190-113-Illinois.hfc.comcastbusiness.net. [74.92.190.113]) by mx.google.com with ESMTPSA id tz10sm6455847obc.10.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 12 Sep 2013 09:13:00 -0700 (PDT) In-Reply-To: <87mwnj1414.fsf@mail.jurta.org> Original-References: <87mwnj1414.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c02::235 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:163314 Archived-At: Juri Linkov wrote: >> An obvious solution to this problem is to save the >> current file name in Dired instead of its point. >> >> It seems saving information other than point doesn't contradict >> the purpose of saveplace.el that automatically saves places where >> visiting them later automatically moves point to the saved position. >> Also elements of `save-place-alist' are (FILENAME . POSITION), >> not more limited (FILENAME . POINT). So saving a string to >> POSITION would be consistent with the design of saveplace.el. > >I realized this is not backward-compatible change, i.e. >older Emacs versions won't be able to read saved places >in the new format. Unfortunately, Dired filename positions >can't be added to the current format that uses an alist >with cons pair cells. I mean (FILENAME . POINT) >can't be changed to (FILENAME POINT DIRED-FILENAME-POSITION) >because older Emacs versions will fail to read them. > >The only solution that I see is to save two alists to the places file: > >((FILENAME1 . POINT1) > (FILENAME2 . POINT2) > ...) >((FILENAME1 DIRED-FILENAME-POSITION1) > (FILENAME2 DIRED-FILENAME-POSITION2) > ...) > >Then the current code: > > (with-demoted-errors > (car (read-from-string > (buffer-substring (point-min) (point-max))))) > >will read the first alist without problems, >and additional code in newer versions like > > (with-demoted-errors > (cadr (read-from-string > (buffer-substring (point-min) (point-max))))) > >will read the second alist with more information >about the context of saved places (like bookmarks). Well, rather, we could use that as an upgrade strategy for the saveplace format as a whole. In other words, starting now and for a few versions of Emacs into the future, write the old format to the first part of the file, and then a more flexible new format to the second part. The modern format would have a more extensible structure, similarly to how bookmark.el does it. Say, a sublist whose first element is the type of the record, and the rest of which is the data for that record. Like: ((FILE_OR_DIR_NAME_1 ('position (position information goes here))) (FILE_OR_DIR_NAME_2 ('dired-position (different kind of information))) ...) etc. Thoughts? -Karl