[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb 5ba5ce4 062/449: Rework gnorb-org-restore-after-s
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb 5ba5ce4 062/449: Rework gnorb-org-restore-after-send |
Date: |
Fri, 27 Nov 2020 23:15:09 -0500 (EST) |
branch: externals/gnorb
commit 5ba5ce42a408974c64da7dc36be9259fb95fc785
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
Rework gnorb-org-restore-after-send
Now does a better job of ensuring that we're restored to the correct Org
heading. Also supports visiting multiple Org headings, though there's
currently no way to set up multiple headings.
---
lisp/gnorb-org.el | 71 ++++++++++++++++++++++++++++++++-----------------------
1 file changed, 41 insertions(+), 30 deletions(-)
diff --git a/lisp/gnorb-org.el b/lisp/gnorb-org.el
index 196dc9e..e7b56b2 100644
--- a/lisp/gnorb-org.el
+++ b/lisp/gnorb-org.el
@@ -57,42 +57,53 @@ point."
(defun gnorb-org-restore-after-send ()
(when (eq major-mode 'gnus-summary-mode)
(gnus-summary-exit nil t))
- ;; this var would have been set in `gnorb-gnus-check-org-header',
- ;; which was run during `message-send-hook'
- (when gnorb-message-org-ids
- (dolist (id gnorb-message-org-ids)
- (with-demoted-errors
- (org-id-goto id)
- (delete-other-windows)
- (when (or (null gnorb-org-mail-todos)
- (member (org-entry-get (point) "TODO")
- gnorb-org-mail-todos))
- (call-interactively 'org-todo)))))
(when (window-configuration-p gnorb-org-window-conf)
(set-window-configuration gnorb-org-window-conf))
+ ;; This is some ugly stuff, but it (hopefully) results in smooth
+ ;; usage.
+ (let* ((agenda-p (eq major-mode 'org-agenda-mode))
+ ;; all this is still broken. Why?
+ (ret-dest-id (org-entry-get
+ (if agenda-p
+ (org-get-at-bol 'org-hd-marker)
+ (point-at-bol)) "ID"))
+ (ret-dest-todo (org-entry-get
+ (if agenda-p
+ (org-get-at-bol 'org-hd-marker)
+ (point-at-bol)) "TODO")))
+ (if (not gnorb-message-org-ids)
+ ;; If there were no Org ID headers, just throw us back where
+ ;; we were and hope.
+ (cond ((eq major-mode 'org-agenda-mode)
+ (call-interactively 'org-agenda-todo))
+ ((eq major-mode 'org-mode)
+ (call-interactively 'org-todo))
+ (t nil))
+ ;; We've been returned to a heading, is it the one referenced by
+ ;; the first of the Org ID headers? This should be the most
+ ;; common case.
+ (when (and (equal ret-dest-id (car gnorb-message-org-ids))
+ (or (null gnorb-org-mail-todos)
+ (member ret-dest-todo gnorb-org-mail-todos)))
+ (if agenda-p
+ (call-interactively 'org-agenda-todo)
+ (call-interactively 'org-todo))
+ (setq gnorb-message-org-ids
+ (cdr gnorb-message-org-ids)))
+ ;; there's currently no way to attach multiple Org IDs to a
+ ;; message, but there might be in the future
+ (dolist (id gnorb-message-org-ids)
+ (with-demoted-errors
+ (org-id-goto id)
+ (delete-other-windows)
+ (when (or (null gnorb-org-mail-todos)
+ (member (org-entry-get (point) "TODO")
+ gnorb-org-mail-todos))
+ (call-interactively 'org-todo))))))
;; this is a little unnecessary, but still...
(setq gnorb-org-window-conf nil)
(setq gnorb-message-org-ids nil))
- ;; (cond ((eq major-mode 'org-agenda-mode)
- ;; (if (null gnorb-org-mail-todos)
- ;; (call-interactively 'org-agenda-todo)
- ;; (let* ((marker (or (org-get-at-bol 'org-marker)
- ;; (org-agenda-error)))
- ;; (buffer (marker-buffer marker)))
- ;; (when (save-excursion
- ;; (with-current-buffer buffer
- ;; (goto-char (marker-position marker))
- ;; (member (org-entry-get (point) "TODO")
- ;; gnorb-org-mail-todos)))
- ;; (call-interactively 'org-agenda-todo)))))
- ;; ((eq major-mode 'org-mode)
- ;; (when (or (null gnorb-org-mail-todos)
- ;; (member (org-entry-get (point) "TODO")
- ;; gnorb-org-mail-todos))
- ;; (call-interactively 'org-todo)))
- ;; (t nil))
-
(defun gnorb-org-extract-mail-stuff ()
(let (message mails)
(while (re-search-forward org-any-link-re (line-end-position) t)
- [elpa] externals/gnorb 1024a81 037/449: New gnorb-org-capture-collect-link-p option, (continued)
- [elpa] externals/gnorb 1024a81 037/449: New gnorb-org-capture-collect-link-p option, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ee8b595 036/449: Merge gnorb-org-handle-mail functions, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5b9e163 047/449: Allow attaching in all captures., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 3a95a07 049/449: First go at `gnorb-org-agenda-popup-bbdb', Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb cf975f5 048/449: Refactor gnorb-org mail-related stuff., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ac3a4d2 050/449: Change README.org wording, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 78f625b 052/449: Documentation and whitespace changes, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ac392c0 053/449: Leave point in body of message replies, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e05fafe 054/449: `gnorb-org-popup-agenda-popup-bbdb' keybinding, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 32a88b8 061/449: Wishlist item for outgoing messages, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5ba5ce4 062/449: Rework gnorb-org-restore-after-send,
Stefan Monnier <=
- [elpa] externals/gnorb 8246cd4 064/449: Restore from mails more reliably, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 89b57f0 066/449: Whoops., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9f13881 067/449: First whack at gnorb-gnus-message-trigger-todo, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e472348 073/449: New hook gnorb-org-after-message-setup-hook, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb a165584 041/449: Handle return from mail sending better, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 7ffc885 043/449: Commenting out my re-implementation of map-y-or-n-p, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 6152e85 059/449: Comments on editing messages, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d786b81 063/449: Random comment edits and indenting changes., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 77698aa 071/449: Split 'gnorb-org-email-subtree-parameters', Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 3a2cd3b 072/449: Improve scanning of headings for mail actions, Stefan Monnier, 2020/11/27