From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Karl Fogel Newsgroups: gmane.emacs.bugs Subject: bug#15329: saveplace restores dired positions to random places Date: Thu, 12 Sep 2013 11:12:58 -0500 Message-ID: <8761u6ow6t.fsf__44995.2806150124$1379002489$gmane$org@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 1379002480 9878 80.91.229.3 (12 Sep 2013 16:14:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Sep 2013 16:14:40 +0000 (UTC) Cc: 15329@debbugs.gnu.org To: emacs-devel@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 12 18:14:42 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1VK9XA-0007P2-Lw for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Sep 2013 18:14:20 +0200 Original-Received: from localhost ([::1]:42774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK9XA-0008FS-7I for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Sep 2013 12:14:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK9Wz-0008Ez-Vy for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2013 12:14:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VK9Ws-0002Md-HY for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2013 12:14:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50936) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK9Ws-0002MZ-Dd for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2013 12:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VK9Wr-0003gV-Pw for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2013 12:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Karl Fogel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Sep 2013 16:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15329 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 15329-submit@debbugs.gnu.org id=B15329.137900238814089 (code B ref 15329); Thu, 12 Sep 2013 16:14:01 +0000 Original-Received: (at 15329) by debbugs.gnu.org; 12 Sep 2013 16:13:08 +0000 Original-Received: from localhost ([127.0.0.1]:59229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VK9W0-0003fA-7E for submit@debbugs.gnu.org; Thu, 12 Sep 2013 12:13:08 -0400 Original-Received: from mail-oa0-f48.google.com ([209.85.219.48]:42294) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VK9Vy-0003eg-H3 for 15329@debbugs.gnu.org; Thu, 12 Sep 2013 12:13:07 -0400 Original-Received: by mail-oa0-f48.google.com with SMTP id o17so14923oag.7 for <15329@debbugs.gnu.org>; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:78291 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