Patchwork [O] narrowing in agenda file

login
register
Submitter Litvinov Sergey
Date 2012-01-23 14:41:13
Message ID <5r1uqq4h2u.fsf@kana.aer.mw.tum.de>
Download mbox | patch
Permalink /patch/1128/
State New
Headers show

Comments

Litvinov Sergey - 2012-01-23 14:41:13
"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.
Bernt Hansen - 2012-01-23 18:04:20
Litvinov Sergey <slitvinov@gmail.com> writes:

> "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.

Hi Sergey,

I haven't had a chance to try your patch yet but I recently tried to fix
this behaviour as well but there are other issues that crop up when you
keep the narrowed region.

Please make sure that at least the following work as expected with your
patch:

  - org agenda clock reports are correct
  - You don't have the LOGBOOK drawer aligned with tags when clocking in
    from the agenda (this was with emacs -q (no org-indent-mode)
  - Column view in the agenda shows correct clocking amounts for each
    task
  - Visiting a task with RET or SPC goes to the task when outside the
    narrowed region
  - Remote editing of a task outside the narrowed region changes the
    target task and not something in your narrowed region instead

I'm hoping your patch works since I also want this desired behaviour but
so far my attempts to achieve this failed miserably :(

Regards,
Bernt
Bernt Hansen - 2012-02-01 14:11:59
Bernt Hansen <bernt@norang.ca> writes:

> Litvinov Sergey <slitvinov@gmail.com> writes:
>
>> "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.
>
> Hi Sergey,
>
> I haven't had a chance to try your patch yet but I recently tried to fix
> this behaviour as well but there are other issues that crop up when you
> keep the narrowed region.
>
> Please make sure that at least the following work as expected with your
> patch:
>
>   - org agenda clock reports are correct
>   - You don't have the LOGBOOK drawer aligned with tags when clocking in
>     from the agenda (this was with emacs -q (no org-indent-mode)
>   - Column view in the agenda shows correct clocking amounts for each
>     task
>   - Visiting a task with RET or SPC goes to the task when outside the
>     narrowed region
>   - Remote editing of a task outside the narrowed region changes the
>     target task and not something in your narrowed region instead
>
> I'm hoping your patch works since I also want this desired behaviour but
> so far my attempts to achieve this failed miserably :(
>
> Regards,
> Bernt


Hi Litvinov,

I tried this patch today and clock reports in the agenda no longer
display for me.  Could you take a look at it please?

Thanks,
Bernt

Patch

From 188d95624fec5d53403fd705679167ed7d7345a2 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey <slitvinov@gmail.com>
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