emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add option to skip timestamp entries if already displayed as deadline entries in agenda
@ 2012-04-22 22:32 Toby Cubitt
  2012-04-23 12:52 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Toby Cubitt @ 2012-04-22 22:32 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

This one's pretty self-explanatory. It adds an
`org-agenda-skip-timestamp-if-deadline-is-shown' customization option,
precisely analogous to the existing
`org-agenda-skip-scheduled-if-deadline-is-shown' option.

Toby
-- 
Dr T. S. Cubitt
Mathematics and Quantum Information group
Department of Mathematics
Complutense University
Madrid, Spain

email: tsc25@cantab.net
web:   www.dr-qubit.org

[-- Attachment #2: 0001-Agenda-Add-org-agenda-skip-timestamp-if-deadline-is-.patch --]
[-- Type: text/x-patch, Size: 3617 bytes --]

From 5cae4b80d34ed7ba54532bf0a029384fcd1353a8 Mon Sep 17 00:00:00 2001
From: "Toby S. Cubitt" <tsc25@cantab.net>
Date: Sun, 29 Jan 2012 13:02:27 +0100
Subject: [PATCH] Agenda: Add org-agenda-skip-timestamp-if-deadline-is-shown

* lisp/org-agenda.el (org-agenda-skip-timestamp-if-deadline-is-shown):
Skip timestamp items in agenda view if item is already shown as a
deadline item.
(org-agenda-skip-dealine-if-done): Pass deadline results to
org-agenda-get-timestamps.
(org-agenda-get-timestamps): Optionally take list of deadline results,
so that timestamp results can be skipped if already included in
deadline results.
---
 lisp/org-agenda.el |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 796f158..aa433fa 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -776,6 +776,20 @@ but not scheduled today."
 	  (const :tag "Always" t)
 	  (const :tag "Not when scheduled today" not-today)))
 
+(defcustom org-agenda-skip-timestamp-if-deadline-is-shown nil
+  "Non-nil means skip timestamp line if same entry shows because of deadline.
+In the agenda of today, an entry can show up multiple times
+because it has both a plain timestamp and has a nearby deadline.
+When this variable is t, then only the deadline is shown and the
+fact that the entry has a timestamp for or including today is not
+shown.  When this variable is nil, the entry will be shown
+several times."
+  :group 'org-agenda-skip
+  :group 'org-agenda-daily/weekly
+  :type '(choice
+	  (const :tag "Never" nil)
+	  (const :tag "Always" t)))
+
 (defcustom org-agenda-skip-deadline-if-done nil
   "Non-nil means don't show deadlines when the corresponding item is done.
 When nil, the deadline is still shown and should give you a happy feeling.
@@ -4785,7 +4799,7 @@ the documentation of `org-diary'."
 		 ((eq arg :timestamp)
 		  (setq rtn (org-agenda-get-blocks))
 		  (setq results (append results rtn))
-		  (setq rtn (org-agenda-get-timestamps))
+		  (setq rtn (org-agenda-get-timestamps deadline-results))
 		  (setq results (append results rtn)))
 		 ((eq arg :sexp)
 		  (setq rtn (org-agenda-get-sexps))
@@ -4937,7 +4951,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 (defconst org-agenda-no-heading-message
   "No heading for this item in buffer or region.")
 
-(defun org-agenda-get-timestamps ()
+(defun org-agenda-get-timestamps (&optional deadline-results)
   "Return the date stamp information for agenda display."
   (let* ((props (list 'face 'org-agenda-calendar-event
 		      'org-not-done-regexp org-not-done-regexp
@@ -4948,6 +4962,12 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 		      (format "mouse-2 or RET jump to org file %s"
 			      (abbreviate-file-name buffer-file-name))))
 	 (d1 (calendar-absolute-from-gregorian date))
+	 mm
+	 (deadline-position-alist
+	  (mapcar (lambda (a) (and (setq mm (get-text-property
+					     0 'org-hd-marker a))
+				   (cons (marker-position mm) a)))
+		  deadline-results))
 	 (remove-re
 	  (concat
 	   (regexp-quote
@@ -5015,6 +5035,9 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 	  (if (not (re-search-backward org-outline-regexp-bol nil t))
 	      (setq txt org-agenda-no-heading-message)
 	    (goto-char (match-beginning 0))
+	    (if (and (eq t org-agenda-skip-timestamp-if-deadline-is-shown)
+		     (assoc (point) deadline-position-alist))
+		(throw :skip nil))
 	    (setq hdmarker (org-agenda-new-marker)
 		  tags (org-get-tags-at))
 	    (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
-- 
1.7.8.5


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

* Re: [PATCH] Add option to skip timestamp entries if already displayed as deadline entries in agenda
  2012-04-22 22:32 [PATCH] Add option to skip timestamp entries if already displayed as deadline entries in agenda Toby Cubitt
@ 2012-04-23 12:52 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2012-04-23 12:52 UTC (permalink / raw)
  To: emacs-orgmode

Toby Cubitt <tsc25@cantab.net> writes:

> This one's pretty self-explanatory. It adds an
> `org-agenda-skip-timestamp-if-deadline-is-shown' customization option,
> precisely analogous to the existing
> `org-agenda-skip-scheduled-if-deadline-is-shown' option.

Thanks for this, I just applied this patch.

-- 
 Bastien

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

end of thread, other threads:[~2012-04-23 12:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-22 22:32 [PATCH] Add option to skip timestamp entries if already displayed as deadline entries in agenda Toby Cubitt
2012-04-23 12:52 ` Bastien

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