From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Docs submitted (Was Re: Advice sought on managing decision alternatives.) Date: Wed, 11 Feb 2009 18:38:49 -0500 Message-ID: <19798.1234395529@alphaville.usa.hp.com> References: <20090101170227.C707734803@mail2.panix.com> <1036.24.63.0.170.1233950825.squirrel@mail.panix.com> <60BDFE6D-6B8C-4A23-A737-67DC1F523C79@uva.nl> <1044.66.30.185.29.1234039592.squirrel@mail.panix.com> <6444D654-9B7B-415D-A6DB-F3BADCB1EE2A@uva.nl> <1451.24.63.21.131.1234124707.squirrel@mail.panix.com> <8BD25355-1218-4DB5-9C85-77EA011540D0@uva.nl> <1555.24.62.30.15.1234235653.squirrel@mail.panix.com> <1062.24.62.30.15.1234314505.squirrel@mail.panix.com> <1330.65.96.63.84.1234388462.squirrel@mail.panix.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LXOga-0005xs-A5 for emacs-orgmode@gnu.org; Wed, 11 Feb 2009 18:40:08 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LXOgZ-0005xE-SP for emacs-orgmode@gnu.org; Wed, 11 Feb 2009 18:40:08 -0500 Received: from [199.232.76.173] (port=55784 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LXOgZ-0005xB-HH for emacs-orgmode@gnu.org; Wed, 11 Feb 2009 18:40:07 -0500 Received: from g5t0007.atlanta.hp.com ([15.192.0.44]:34474) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LXOgZ-00034S-3G for emacs-orgmode@gnu.org; Wed, 11 Feb 2009 18:40:07 -0500 In-Reply-To: Message from "Tom Breton (Tehom)" of "Wed, 11 Feb 2009 16:41:02 EST." <1330.65.96.63.84.1234388462.squirrel@mail.panix.com> 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: "Tom Breton (Tehom)" Cc: emacs-orgmode@gnu.org Tom Breton (Tehom) wrote: > > > > On Feb 11, 2009, at 2:08 AM, Tom Breton (Tehom) wrote: > > > > >> This bug is simple. In "Setting it all up" at the end of org- > >> choose.el, > >> in 6.22b a quote got introduced before progn. That's all. With that > >> quote, it "evaluated" a quoted form and did nothing. I'd send a > >> patch, > >> but ISTM it's easier to just press backspace once. It's here: > >> > >> (eval-after-load 'org > >> '(progn > >> ;;^--HERE. > >> (add-to-list 'org-todo-setup-filter-hook > >> #'org-choose-setup-filter) > >> (add-to-list 'org-todo-get-default-hook > >> #'org-choose-get-default-mark) > >> (add-to-list 'org-trigger-hook > >> #'org-choose-keep-sensible) > >> (add-to-list 'org-todo-interpretation-widgets > >> '(:tag "Choose (to record decisions)" choose) > >> 'append) > >> )) > > > > Hi Tom, > > > > I added the quote because without it, evaluating org-chose.el did error= > . > > It was my understanding that such a form has to be quoted. Am > > I missing something here? > > What error did it give? I didn't get one here. > > Definitely the form should not be quoted. Quoted, it does nothing. > Demonstration (with libary `simple' which is fairly basic in emacs so > probably loaded for everyone): > > (let* > ((x 1)) > (eval-after-load 'simple (setq x 2)) > x) > > =3D> 2 > > > > (let* > ((x 1)) > (eval-after-load 'simple '(setq x 2)) > x) > > =3D> 1 Are you sure about this? My understanding of this differs from yours: eval-after-load is an ordinary function (not a special form), and function evaluation in most LISPs (elisp in particular) evaluates arguments before the function is called on them. So if you give it an unquoted form, the form will be evaluated *before* eval-after-load gets its hands on it. That seems to me to defeat the purpose. I'd think that the thing to do is to give the quoted form as argument, then function evaluation evaluates the argument (i.e. unquotes the quoted form, giving back the form) which is then passed to eval-after-load for action. The semantics of eval-after-load imply that (depending on whether the library is already loaded or not) the form may be evaluated once. It is then squirrelled away and if the library is ever loaded again, it is evaluated (perhaps for the first time, perhaps for the nth), *after* the library is loaded. And I think your demonstration is misleading: after doing the eval-after-load, you need to reload "simple" to trigger the "after-load" evaluation, otherwise eval-after-load reduces to just plain eval (in this particular case, since simple is, as you point out, already loaded - things would be different if you had chosen some obscure library that is not already loaded): (let* ((x 1)) (eval-after-load 'simple (setq x 2)) (load-library "simple") x) 2 (let* ((x 1)) (eval-after-load 'simple '(setq x 2)) (load-library "simple") x) 2 In the first case, (setq x 2) was evaluated, x was set to 2 and 2 was passed into eval-after-load. Assuming that simple is already loaded, the 2 is evaluated: the result is 2 and it is just thrown away. After the library is loaded again, 2 is evaluated again and the result is 2 and it just thrown away. Since x was set to 2 before, the value of x is 2. In the second case, (quote (setq x 2)) is evaluated, so the form (setq x 2) is passed to eval-after-load. Assuming that simple is already loaded, the form is evaluated, setting x to 2 and giving a result of 2 (which is thrown away). After the library is loaded, (setq x 2) is eval'led again, setting x to 2 again, and giving a result of 2 (which is thrown away). In both cases, the value of x (and therefore the value the let* form returns) is 2. But it seems to me that the second case is the useful one. Perhaps the most telling evidence that the quote should be there however is the following: if you look at eval-after-load instances in the emacs lisp directory, you'll see that the second argument in all of them is quoted or at least (when partial evaluation is required) backquoted -- although I guess one could argue that they all originated by copying a badly constructed precursor - the programming version of original sin!-) Regards, Nick