emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: Dan Griswold <dgriswol@rochester.rr.com>
Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org
Subject: Re: Re: Problem with agenda and diary
Date: Thu, 17 Mar 2011 18:01:18 -0400	[thread overview]
Message-ID: <9418.1300399278@alphaville.usa.hp.com> (raw)
In-Reply-To: Message from Dan Griswold <dgriswol@rochester.rr.com> of "Thu, 17 Mar 2011 16:37:50 EDT." <87oc59fppd.fsf@rochester.rr.com>

Dan Griswold <dgriswol@rochester.rr.com> 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 <RET>

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

  reply	other threads:[~2011-03-17 22:01 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-13 17:29 [PATCH] org: rework property set Julien Danjou
2010-12-13 21:21 ` Bernt Hansen
2010-12-14  9:01   ` Julien Danjou
2010-12-14 10:15     ` Giovanni Ridolfi
2010-12-14 10:30       ` Julien Danjou
2010-12-14 12:28         ` Bernt Hansen
2010-12-16 13:34         ` Carsten Dominik
2010-12-16 13:45           ` Julien Danjou
2010-12-16 13:55             ` Carsten Dominik
2010-12-16 17:12               ` Julien Danjou
2010-12-17 17:39                 ` Carsten Dominik
     [not found]         ` <julien@danjou.info>
2010-12-14 14:50           ` Nick Dokos
2011-03-17 17:27           ` Re: Problem with agenda and diary Nick Dokos
2011-03-17 18:18             ` Tassilo Horn
2011-03-17 19:06               ` Dan Griswold
2011-03-17 19:45                 ` Nick Dokos
2011-03-17 20:37                   ` Dan Griswold
2011-03-17 22:01                     ` Nick Dokos [this message]
2011-03-17 22:11                     ` Nick Dokos
2011-03-18 10:36                 ` Julien Danjou
2011-03-18 10:36             ` Julien Danjou
2011-03-18 14:04           ` Nick Dokos
2011-03-18 14:14             ` Nick Dokos
2011-03-18 14:56               ` Bernt Hansen
2011-03-18 15:20               ` Bastien
2011-03-18 15:33                 ` Nick Dokos
2011-03-18 16:27                 ` Julien Danjou
2011-03-19 10:20                   ` Bastien
2011-03-19 10:20                   ` Bastien
2011-03-18 14:22             ` Julien Danjou
2011-03-18 14:51               ` Julien Danjou, Nick Dokos
2011-03-18 15:05                 ` Bastien
  -- strict thread matches above, loose matches on Subject: below --
2011-03-17 13:30 Dan Griswold
2011-03-17 13:39 ` Erik Iverson
2011-03-17 13:48 ` Tassilo Horn
2011-03-17 14:45   ` Julien Danjou
2011-03-17 15:34     ` Tassilo Horn
2011-03-17 16:46       ` Julien Danjou
2011-03-17 20:28       ` Sébastien Vauban
2011-03-17 22:06         ` Nick Dokos
2011-03-17 23:43           ` Sébastien Vauban
2011-03-18  0:20             ` Nick Dokos
2011-03-18 10:07     ` Bastien
2011-03-17 14:48   ` Dan Griswold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9418.1300399278@alphaville.usa.hp.com \
    --to=nicholas.dokos@hp.com \
    --cc=dgriswol@rochester.rr.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).