From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Spiers Subject: Re: strange behaviour when customising org-agenda-custom-commands Date: Sun, 30 Dec 2007 21:32:55 +0000 Message-ID: <20071230213255.GH20947@atlantic.linksys.moosehall> References: <20071208183046.GC15129@atlantic.linksys.moosehall> <20071210112539.GH15129@atlantic.linksys.moosehall> <20071217140115.GF13112@atlantic.linksys.moosehall> <20071108005556.GU13544@atlantic.linksys.moosehall> <20071208183046.GC15129@atlantic.linksys.moosehall> <20071210112539.GH15129@atlantic.linksys.moosehall> <20071230194707.GG20947@atlantic.linksys.moosehall> Reply-To: Adam Spiers Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J95mE-00075m-T0 for emacs-orgmode@gnu.org; Sun, 30 Dec 2007 16:32:58 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J95mE-000758-Ao for emacs-orgmode@gnu.org; Sun, 30 Dec 2007 16:32:58 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J95mE-00074t-4V for emacs-orgmode@gnu.org; Sun, 30 Dec 2007 16:32:58 -0500 Received: from mail.beimborn.com ([70.84.38.100]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J95mD-00018A-OM for emacs-orgmode@gnu.org; Sun, 30 Dec 2007 16:32:57 -0500 Received: from mail.beimborn.com (localhost.localdomain [127.0.0.1]) by mail.beimborn.com (8.12.11.20060308/8.12.8) with ESMTP id lBULWu03023944 for ; Sun, 30 Dec 2007 15:32:56 -0600 Received: from localhost (localhost [[UNIX: localhost]]) by mail.beimborn.com (8.12.11.20060308/8.12.11/Submit) id lBULWup9023938 for emacs-orgmode@gnu.org; Sun, 30 Dec 2007 21:32:56 GMT Content-Disposition: inline In-Reply-To: <20071230194707.GG20947@atlantic.linksys.moosehall> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Adam Spiers (orgmode@adamspiers.org) wrote: > Adam Spiers wrote: > > On Mon, Dec 17, 2007 at 01:49:49PM +0100, Carsten Dominik wrote: > > > On Dec 10, 2007 12:25 PM, Adam Spiers wrote: > > > > On Sat, Dec 08, 2007 at 06:30:46PM +0000, Adam Spiers wrote: > > > > > On Tue, Nov 13, 2007 at 12:38:06PM +0100, Carsten Dominik wrote: > > > > > > On 8Nov2007, at 1:55 AM, Adam Spiers wrote: > > > > > > > I haven't figured out how to reproduce this reliably yet, but there > > > > > > > seems to be a bug in 5.13h where when customizing > > > > > > > org-agenda-custom-commands, sometimes during a Set or Save (not sure > > > > > > > which) all the prefix key documentation entries vanish. Any ideas why > > > > > > > this would happen? [snipped] > Argh, it just happened again with 5.17a! And it was definitely only > (and all) the prefix key documentation entries which vanished, such as > > ("#" . "TODOs by priority") > > Additionally I have been most careful to regularly save customizations > since the discussion above, so I'm now sure that there is a bug > somewhere after all; I just don't know how to trigger it. Is the > defcustom definition for prefix key documentation definitely correct? I just cracked it :-) I noticed that the prefix key documentation cons cells only vanished when the *Customize Option: Org Agenda Custom Commands* buffer was generated via M-x org-agenda C and never via M-x customize-option. So that led me to the culprit: (defun org-agenda (arg &optional keys restriction) [...] (let* ((prefix-descriptions nil) (org-agenda-custom-commands ;; normalize different versions (delq nil (mapcar (lambda (x) (cond ((stringp (cdr x)) (push x prefix-descriptions) nil) ((stringp (nth 1 x)) x) ((not (nth 1 x)) (cons (car x) (cons "" (cddr x)))) (t (cons (car x) (cons "" (cdr x)))))) org-agenda-custom-commands))) So that when customize-variable is invoked later on in the same function: ((equal keys "C") (customize-variable 'org-agenda-custom-commands)) it is done within the scope of the local value of org-agenda-custom-commands which has the prefix-descriptions stripped out by the above code. Here is a workaround, but it's very ugly since it overrides the local scope with another value. No doubt Carsten will come up with a cleaner fix - perhaps assigning the first "stripped" value to a different symbol name such as `org-agenda-custom-commands-normalized' would work? http://www.adamspiers.org/cgi-bin/hg.cgi/org-atlantic/rev/0e3d335dbc2c # HG changeset patch # User Adam Spiers # Date 1199050134 0 # Node ID 0e3d335dbc2c1c388a63702e2d59e550a0e52383 # Parent 8b97b436208cd3b766f2323e392945984ddf0cc7 stop org-agenda losing prefix descriptions from org-agenda-custom-commands diff -r 8b97b436208c -r 0e3d335dbc2c org.el --- a/org.el Sun Dec 30 19:29:52 2007 +0000 +++ b/org.el Sun Dec 30 21:28:54 2007 +0000 @@ -19170,7 +19170,10 @@ Pressing `<' twice means to restrict to (org-let lprops '(funcall type match))) (t (error "Invalid custom agenda command type %s" type)))) (org-run-agenda-series (nth 1 entry) (cddr entry)))) - ((equal keys "C") (customize-variable 'org-agenda-custom-commands)) + ((equal keys "C") + (let ((org-agenda-custom-commands + (append prefix-descriptions org-agenda-custom-commands))) + (customize-variable 'org-agenda-custom-commands))) ((equal keys "a") (call-interactively 'org-agenda-list)) ((equal keys "t") (call-interactively 'org-todo-list)) ((equal keys "T") (org-call-with-arg 'org-todo-list (or arg '(4))))