From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Re: Problem with agenda and diary Date: Thu, 17 Mar 2011 18:01:18 -0400 Message-ID: <9418.1300399278@alphaville.usa.hp.com> References: <87sjul50xb.fsf@rochester.rr.com> <8762rhg8o8.fsf@member.fsf.org> <87vczhep74.fsf@member.fsf.org> <9609.1300382878@alphaville.dokosmarshall.org> <87r5a5k3vj.fsf@member.fsf.org> <87fwql8t2m.fsf@rochester.rr.com> <5887.1300391111@alphaville.usa.hp.com> <87oc59fppd.fsf@rochester.rr.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from [140.186.70.92] (port=51477 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q0LFy-0006cT-1W for emacs-orgmode@gnu.org; Thu, 17 Mar 2011 18:01:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q0LFw-0002o5-OG for emacs-orgmode@gnu.org; Thu, 17 Mar 2011 18:01:21 -0400 Received: from g4t0014.houston.hp.com ([15.201.24.17]:33171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q0LFw-0002ny-FF for emacs-orgmode@gnu.org; Thu, 17 Mar 2011 18:01:20 -0400 In-Reply-To: Message from Dan Griswold of "Thu, 17 Mar 2011 16:37:50 EDT." <87oc59fppd.fsf@rochester.rr.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: Dan Griswold Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Dan Griswold wrote: > Sure. But I don't want to include absolutely everything, because of > personal calendar entries. Here it is, back to the point where it gets > too specific to my life: > That's of course as it should be. > > Debugger entered--Lisp error: (args-out-of-range -1 0) > add-text-properties(0 -1 (org-heading t) "") ... > org-format-agenda-item("" "" "Diary" nil time) The code in org-format-agenda-item is ,---- | ;; Set org-heading property on `txt' to mark the start of the | ;; heading. | (add-text-properties 0 (1- (length txt)) '(org-heading t) txt) | `---- where txt is the second argument of org-format-agenda-item. As you can see from your backtrace, that is the empty string, so the call to add-text-properties ends up trying to give some property to an empty string: it does not like that. So the problem is that that second argument is the empty string. Now org-format-agenda-item is called from many places: In org-agenda.el - org-search-view - org-get-entries-from-diary - org-agenda-get-todos - org-agenda-get-timestamps - org-agenda-get-sexps - org-agenda-get-progress - org-agenda-get-deadlines - org-agenda-get-scheduled - org-agenda-get-blocks - org-agenda-add-time-grid-maybe - org-agenda-change-all-lines - org-agenda-add-entry-to-org-agenda-diary-file In org.el - org-scan-tags Of these, org-get-entries-from-diary and org-agenda-add-entry-to-org-agenda-diary-file sound like the plausible candidates, but since I don't have the rest of the backtrace, I cannot tell for sure. Can you check whether one or the other (or both) occurs further down in your backtrace and let us know? If neither appears, can you check whether one of the others does? Proceeding on the *assumption* that it is org-get-entries-from-diary, the call chain is org-agenda-list --> org-get-entries-from-diary --> org-format-agenda-item --> boom The code in org-get-entries-from-diary that calls org-format-agenda-item looks like this: ... (when entries (setq entries (org-split-string entries "\n")) (setq entries (mapcar (lambda (x) (setq x (org-format-agenda-item "" x "Diary" nil 'time)) ;; Extend the text properties to the beginning of the line (org-add-props x (text-properties-at (1- (length x)) x) 'type "diary" 'date date 'face 'org-agenda-diary)) entries))) and the entries come from your diary, so that's the end of the road for us. What I would suggest you do depends on a number of factors: whether you use git to manage your org sources, how conversant you are with elisp and the debugger and how much time you want to spend on it. At the most basic level, I would first take a jaundiced look at the diary file: see if there is anything that looks strange, like an empty entry. Then I would bisect my way through it: copy the diary file to a backup. Then start editing the original by whacking half of it away at each stage, and seeing whether you still have the problem: if you do, continue on this half; if you don't, continue on the other half - until you are down to a single entry. Then copy your backup back to the original, delete the suspect entry and try again. Alternatively, if you want to get your hands dirty with some debugging, you can try changing the code above as follows: ... (when entries (setq entries (org-split-string entries "\n")) (debug) (setq entries (mapcar (lambda (x) (setq x (org-format-agenda-item "" x "Diary" nil 'time)) ;; Extend the text properties to the beginning of the line (org-add-props x (text-properties-at (1- (length x)) x) 'type "diary" 'date date 'face 'org-agenda-diary)) entries))) adding a call to debug: when it reaches that point, emacs will drop you into the debugger and you can examine the variable `entries' with e entries The result will be shown in the minibuffer which may not be large enough for everything, in which case switch to the *Messages* buffer which will have everything. Look for an empty entry and check its neighbors. I haven't looked at the code that reads the stuff from the diary, but chances are that the empty entry's neighbors will be its neighbors in the diary file as well. That should give you a good indication of what entry is at fault. If you use git, you can create a temporary branch and make your changes there, experiment and then switch back to master and delete the temporary branch. If you don't use git, save org-agenda.el in a backup file, do the experiment and restore it afterwards. In either case, it's probably best to restart your emacs and possibly use a minimal .emacs file to get only the behavior you need to test. Good luck! And let us know how you fare. Nick