emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Patch] Support for dimming local to each agenda
@ 2017-07-12  0:39 Yuri Lensky
  2017-07-13 12:51 ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Yuri Lensky @ 2017-07-12  0:39 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 73 bytes --]

Composite agenda views can now set org-agenda-dim-blocked-tasks locally.

[-- Attachment #1.2: Type: text/html, Size: 96 bytes --]

[-- Attachment #2: 0002-org-agenda.el-Support-for-dimming-local-to-each-agen.patch --]
[-- Type: application/octet-stream, Size: 3839 bytes --]

From 52f8bf79a198fa2e7f131c2a015a7c9400a403ac Mon Sep 17 00:00:00 2001
From: "Yuri D. Lensky" <ydlensky@gmail.com>
Date: Mon, 10 Jul 2017 19:21:39 -0700
Subject: [PATCH 2/2] org-agenda.el: Support for dimming local to each agenda.

Composite agenda views could not separately specify whether to dim
blocked tasks.
---
 lisp/org-agenda.el | 56 ++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 35 insertions(+), 21 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 9ac4f65..f132420 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3887,34 +3887,46 @@ dimming them."
       (delete-overlay o)))
   (save-excursion
     (let ((inhibit-read-only t)
-	  (org-depend-tag-blocked nil)
-	  org-blocked-by-checkboxes)
+	  (org-depend-tag-blocked nil))
       (goto-char (point-min))
       (while (let ((pos (text-property-not-all
-			 (point) (point-max) 'todo-state nil)))
+			 (point) (point-max) 'org-todo-blocked nil)))
 	       (when pos (goto-char pos)))
-	(setq org-blocked-by-checkboxes nil)
-	(let ((marker (org-get-at-bol 'org-hd-marker)))
-	  (when (and (markerp marker)
-		     (with-current-buffer (marker-buffer marker)
-		       (save-excursion (goto-char marker)
-				       (org-entry-blocked-p))))
-	    ;; Entries blocked by checkboxes cannot be made invisible.
-	    ;; See `org-agenda-dim-blocked-tasks' for details.
-	    (let* ((really-invisible
-		    (and (not org-blocked-by-checkboxes)
-			 (or invisible (eq org-agenda-dim-blocked-tasks
-					   'invisible))))
-		   (ov (make-overlay (if really-invisible (line-end-position 0)
-				       (line-beginning-position))
-				     (line-end-position))))
-	      (if really-invisible (overlay-put ov 'invisible t)
-		(overlay-put ov 'face 'org-agenda-dimmed-todo-face))
-	      (overlay-put ov 'org-type 'org-blocked-todo))))
+	(let* ((invisible (eq (org-get-at-bol 'org-todo-blocked) 'invisible))
+	       (ov (make-overlay (if invisible
+				     (line-end-position 0)
+				   (line-beginning-position))
+				 (line-end-position))))
+	  (if invisible
+	      (overlay-put ov 'invisible t)
+	    (overlay-put ov 'face 'org-agenda-dimmed-todo-face))
+	  (overlay-put ov 'org-type 'org-blocked-todo))
 	(forward-line))))
   (when (called-interactively-p 'interactive)
     (message "Dim or hide blocked tasks...done")))
 
+(defun org-agenda-mark-blocked-entry (entry)
+  "Mark a blocked entry in text properties."
+  (when (get-text-property 0 'todo-state entry)
+    (let ((entry-marker (get-text-property 0 'org-hd-marker entry))
+          (org-blocked-by-checkboxes nil)
+	  ;; Necessary so that org-entry-blocked-p does not change the buffer
+          (org-depend-tag-blocked nil))
+      (let ((blocked
+	     (with-current-buffer (marker-buffer entry-marker)
+	       (save-mark-and-excursion
+		 (goto-char entry-marker)
+		 (org-entry-blocked-p)))))
+	(when blocked
+	  (let ((really-invisible
+		 (and (not org-blocked-by-checkboxes)
+		      (eq org-agenda-dim-blocked-tasks 'invisible))))
+	    (put-text-property
+	     0 (length entry) 'org-todo-blocked
+	     (if really-invisible 'invisible t)
+	     entry)))))
+    entry))
+
 (defvar org-agenda-skip-function nil
   "Function to be called at each match during agenda construction.
 If this function returns nil, the current match should not be skipped.
@@ -6781,6 +6793,8 @@ The optional argument TYPE tells the agenda type."
       (setq list (org-agenda-limit-entries list 'tags max-tags)))
     (when max-entries
       (setq list (org-agenda-limit-entries list 'org-hd-marker max-entries)))
+    (when (and org-agenda-dim-blocked-tasks org-blocker-hook)
+      (setq list (mapcar 'org-agenda-mark-blocked-entry list)))
     (mapconcat 'identity list "\n")))
 
 (defun org-agenda-limit-entries (list prop limit &optional fn)
-- 
2.9.2.windows.1


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

end of thread, other threads:[~2017-07-14 12:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-12  0:39 [Patch] Support for dimming local to each agenda Yuri Lensky
2017-07-13 12:51 ` Nicolas Goaziou
2017-07-13 18:09   ` Yuri Lensky
2017-07-14  8:29     ` Nicolas Goaziou
2017-07-14  9:22       ` Yuri Lensky
2017-07-14  9:39         ` Nicolas Goaziou
2017-07-14 12:18           ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).