From mboxrd@z Thu Jan 1 00:00:00 1970 From: Litvinov Sergey Subject: [PATCH] narrowing in agenda file Date: Mon, 23 Jan 2012 15:41:13 +0100 Message-ID: <5r1uqq4h2u.fsf@kana.aer.mw.tum.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:46516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpL5Z-0001gC-5g for emacs-orgmode@gnu.org; Mon, 23 Jan 2012 09:41:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RpL5T-0002TV-1W for emacs-orgmode@gnu.org; Mon, 23 Jan 2012 09:41:41 -0500 Received: from lo.gmane.org ([80.91.229.12]:41475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpL5S-0002TM-Ol for emacs-orgmode@gnu.org; Mon, 23 Jan 2012 09:41:35 -0500 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RpL5Q-0007BE-NZ for emacs-orgmode@gnu.org; Mon, 23 Jan 2012 15:41:32 +0100 Received: from kana.aer.mw.tum.de ([129.187.68.65]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 23 Jan 2012 15:41:32 +0100 Received: from slitvinov by kana.aer.mw.tum.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 23 Jan 2012 15:41:32 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= "Narrowing" in the agenda file does not "survive" agenda redo. Please see an example in the first patch. I think the second patch fixes this problem. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Add-a-test-narrowed-agenda-file.patch >From 60ef46625131391c6a49fccd26861f933a984515 Mon Sep 17 00:00:00 2001 From: Litvinov Sergey Date: Mon, 23 Jan 2012 14:22:53 +0100 Subject: [PATCH 1/2] Add a test "narrowed" agenda file --- testing/examples/org-agenda-test.org | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) create mode 100644 testing/examples/org-agenda-test.org diff --git a/testing/examples/org-agenda-test.org b/testing/examples/org-agenda-test.org new file mode 100644 index 0000000..ecd00e5 --- /dev/null +++ b/testing/examples/org-agenda-test.org @@ -0,0 +1,10 @@ +#+Title: a collection of examples for org-agenda tests +* TODO should be visible +ob-agenda-test.org buffer should be narrowed after execution of this block +#+BEGIN_SRC elisp :results silent + (let ((org-agenda-files (list buffer-file-name))) + (narrow-to-region 1 (- (buffer-size) 23)) + (org-agenda nil "t") + (org-agenda-redo)) +#+END_SRC +* TODO should be hidden -- 1.7.3.4 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-Make-narrowing-of-the-agenda-file-survive-org-agenda.patch >From 188d95624fec5d53403fd705679167ed7d7345a2 Mon Sep 17 00:00:00 2001 From: Litvinov Sergey Date: Mon, 23 Jan 2012 14:26:14 +0100 Subject: [PATCH 2/2] Make narrowing of the agenda file survive (org-agenda-redo) * lisp/org.el (org-prepare-agenda-buffers): move '(save-excursion (save-restriction' construction --- lisp/org.el | 67 +++++++++++++++++++++++++++++------------------------------ 1 files changed, 33 insertions(+), 34 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index f6a1160..9e23c18 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16498,47 +16498,46 @@ When a buffer is unmodified, it is just killed. When modified, it is saved (inhibit-read-only t) (rea (concat ":" org-archive-tag ":")) bmp file re) - (save-excursion - (save-restriction (while (setq file (pop files)) (catch 'nextfile (if (bufferp file) (set-buffer file) (org-check-agenda-file file) (set-buffer (org-get-agenda-file-buffer file))) - (widen) - (setq bmp (buffer-modified-p)) - (org-refresh-category-properties) - (setq org-todo-keywords-for-agenda - (append org-todo-keywords-for-agenda org-todo-keywords-1)) - (setq org-done-keywords-for-agenda - (append org-done-keywords-for-agenda org-done-keywords)) - (setq org-todo-keyword-alist-for-agenda - (append org-todo-keyword-alist-for-agenda org-todo-key-alist)) - (setq org-drawers-for-agenda - (append org-drawers-for-agenda org-drawers)) - (setq org-tag-alist-for-agenda - (append org-tag-alist-for-agenda org-tag-alist)) - (save-excursion - (remove-text-properties (point-min) (point-max) pall) - (when org-agenda-skip-archived-trees - (goto-char (point-min)) - (while (re-search-forward rea nil t) - (if (org-at-heading-p t) - (add-text-properties (point-at-bol) (org-end-of-subtree t) pa)))) - (goto-char (point-min)) - (setq re (format org-heading-keyword-regexp-format - org-comment-string)) - (while (re-search-forward re nil t) - (add-text-properties - (match-beginning 0) (org-end-of-subtree t) pc))) - (set-buffer-modified-p bmp))))) - (setq org-todo-keywords-for-agenda - (org-uniquify org-todo-keywords-for-agenda)) - (setq org-todo-keyword-alist-for-agenda - (org-uniquify org-todo-keyword-alist-for-agenda) - org-tag-alist-for-agenda (org-uniquify org-tag-alist-for-agenda)))) + (save-restriction + (widen) + (setq bmp (buffer-modified-p)) + (org-refresh-category-properties) + (setq org-todo-keywords-for-agenda + (append org-todo-keywords-for-agenda org-todo-keywords-1)) + (setq org-done-keywords-for-agenda + (append org-done-keywords-for-agenda org-done-keywords)) + (setq org-todo-keyword-alist-for-agenda + (append org-todo-keyword-alist-for-agenda org-todo-key-alist)) + (setq org-drawers-for-agenda + (append org-drawers-for-agenda org-drawers)) + (setq org-tag-alist-for-agenda + (append org-tag-alist-for-agenda org-tag-alist)) + (save-excursion + (remove-text-properties (point-min) (point-max) pall) + (when org-agenda-skip-archived-trees + (goto-char (point-min)) + (while (re-search-forward rea nil t) + (if (org-at-heading-p t) + (add-text-properties (point-at-bol) (org-end-of-subtree t) pa)))) + (goto-char (point-min)) + (setq re (format org-heading-keyword-regexp-format + org-comment-string)) + (while (re-search-forward re nil t) + (add-text-properties + (match-beginning 0) (org-end-of-subtree t) pc))) + (set-buffer-modified-p bmp))))) + (setq org-todo-keywords-for-agenda + (org-uniquify org-todo-keywords-for-agenda)) + (setq org-todo-keyword-alist-for-agenda + (org-uniquify org-todo-keyword-alist-for-agenda) + org-tag-alist-for-agenda (org-uniquify org-tag-alist-for-agenda)))) ;;;; Embedded LaTeX -- 1.7.3.4 --=-=-=--