From: Kevin Ryde <user42@zip.com.au>
To: 13882@debbugs.gnu.org
Subject: bug#13882: 24.2; saveplace.el limit drop least recently used
Date: Wed, 06 Mar 2013 07:49:14 +1100 [thread overview]
Message-ID: <87ip55608l.fsf@blah.blah> (raw)
[-- Attachment #1: Type: text/plain, Size: 2117 bytes --]
When saveplace.el reaches save-place-limit, the file positions retained
via ~/.emacs-places are the first limit-many in alphabetical order.
I hoped instead it would be the first limit-many most recently used.
Ie. drop the least recently visited files in order to enforce the limit.
I struck this when I reached my save-place-limit with lots of files I
had visited long ago but which happened to be alphabetically before ones
I was visiting now. The save-place feature no longer saved places
across sessions for files I now visited.
The effect can be seen by setting a small limit per init.el below. Then
foo.el to visit three files successively
HOME=`pwd` emacs -Q -l ./init.el -l ./foo.el
This leaves .emacs-places (in the current directory due to faked $HOME)
containing
(("/tmp/aa" . 4)
("/tmp/bb" . 4)
("/tmp/cc" . 4))
Notice /tmp/cc was the most recently visited file but it's at the end of
the list and will be truncated when load-save-place-alist-from-file
enforces save-place-limit of 2.
HOME=`pwd` emacs -Q -l ./init.el /tmp/cc
=>
point is at start of buffer /tmp/cc
I hoped it would be at the end from the last visit
Note that you must exit and restart emacs to see the effect, because
save-place-limit is only enforced by load-save-place-alist-from-file.
Within a session there's no limit, only in reading the .emacs-places
file on restarting emacs.
I get some joy from not sorting save-place-alist when saving per change
below.
I believe save-place-to-alist keeps save-place-alist in "most recent
first" order (by delq and re-push to move an existing entry to the
start), and that that order should be preserved when saving.
2013-03-04 Kevin Ryde <user42@zip.com.au>
* saveplace.el (save-place-alist-to-file): Don't `sort'
save-place-alist alphabetically, keep it in "most recent first" order.
This ensures save-place-limit drops the least recently visited files,
not the alphabetically last files. Dropping alphabetically last files
had meant save-place stopped working across sessions after
.emacs-places filled with alphabetically early names.
[-- Attachment #2: init.el --]
[-- Type: application/emacs-lisp, Size: 78 bytes --]
[-- Attachment #3: foo.el --]
[-- Type: application/emacs-lisp, Size: 265 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: saveplace.el.nosort.diff --]
[-- Type: text/x-diff, Size: 507 bytes --]
--- saveplace.el.orig 2013-03-04 17:06:20.000000000 +1100
+++ saveplace.el 2013-03-04 17:07:42.000000000 +1100
@@ -224,8 +224,7 @@
(symbol-name coding-system-for-write)))
(let ((print-length nil)
(print-level nil))
- (pp (sort save-place-alist
- (lambda (a b) (string< (car a) (car b))))
+ (pp save-place-alist ;; saved in order of most recently used
(current-buffer)))
(let ((version-control
(cond
[-- Attachment #5: Type: text/plain, Size: 1159 bytes --]
In GNU Emacs 24.2.1 (i486-pc-linux-gnu, GTK+ Version 2.24.10)
of 2012-09-10 on biber, modified by Debian
Configured using:
`configure '--build' 'i486-linux-gnu' '--build' 'i486-linux-gnu'
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
'--localstatedir=/var/lib' '--infodir=/usr/share/info'
'--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.2/site-lisp:/usr/share/emacs/site-lisp'
'--with-crt-dir=/usr/lib/i386-linux-gnu' '--with-x=yes'
'--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
'build_alias=i486-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
--param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
'CPPFLAGS=-D_FORTIFY_SOURCE=2''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_AU
value of $XMODIFIERS: nil
locale-coding-system: iso-latin-1-unix
default enable-multibyte-characters: t
next reply other threads:[~2013-03-05 20:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-05 20:49 Kevin Ryde [this message]
2013-03-07 15:32 ` bug#13882: 24.2; saveplace.el limit drop least recently used Dmitry Gutov
2013-03-07 21:20 ` Karl Fogel
2013-03-07 22:13 ` Dmitry Gutov
2013-03-10 0:57 ` Kevin Ryde
2013-03-10 22:09 ` Karl Fogel
2013-03-11 21:23 ` Kevin Ryde
2013-03-11 22:00 ` Karl Fogel
2013-03-11 22:08 ` Ian Dalton
2013-03-12 0:43 ` Kevin Ryde
2013-03-13 18:59 ` 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=87ip55608l.fsf@blah.blah \
--to=user42@zip.com.au \
--cc=13882@debbugs.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).