emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: ignotus@freemail.hu
To: emacs-orgmode@gnu.org
Subject: Re: postponing todos
Date: Sat, 11 Aug 2007 17:31:59 +0200	[thread overview]
Message-ID: <87odheulxs.fsf@freemail.hu> (raw)
In-Reply-To: <2151c7f8a47e69a374e5edbed368e83d@science.uva.nl> (Carsten Dominik's message of "Thu, 9 Aug 2007 07:05:46 +0200")

I hack together something that does what I needed.  I don't know org
internal workings, so it is just a quick and dirty hack.  I don't really
know about agenda views as such, maybe what I want to do is possible
with actual org mode stuff, but with my modification org does exactly
what I want the way I want it.  Please Carsten, consider adding
something like this to org-mode.  

Bastien posted another solution that probably does something very
similar but with lot less internal hacking, Bastien please comment.

> ------------------------------------------------------------------------

GOAL: be able to tell org-tags-view to only list entries, that are not
scheduled into the future.  With org-scan-not-future set to nil, users
get standard org behaviour.

CODE:  one new variable and one modified function (ORG-SCAN-TAGS)
 lines marked with ADDED are added by me.

(defvar org-scan-not-future t           ;<<-- ADDED
  "Don't include entries, that are scheduled into the future.")

(defun org-scan-tags (action matcher &optional todo-only)
  "Scan headline tags with inheritance and produce output ACTION.
ACTION can be `sparse-tree' or `agenda'.  MATCHER is a Lisp form to be
evaluated, testing if a given set of tags qualifies a headline for
inclusion.  When TODO-ONLY is non-nil, only lines with a TODO keyword
are included in the output."
  (let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\("
		     (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
		     (org-re
		      "\\>\\)\\)? *\\(.*?\\)\\(:[[:alnum:]_@:]+:\\)?[ \t]*$")))
	 (props (list 'face nil
		      'done-face 'org-done
		      'undone-face nil
		      'mouse-face 'highlight
		      'org-not-done-regexp org-not-done-regexp
		      'org-todo-regexp org-todo-regexp
		      'keymap org-agenda-keymap
		      'help-echo
		      (format "mouse-2 or RET jump to org file %s"
			      (abbreviate-file-name buffer-file-name))))
	 (case-fold-search nil)
         (org-props nil)                ; <<-- ADDED
         lspos
	 tags tags-list tags-alist (llast 0) rtn level category i txt
	 todo marker entry priority)
    (save-excursion
      (goto-char (point-min))
      (when (eq action 'sparse-tree) (org-overview))
      (while (re-search-forward re nil t)
	(catch :skip
          (setq org-props               ; <<-- ADDED
                (save-match-data        ; <<-- ADDED
                  (save-excursion       ; <<-- ADDED
                    (save-restriction   ; <<-- ADDED
                      (org-entry-properties))))) ; <<-- ADDED
	  (setq todo (if (match-end 1) (match-string 2))
		tags (if (match-end 4) (match-string 4)))
	  (goto-char (setq lspos (1+ (match-beginning 0))))
	  (setq level (org-reduced-level (funcall outline-level))
		category (org-get-category))
	  (setq i llast llast level)
	  ;; remove tag lists from same and sublevels
	  (while (>= i level)
	    (when (setq entry (assoc i tags-alist))
	      (setq tags-alist (delete entry tags-alist)))
	    (setq i (1- i)))
	  ;; add the nex tags
	  (when tags
	    (setq tags (mapcar 'downcase (org-split-string tags ":"))
		  tags-alist
		  (cons (cons level tags) tags-alist)))
	  ;; compile tags for current headline
	  (setq tags-list
		(if org-use-tag-inheritance
		    (apply 'append (mapcar 'cdr tags-alist))
		  tags))
	  (when (and (or (not todo-only) (member todo org-not-done-keywords))
		     (eval matcher)
		     (or (not org-agenda-skip-archived-trees)
			 (not (member org-archive-tag tags-list)))
                     )
	    (and (eq action 'agenda) (org-agenda-skip))
	    ;; list this headline
	    (if (eq action 'sparse-tree)
		(progn
		  (org-show-context 'tags-tree))
	      (setq txt (org-format-agenda-item
			 ""
			 (concat
			  (if org-tags-match-list-sublevels
			      (make-string (1- level) ?.) "")
			  (org-get-heading))
			 category tags-list)
		    priority (org-get-priority txt))
	      (goto-char lspos)
	      (setq marker (org-agenda-new-marker))
	      (org-add-props txt props
		'org-marker marker 'org-hd-marker marker 'org-category category
		'priority priority 'type "tagsmatch")
              ; v-- ADDED
              (if org-scan-not-future
                  (if (assoc "SCHEDULED" org-props)
                      ;; scheduled for today, or past?
                      (and (<= (org-days-to-time (cdr (assoc "SCHEDULED" org-props)))
                               0)
                           (push txt rtn))
                      ;; not scheduled, keeper
                      (push txt rtn))
                  (push txt rtn))
              ; ^-- ADDED
	      ;;(push txt rtn)        ; <<-- ADDED (commented out)
              )
	    ;; if we are to skip sublevels, jump to end of subtree
	    (or org-tags-match-list-sublevels (org-end-of-subtree t)))
          )))
    (when (and (eq action 'sparse-tree)
	       (not org-sparse-tree-open-archived-trees))
      (org-hide-archived-subtrees (point-min) (point-max)))
    (nreverse rtn)))

-- 
Udv, Ricsi

  parent reply	other threads:[~2007-08-11 15:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-06 15:42 postponing todos ignotus
2007-08-06 23:18 ` Bastien
2007-08-07  0:56   ` Bastien
2007-08-07  8:41   ` ignotus
2007-08-07  1:47 ` Eddward DeVilla
2007-08-07  8:25   ` ignotus
2007-08-07 17:13     ` Bastien
2007-08-07 20:03     ` Christian Egli
2007-08-07 20:14 ` Christian Egli
2007-08-09  5:05 ` Carsten Dominik
2007-08-11 14:29   ` ignotus
2007-08-21 10:19     ` Carsten Dominik
2007-08-21 10:43       ` Carsten Dominik
2007-08-21 11:33       ` Bastien
2007-08-11 15:31   ` ignotus [this message]
2007-08-11 16:34     ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87odheulxs.fsf@freemail.hu \
    --to=ignotus@freemail.hu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).