From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Kliakhandler Subject: Re: Weird behavior in `org-agenda-redo' and/or `org-mobile-push' Date: Tue, 6 May 2014 21:49:16 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a11355070ad188304f8bfb59c Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhkQy-0007Ix-8s for emacs-orgmode@gnu.org; Tue, 06 May 2014 14:49:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhkQt-0007Zb-MM for emacs-orgmode@gnu.org; Tue, 06 May 2014 14:49:44 -0400 Received: from mail-qg0-f52.google.com ([209.85.192.52]:62765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhkQt-0007ZF-Fw for emacs-orgmode@gnu.org; Tue, 06 May 2014 14:49:39 -0400 Received: by mail-qg0-f52.google.com with SMTP id a108so3221395qge.11 for ; Tue, 06 May 2014 11:49:38 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --001a11355070ad188304f8bfb59c Content-Type: multipart/alternative; boundary=001a11355070ad187e04f8bfb59a --001a11355070ad187e04f8bfb59a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Ok, I don't know specifically why the code in the last message was necessary, but I realized the difference between the two cases (in the first case, the macro is expanded every time the function is called, whereas in the second it is expanded once, when the function is defined). I also fixed the problems in both org-agenda.el and am including the patch. Thanks, Kosta -- Konstantin Kliakhandler http://slumpy.org )=C2=B0) )=C2=B0( (=C2=B0( On Tue, May 6, 2014 at 6:54 PM, Konstantin Kliakhandler w= rote: > While investigating the previous issue, I came upon this code: > > ;;;###autoload > (defun org-store-agenda-views (&rest parameters) > "Store agenda views." > (interactive) > (eval (list 'org-batch-store-agenda-views))) > > I guess there is some advantage over the following, simpler version? > > ;;;###autoload > (defun org-store-agenda-views (&rest parameters) > "Store agenda views." > (interactive) > (org-batch-store-agenda-views)) > > If so, what is it? > > Thanks in advance for furthering my education, > Kosta > > -- > Konstantin Kliakhandler > http://slumpy.org > )=C2=B0) )=C2=B0( (=C2=B0( > > > On Tue, May 6, 2014 at 2:00 PM, Konstantin Kliakhandler wrote: > >> Hello, >> >> [This behavior appears in a previous and the following org versions: >> Org-mode version 8.2.6 (8.2.6-14-g063c8b-elpa @ >> /home/kosta/.emacs.d/elpa/org-20140505/)] >> >> I recently began seeing weird behavior when trying to run >> `org-mobile-push' in an agenda buffer; It appears the files are indeed >> pushed, but at the end I get an error: "(wrong-type-argument arrayp nil)= " >> >> This only happens when I attempt to push from an agenda buffer - if I >> push in a regular org buffer, everything works. >> >> The stack trace is: >> org-agenda-filter-apply(nil category) >> org-agenda-redo() >> org-mobile-push() >> >> where the `org-agenda-filter-apply' call is from this sexp in >> `org-agenda-redo': >> (and (or cat-filter cat-preset) (org-agenda-filter-apply cat-filter >> 'category)) >> >> And cat-filter, cat-preset are set in a let* form higher up in >> org-agenda-redo as (their values are included): >> >> (cat-filter org-agenda-category-filter) >> nil >> (cat-preset (get 'org-agenda-category-filter :preset-filter)) >> ("+Academic") >> >> When I start emacs or even look at the agenda, >> (get 'org-agenda-category-filter :preset-filter) always evaluates to nil >> (up to the point where I eval `org-mobile-push'). It gets set in >> `org-mobile-create-sumo-agenda', which is called at some point from >> `org-mobile-push' before `org-agenda-redo'. >> >> Apparently this started happening after I added the following custom >> agenda command: >> >> ("z" "All academic agenda items" alltodo "" >> ((org-agenda-overriding-header "Academic todos.") >> (org-agenda-category-filter-preset >> (quote >> ("+Academic"))) >> (org-agenda-todo-list-sublevels nil))) >> >> Now, I have two questions/comments: >> 1. It appears that `org-agenda-filter-apply' expects an array, and an >> array always evaluates to togical t (As far as I remember, have just >> checked). If this is the case, in the following sexp (from >> `org-agenda-filter-apply'): (and (or cat-filter cat-preset) >> (org-agenda-filter-apply cat-filter 'category)) why is the (or cat-filte= r >> cat-preset)? It seems that either `cat-filter' is an array, in which cas= e >> it is (possibly) valid to pass it to `org-agenda-filter-apply', or is ni= l, >> in which case it isn't. What role does cat-preset play here? >> 2. It appears to me that `org-mobile-create-sumo-agenda' does not work >> entirely correctly, as it leaves some properties set that were not set >> before it ran? >> >> Ok, so after writing the last two questions, I looked into >> `org-agenda-filter-apply', and it appears that it expects a list of stri= ngs >> of the form "+cat" or "-cat", which is what `cat-preset' holds at this >> point. >> >> Changing >> (and (or cat-filter cat-preset) (org-agenda-filter-apply cat-filter >> 'category)) >> to >> (and (or cat-filter cat-preset) (org-agenda-filter-apply (or cat-filter >> cat-preset) 'category)) >> as a check and reevaling the defun makes org-mobile-push complete with n= o >> errors even when ran from an agenda buffer. Note however: >> 1. There are several more similar lines in org-agenda-redo, which I >> suspect also need to be checked. >> 2. After org-mobile-push, a category filter is applied to the agenda >> buffer ("+Academic"), despite the original agenda buffer having no such >> filter, so it seems that something is broken in >> `org-mobile-create-sumo-agenda' regardless. >> >> I found a (somewhat) relevant post here: >> http://thread.gmane.org/gmane.emacs.orgmode/57481 >> If what I wrote makes sense, let me know and I will submit a patch for >> `org-agenda-filter-apply', and if I figure out how to fix >> `org-mobile-create-sumo-agenda', for that as well. >> >> Thanks, >> Kosta >> > > --001a11355070ad187e04f8bfb59a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Ok, I don't know specifically why the code in the last= message was necessary, but I realized the difference between the two cases= (in the first case, the macro is expanded every time the function is calle= d, whereas in the second it is expanded once, when the function is defined)= .

I also fixed the problems in both org-agenda.el and am inclu= ding the patch.

Thanks,
Kosta
=

--
Konstantin Kliakhandler
=C2=A0 =C2=A0 http://slumpy.org
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2= =A0=C2=A0 )=C2=B0) )=C2=B0( (=C2=B0(


On Tue, May 6, 2014 at 6:54 PM, Konstant= in Kliakhandler <kosta@slumpy.org> wrote:
While investigating the previous issue, I came upon this c= ode:

;;;###autoload
(defun org-store-agen= da-views (&rest parameters)
=C2=A0 "Store agenda views.&= quot;
=C2=A0 (interactive)
=C2=A0 (eval (list 'org-batch-store= -agenda-views)))

I guess there is some advan= tage over the following, simpler version?

;;;###autoload
(defun org-store-agenda-views (&rest parameters)
=C2=A0 = "Store agenda views."
=C2=A0 (interactive)
= =C2=A0 (org-batch-store-agenda-views))

If so, what is it?

Thanks in advance for furthering my education,
Kosta

--
Konstantin Kliakhandler
=C2=A0 =C2=A0 http://slumpy.org
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 )=C2=B0) )=C2=B0( (=C2=B0(


On Tue, May 6, 2014 at 2:00 PM, Konstant= in Kliakhandler <kosta@slumpy.org> wrote:
Hello,

[This behavior a= ppears in a previous and the following org versions: Org-mode version 8.2.6= (8.2.6-14-g063c8b-elpa @ /home/kosta/.emacs.d/elpa/org-20140505/)]

I recently began seeing weird behavior when trying to run `o= rg-mobile-push' in an agenda buffer; It appears the files are indeed pu= shed, but at the end I get an error: "(wrong-type-argument arrayp nil)= "

This only happens when I attempt to push from an agenda= buffer - if I push in a regular org buffer, everything works.
The stack trace is:
org-agenda-filter-apply(nil cate= gory)
org-agenda-redo()
org-mobile-push()

where the `org-agenda-filter-apply' call is from this sexp in `org-age= nda-redo':
(and (or cat-filter cat-preset) (org-agenda-filter= -apply cat-filter 'category))

And cat-filter, cat-preset are set in a let* form highe= r up in org-agenda-redo as (their values are included):

(cat-filter org-agenda-category-filter)
nil
(cat-preset (get 'org-agenda-category-filter :preset-filter))
("+Academic")

When I start emacs or= even look at the agenda,
(get 'org-agenda-category-filter :p= reset-filter) always evaluates to nil (up to the point where I eval `org-mo= bile-push'). It gets set in `org-mobile-create-sumo-agenda', which = is called at some point from `org-mobile-push' before `org-agenda-redo&= #39;.

Apparently this started happening after I added the fol= lowing custom agenda command:

("z" "= ;All academic agenda items" alltodo ""
=C2=A0((org= -agenda-overriding-header "Academic todos.")
=C2=A0 (org-agenda-category-filter-preset
=C2=A0 =C2=A0(quot= e
("+Academic&q= uot;)))
(org-agenda-todo-list-sublevels nil)))

Now, I have two questions/comments:
1. It appears that `org-agenda-filter-apply' expects an array, and= an array always evaluates to togical t (As far as I remember, have just ch= ecked). If this is the case, in the following sexp (from `org-agenda-filter= -apply'): (and (or cat-filter cat-preset) (org-agenda-filter-apply cat-= filter 'category)) why is the (or cat-filter cat-preset)? It seems that= either `cat-filter' is an array, in which case it is (possibly) valid = to pass it to `org-agenda-filter-apply', or is nil, in which case it is= n't. What role does cat-preset play here?
2. It appears to me that `org-mobile-create-sumo-agenda' does not = work entirely correctly, as it leaves some properties set that were not set= before it ran?

Ok, so after writing the last two = questions, I looked into `org-agenda-filter-apply', and it appears that= it expects a list of strings of the form "+cat" or "-cat&qu= ot;, which is what `cat-preset' holds at this point.

Changing
(and (or cat-filter cat-preset) (org= -agenda-filter-apply cat-filter 'category))
to
(and= (or cat-filter cat-preset) (org-agenda-filter-apply (or cat-filter cat-pre= set) 'category))
as a check and reevaling the defun makes org-mobile-push complete with= no errors even when ran from an agenda buffer. Note however:
1. = There are several more similar lines in org-agenda-redo, which I suspect al= so need to be checked.
2. After org-mobile-push, a category filter is applied to the agenda b= uffer ("+Academic"), despite the original agenda buffer having no= such filter, so it seems that something is broken in `org-mobile-create-su= mo-agenda' regardless.

I found a (somewhat) relevant post here: http://th= read.gmane.org/gmane.emacs.orgmode/57481
If what I wrote make= s sense, let me know and I will submit a patch for `org-agenda-filter-apply= ', and if I figure out how to fix `org-mobile-create-sumo-agenda', = for that as well.

Thanks,
Kosta


--001a11355070ad187e04f8bfb59a-- --001a11355070ad188304f8bfb59c Content-Type: text/x-patch; charset=US-ASCII; name="org-agenda.patch" Content-Disposition: attachment; filename="org-agenda.patch" Content-Transf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