From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#15329: saveplace restores dired positions to random places Date: Wed, 11 Sep 2013 23:45:11 +0300 Organization: JURTA Message-ID: <87mwnj1414.fsf__38253.0904295438$1378932505$gmane$org@mail.jurta.org> References: <87r4cwjy50.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1378932497 30670 80.91.229.3 (11 Sep 2013 20:48:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Sep 2013 20:48:17 +0000 (UTC) Cc: emacs-devel@gnu.org To: 15329@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 11 22:48:18 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 1VJrKj-0006de-9f for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Sep 2013 22:48:17 +0200 Original-Received: from localhost ([::1]:37839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJrKi-0002EK-W5 for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Sep 2013 16:48:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJrKa-0002CS-Ka for bug-gnu-emacs@gnu.org; Wed, 11 Sep 2013 16:48:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJrKU-0005dS-Lo for bug-gnu-emacs@gnu.org; Wed, 11 Sep 2013 16:48:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48329) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJrKU-0005dO-I9 for bug-gnu-emacs@gnu.org; Wed, 11 Sep 2013 16:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VJrKU-0005HZ-5O for bug-gnu-emacs@gnu.org; Wed, 11 Sep 2013 16:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Sep 2013 20:48:02 +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.137893244820254 (code B ref 15329); Wed, 11 Sep 2013 20:48:02 +0000 Original-Received: (at 15329) by debbugs.gnu.org; 11 Sep 2013 20:47:28 +0000 Original-Received: from localhost ([127.0.0.1]:56622 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VJrJv-0005Gb-FB for submit@debbugs.gnu.org; Wed, 11 Sep 2013 16:47:27 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:40894 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VJrJs-0005GQ-Fk for 15329@debbugs.gnu.org; Wed, 11 Sep 2013 16:47:25 -0400 Original-Received: from localhost.jurta.org (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 8CFCD258B9E935; Wed, 11 Sep 2013 13:47:22 -0700 (PDT) In-Reply-To: <87r4cwjy50.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 10 Sep 2013 23:45:15 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) 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:78247 Archived-At: > Remembering dired positions is a good feature, but > unfortunately in its current implementation is useless. > > The problem is that often the position of point in Dired > is restored to random places because in Dired buffers > it depends on many irrelevant ever-changing factors > such as the total size of all files in the directory > and available space (thus the line with this information > changes its length), sizes of each file above the restored > file in the Dired buffer also accounts to the incorrect position > of point, also added/deleted files in Dired change the restored > position to random places, different sorting order, etc. > > 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).