unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: 15329@debbugs.gnu.org
Cc: emacs-devel@gnu.org
Subject: bug#15329: saveplace restores dired positions to random places
Date: Wed, 11 Sep 2013 23:45:11 +0300	[thread overview]
Message-ID: <87mwnj1414.fsf__38253.0904295438$1378932505$gmane$org@mail.jurta.org> (raw)
In-Reply-To: <87r4cwjy50.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 10 Sep 2013 23:45:15 +0300")

> 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).





  reply	other threads:[~2013-09-11 20:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-10 20:45 bug#15329: saveplace restores dired positions to random places Juri Linkov
2013-09-11 20:45 ` Juri Linkov [this message]
     [not found] <mailman.247.1379001674.12311.emacs-devel@gnu.org>
     [not found] ` <87mwnj1414.fsf@mail.jurta.org>
2013-09-12 16:12   ` Karl Fogel
     [not found]   ` <8761u6ow6t.fsf@kwarm.red-bean.com>
2013-09-12 19:13     ` Stefan Monnier
2013-09-12 20:52     ` Juri Linkov
     [not found]     ` <87d2odvk36.fsf@mail.jurta.org>
2013-10-03 21:37       ` Karl Fogel
     [not found]       ` <87hacy829m.fsf@floss.red-bean.com>
2013-12-15 20:20         ` Juri Linkov
2013-12-15 21:43           ` Drew Adams
2013-12-16 20:58             ` Juri Linkov
2013-12-16 21:15               ` Drew Adams
2013-12-20 20:20           ` Juri Linkov
2013-12-21  2:09             ` Karl Fogel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='87mwnj1414.fsf__38253.0904295438$1378932505$gmane$org@mail.jurta.org' \
    --to=juri@jurta.org \
    --cc=15329@debbugs.gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).