From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.emacs.bugs Subject: bug#13882: 24.2; saveplace.el limit drop least recently used Date: Wed, 06 Mar 2013 07:49:14 +1100 Message-ID: <87ip55608l.fsf@blah.blah> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1362516704 5203 80.91.229.3 (5 Mar 2013 20:51:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Mar 2013 20:51:44 +0000 (UTC) To: 13882@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 05 21:52:08 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 1UCyqF-00029C-EK for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Mar 2013 21:52:07 +0100 Original-Received: from localhost ([::1]:44578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCypt-0000pC-WB for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Mar 2013 15:51:46 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCypq-0000oz-8a for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2013 15:51:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCypo-0006mV-Uu for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2013 15:51:42 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCypo-0006mR-RY for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2013 15:51:40 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UCyqA-0004TD-2j for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2013 15:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Kevin Ryde Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Mar 2013 20:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13882 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.136251666517114 (code B ref -1); Tue, 05 Mar 2013 20:52:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Mar 2013 20:51:05 +0000 Original-Received: from localhost ([127.0.0.1]:33039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UCypB-0004Rf-2C for submit@debbugs.gnu.org; Tue, 05 Mar 2013 15:51:04 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49589) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UCyp2-0004RJ-C0 for submit@debbugs.gnu.org; Tue, 05 Mar 2013 15:50:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCyoZ-0006WZ-GT for submit@debbugs.gnu.org; Tue, 05 Mar 2013 15:50:25 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:53122) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCyoZ-0006WV-De for submit@debbugs.gnu.org; Tue, 05 Mar 2013 15:50:23 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:60918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCyoW-0000Dq-K9 for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2013 15:50:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCyoN-0006TR-5H for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2013 15:50:20 -0500 Original-Received: from mailout1-15.pacific.net.au ([125.255.80.134]:45483 helo=mailout3-syd3.pacific.net.au) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCyoM-0006S3-JF for bug-gnu-emacs@gnu.org; Tue, 05 Mar 2013 15:50:11 -0500 Original-Received: from mailproxy3-syd3.pacific.net.au (mailproxy3-syd3.pacific.net.au [61.8.2.164]) by mailout3-syd3.pacific.net.au (Postfix) with ESMTP id 3954C37F7FC for ; Wed, 6 Mar 2013 07:50:03 +1100 (EST) Original-Received: from blah.blah (unknown [203.26.175.129]) by mailproxy3-syd3.pacific.net.au (Postfix) with ESMTP id D185D578085 for ; Wed, 6 Mar 2013 07:49:30 +1100 (EST) Original-Received: from gg by blah.blah with local (Exim 4.80) (envelope-from ) id 1UCynS-0003bT-N8 for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 07:49:14 +1100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.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:72133 Archived-At: --=-=-= Content-Type: text/plain 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 * 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. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=init.el Content-Transfer-Encoding: quoted-printable (setq-default save-place t) (setq save-place-limit 2) (require 'saveplace) --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=foo.el Content-Transfer-Encoding: quoted-printable (progn (find-file "/tmp/aa") (insert "aa\n") (save-buffer) (kill-buffer) (find-file "/tmp/bb") (insert "bb\n") (save-buffer) (kill-buffer) (find-file "/tmp/cc") (insert "cc\n") (save-buffer) (kill-buffer) (kill-emacs)) --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=saveplace.el.nosort.diff --- 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 --=-=-= Content-Type: text/plain 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 --=-=-=--