all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Fix bug that erases org buffer when calling agenda via org-agenda-open-link.
@ 2010-09-16  4:15 Matt Lundin
  2010-09-16  5:29 ` Matthew Lundin
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Lundin @ 2010-09-16  4:15 UTC (permalink / raw)
  To: Org Mode


* lisp/org-agenda.el (org-prepare-agenda): If the agenda is called
  from within the agenda via an elisp link, such as
  [[elisp:(org-agenda-list)]], org-prepare-agenda erases the buffer of
  the file containing the link, since that buffer is current during
  org-prepare agenda (due to a with-current-buffer in
  org-agenda-open-link). An additional test now ensures that the
  agenda buffer is in fact current when the buffer is erased and local
  variables for the agenda are set.
---
 lisp/org-agenda.el |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 9f94fa6..ba46d14 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2816,9 +2816,10 @@ the global options and expect it to be applied to the entire view.")
 	  (org-uniquify org-done-keywords-for-agenda))
     (setq org-drawers-for-agenda (org-uniquify org-drawers-for-agenda))
     (let* ((abuf (get-buffer-create org-agenda-buffer-name))
-	   (awin (get-buffer-window abuf)))
+	   (awin (get-buffer-window abuf))
+	   (abufcur (equal (current-buffer) abuf)))
       (cond
-       ((equal (current-buffer) abuf) nil)
+       (abufcur nil)
        (awin (select-window awin))
        ((not (setq org-pre-agenda-window-conf (current-window-configuration))))
        ((equal org-agenda-window-setup 'current-window)
@@ -2829,7 +2830,11 @@ the global options and expect it to be applied to the entire view.")
 	(switch-to-buffer-other-frame abuf))
        ((equal org-agenda-window-setup 'reorganize-frame)
 	(delete-other-windows)
-	(org-switch-to-buffer-other-window abuf))))
+	(org-switch-to-buffer-other-window abuf)))
+      ;; additional test necessary in case agenda is invoked from within
+      ;; agenda buffer via elisp link
+      (unless abufcur
+	(switch-to-buffer abuf)))
     (setq buffer-read-only nil)
     (let ((inhibit-read-only t)) (erase-buffer))
     (org-agenda-mode)
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] Fix bug that erases org buffer when calling agenda via org-agenda-open-link.
  2010-09-16  4:15 [PATCH] Fix bug that erases org buffer when calling agenda via org-agenda-open-link Matt Lundin
@ 2010-09-16  5:29 ` Matthew Lundin
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Lundin @ 2010-09-16  5:29 UTC (permalink / raw)
  To: Org Mode

[My apologies, but I'm afraid my first attempt at this patch mistook a
necessary second check for redundancy. Here is an improved version.]

* lisp/org-agenda.el (org-prepare-agenda): If the agenda is called
  from within the agenda via an elisp link, such as
  [[elisp:(org-agenda-list)]], org-prepare-agenda erases the buffer of
  the file containing the link, since that buffer is current during
  org-prepare agenda (due to a with-current-buffer in
  org-agenda-open-link). An additional test now ensures that the
  agenda buffer is in fact current when the buffer is erased and local
  variables for the agenda are set.
---
 lisp/org-agenda.el |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 9f94fa6..7458076 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2829,7 +2829,11 @@ the global options and expect it to be applied to the entire view.")
 	(switch-to-buffer-other-frame abuf))
        ((equal org-agenda-window-setup 'reorganize-frame)
 	(delete-other-windows)
-	(org-switch-to-buffer-other-window abuf))))
+	(org-switch-to-buffer-other-window abuf)))
+      ;; additional test in case agenda is invoked from within agenda
+      ;; buffer via elisp link
+      (unless (equal (current-buffer) abuf)
+	(switch-to-buffer abuf)))
     (setq buffer-read-only nil)
     (let ((inhibit-read-only t)) (erase-buffer))
     (org-agenda-mode)
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-16  5:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-16  4:15 [PATCH] Fix bug that erases org buffer when calling agenda via org-agenda-open-link Matt Lundin
2010-09-16  5:29 ` Matthew Lundin

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.