girzel / gnorb

Glue code between the Org, Gnus, and BBDB packages for Emacs.
32 stars 4 forks source link

gnorb-gnus-outgoing-do-todo fails when there is a related message (ID change) #8

Closed brabalan closed 9 years ago

brabalan commented 10 years ago

I tried to run gnorb-gnus-outgoing-do-todo right after sending a message and I got a backtrace:

Debugger entered--Lisp error: (error "Cannot find entry with ID \"485B6A3D-3EB1-4ACC-B6F9-41BA98B67018\"")
  signal(error ("Cannot find entry with ID \"485B6A3D-3EB1-4ACC-B6F9-41BA98B67018\""))
  error("Cannot find entry with ID \"%s\"" "485B6A3D-3EB1-4ACC-B6F9-41BA98B67018")
  org-id-goto("485B6A3D-3EB1-4ACC-B6F9-41BA98B67018")
  (progn (org-id-goto id))
  (if (and (not agenda-p) id) (progn (org-id-goto id)))
  (let* ((agenda-p (eq major-mode (quote org-agenda-mode))) (todo-func (if agenda-p (quote org-agenda-todo) (quote org-todo))) (note-func (if agenda-p (quote org-agenda-add-note) (quote org-add-note))) root-marker ret-dest-todo action) (if (and (not agenda-p) id) (progn (org-id-goto id))) (setq root-marker (if agenda-p (org-get-at-bol (quote org-hd-marker)) (point-at-bol)) ret-dest-todo (org-entry-get root-marker "TODO")) (let ((ids (org-entry-get-multivalued-property root-marker gnorb-org-msg-id-key)) (sent-id (plist-get gnorb-gnus-sending-message-info :msg-id))) (if sent-id (progn (org-entry-add-to-multivalued-property root-marker gnorb-org-msg-id-key sent-id) (gnorb-gnus-make-registry-entry sent-id (plist-get gnorb-gnus-sending-message-info :from) (plist-get gnorb-gnus-sending-message-info :subject) (org-id-get) (plist-get gnorb-gnus-sending-message-info :group)) (gnorb-org-add-id-hash-entry sent-id root-marker))) (setq action (cond ((not (or (and ret-dest-todo ...) (member ret-dest-todo gnorb-org-mail-todos))) (quote note)) ((eq gnorb-trigger-todo-default (quote prompt)) (intern (completing-read "Take note, or trigger TODO state change? " (quote ...) nil t))) ((null arg) gnorb-trigger-todo-default) (t (if (eq gnorb-trigger-todo-default (quote todo)) (quote note) (quote todo))))) (map-y-or-n-p (function (lambda (a) (format "Attach %s to heading? " (file-name-nondirectory a)))) (function (lambda (a) (org-attach-attach a nil (quote mv)))) gnorb-gnus-capture-attachments (quote ("file" "files" "attach"))) (setq gnorb-gnus-capture-attachments nil) (if (eq action (quote note)) (call-interactively note-func) (call-interactively todo-func))))
  gnorb-trigger-todo-action(nil "485B6A3D-3EB1-4ACC-B6F9-41BA98B67018")
  (while --dolist-tail-- (setq id (car --dolist-tail--)) (gnorb-trigger-todo-action nil id) (setq --dolist-tail-- (cdr --dolist-tail--)))
  (let ((--dolist-tail-- gnorb-message-org-ids) id) (while --dolist-tail-- (setq id (car --dolist-tail--)) (gnorb-trigger-todo-action nil id) (setq --dolist-tail-- (cdr --dolist-tail--))))
  (progn (let ((--dolist-tail-- gnorb-message-org-ids) id) (while --dolist-tail-- (setq id (car --dolist-tail--)) (gnorb-trigger-todo-action nil id) (setq --dolist-tail-- (cdr --dolist-tail--)))))
  gnorb-org-restore-after-send()
  (if (not rel-headings) (gnorb-gnus-outgoing-make-todo-1) (progn (let ((--dolist-tail-- rel-headings) h) (while --dolist-tail-- (setq h (car --dolist-tail--)) (setq gnorb-message-org-ids (cons (car h) gnorb-message-org-ids)) (setq --dolist-tail-- (cdr --dolist-tail--))))) (gnorb-org-restore-after-send))
  (progn (if (stringp ref-ids) (progn (setq ref-ids (split-string ref-ids)))) (setq rel-headings (gnorb-org-find-visit-candidates ref-ids)) (if (not rel-headings) (gnorb-gnus-outgoing-make-todo-1) (progn (let ((--dolist-tail-- rel-headings) h) (while --dolist-tail-- (setq h (car --dolist-tail--)) (setq gnorb-message-org-ids (cons (car h) gnorb-message-org-ids)) (setq --dolist-tail-- (cdr --dolist-tail--))))) (gnorb-org-restore-after-send)))
  (if ref-ids (progn (if (stringp ref-ids) (progn (setq ref-ids (split-string ref-ids)))) (setq rel-headings (gnorb-org-find-visit-candidates ref-ids)) (if (not rel-headings) (gnorb-gnus-outgoing-make-todo-1) (progn (let ((--dolist-tail-- rel-headings) h) (while --dolist-tail-- (setq h (car --dolist-tail--)) (setq gnorb-message-org-ids (cons ... gnorb-message-org-ids)) (setq --dolist-tail-- (cdr --dolist-tail--))))) (gnorb-org-restore-after-send))) (gnorb-gnus-outgoing-make-todo-1))
  (if arg (progn (setq gnorb-message-org-ids (cons (caar rel-headings) gnorb-message-org-ids)) (gnorb-org-restore-after-send)) (setq ref-ids (plist-get gnorb-gnus-sending-message-info :refs)) (if ref-ids (progn (if (stringp ref-ids) (progn (setq ref-ids (split-string ref-ids)))) (setq rel-headings (gnorb-org-find-visit-candidates ref-ids)) (if (not rel-headings) (gnorb-gnus-outgoing-make-todo-1) (progn (let ((--dolist-tail-- rel-headings) h) (while --dolist-tail-- (setq h ...) (setq gnorb-message-org-ids ...) (setq --dolist-tail-- ...)))) (gnorb-org-restore-after-send))) (gnorb-gnus-outgoing-make-todo-1)))
  (if (not (eq major-mode (quote message-mode))) (if arg (progn (setq gnorb-message-org-ids (cons (caar rel-headings) gnorb-message-org-ids)) (gnorb-org-restore-after-send)) (setq ref-ids (plist-get gnorb-gnus-sending-message-info :refs)) (if ref-ids (progn (if (stringp ref-ids) (progn (setq ref-ids (split-string ref-ids)))) (setq rel-headings (gnorb-org-find-visit-candidates ref-ids)) (if (not rel-headings) (gnorb-gnus-outgoing-make-todo-1) (progn (let (... h) (while --dolist-tail-- ... ... ...))) (gnorb-org-restore-after-send))) (gnorb-gnus-outgoing-make-todo-1))) (if message-reply-headers (progn (setq reply-id (aref message-reply-headers 4)))) (save-restriction (widen) (message-narrow-to-headers-or-head) (setq header-ids (mail-fetch-field gnorb-mail-header nil nil t)) (setq ref-ids (if arg nil (mail-fetch-field "References" t))) (setq reply-group (if (mail-fetch-field "X-Draft-From" t) (progn (car-safe (read (mail-fetch-field "X-Draft-From" t)))))) (if (and reply-group reply-id) (progn (let ((wconfig (current-window-configuration))) (unwind-protect (progn (org-gnus-follow-link reply-group reply-id) (call-interactively ...)) (set-window-configuration wconfig))))) (if ref-ids (progn (if (stringp ref-ids) (progn (setq ref-ids (split-string ref-ids)))) (setq rel-headings (gnorb-org-find-visit-candidates ref-ids)))) (if rel-headings (progn (goto-char (point-min)) (progn (let ((--dolist-tail-- rel-headings) h) (while --dolist-tail-- (setq h ...) (if ... nil ... ... ... ...) (setq --dolist-tail-- ...))))))) (message-goto-body) (add-to-list (quote message-exit-actions) (if header-ids (quote gnorb-org-restore-after-send) (quote gnorb-gnus-outgoing-make-todo-1)) t) (message (if header-ids "Message will trigger TODO state-changes after sending" "A TODO will be made from this message after it's sent")))
  (let ((org-refile-targets gnorb-gnus-trigger-refile-targets) header-ids ref-ids rel-headings gnorb-org-window-conf reply-id reply-group) (if arg (progn (setq rel-headings (org-refile-get-location "Trigger action on" nil t)) (setq rel-headings (list (list (let (...) (unwind-protect ... ...))))))) (if (not (eq major-mode (quote message-mode))) (if arg (progn (setq gnorb-message-org-ids (cons (caar rel-headings) gnorb-message-org-ids)) (gnorb-org-restore-after-send)) (setq ref-ids (plist-get gnorb-gnus-sending-message-info :refs)) (if ref-ids (progn (if (stringp ref-ids) (progn (setq ref-ids ...))) (setq rel-headings (gnorb-org-find-visit-candidates ref-ids)) (if (not rel-headings) (gnorb-gnus-outgoing-make-todo-1) (progn (let ... ...)) (gnorb-org-restore-after-send))) (gnorb-gnus-outgoing-make-todo-1))) (if message-reply-headers (progn (setq reply-id (aref message-reply-headers 4)))) (save-restriction (widen) (message-narrow-to-headers-or-head) (setq header-ids (mail-fetch-field gnorb-mail-header nil nil t)) (setq ref-ids (if arg nil (mail-fetch-field "References" t))) (setq reply-group (if (mail-fetch-field "X-Draft-From" t) (progn (car-safe (read ...))))) (if (and reply-group reply-id) (progn (let ((wconfig ...)) (unwind-protect (progn ... ...) (set-window-configuration wconfig))))) (if ref-ids (progn (if (stringp ref-ids) (progn (setq ref-ids ...))) (setq rel-headings (gnorb-org-find-visit-candidates ref-ids)))) (if rel-headings (progn (goto-char (point-min)) (progn (let (... h) (while --dolist-tail-- ... ... ...)))))) (message-goto-body) (add-to-list (quote message-exit-actions) (if header-ids (quote gnorb-org-restore-after-send) (quote gnorb-gnus-outgoing-make-todo-1)) t) (message (if header-ids "Message will trigger TODO state-changes after sending" "A TODO will be made from this message after it's sent"))))
  gnorb-gnus-outgoing-do-todo(nil)
  call-interactively(gnorb-gnus-outgoing-do-todo record-it)

What is surprising is that the searched ID existed before (the message I'm replying to is part of a thread where there is a todo with a GNORB_MSG_ID containing a message of the thread; if I go in my org buffer to that task and undo, then I see the ID as searched; when I redo a new ID replaces it). Is it possible that IDs are generated even when they already exist, leading to such an inconsistency?

girzel commented 10 years ago

I use org-id-get-create everywhere, to make sure nothing like that happens, but looking at the org-id code, I don't think there's actually anything that could create a new ID for an entry that already has one. So that's very weird.

I'm in the midst of refactoring and cleaning up all this code, to make it easier to work with. Bear with me for a few days, and hopefully I'll have a cleaner field from which to fix these things.

girzel commented 10 years ago

I think I figured this out -- I was calling org-id-get-create with the force argument, I have no idea why. This should be fixed, but leave it open for a while and see if you get any more similar errors.

brabalan commented 10 years ago

Will do.

girzel commented 9 years ago

If you haven't seen this again recently, I'll go ahead and close this...

brabalan commented 9 years ago

I haven't seen it indeed, thanks.