From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: [PATCH] Fix bug that erases org buffer when calling agenda via org-agenda-open-link. Date: Thu, 16 Sep 2010 00:15:49 -0400 Message-ID: <87d3se9v6m.fsf@archdesk.localdomain> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=47997 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ow5ws-0004AC-EE for emacs-orgmode@gnu.org; Thu, 16 Sep 2010 00:19:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ow5wr-00077L-AY for emacs-orgmode@gnu.org; Thu, 16 Sep 2010 00:19:50 -0400 Received: from out2.smtp.messagingengine.com ([66.111.4.26]:60259) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ow5wr-000775-7h for emacs-orgmode@gnu.org; Thu, 16 Sep 2010 00:19:49 -0400 Received: from archdesk.localdomain (67-197-63-212.rh2.dyn.cm.comporium.net [67.197.63.212]) by mail.messagingengine.com (Postfix) with ESMTPSA id 00F1D4079E3 for ; Thu, 16 Sep 2010 00:19:46 -0400 (EDT) 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: 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