From: David Maus <dmaus@ictsoc.de>
To: emacs-orgmode@gnu.org
Cc: David Maus <dmaus@ictsoc.de>
Subject: [PATCH 3/5] New customization variable: Loop over headlines in active region
Date: Thu, 25 Aug 2011 06:25:32 +0200 [thread overview]
Message-ID: <1314246334-5053-4-git-send-email-dmaus@ictsoc.de> (raw)
In-Reply-To: <87obzpl3ec.fsf@gnu.org>
* org.el (org-loop-over-headlines-in-active-region): New customization
variable. Loop over headlines in active region.
(org-schedule, org-deadline): Apply to headlines in region depending
on new customization variable.
---
lisp/org.el | 159 ++++++++++++++++++++++++++++++++++------------------------
1 files changed, 93 insertions(+), 66 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 27bad52..d15c946 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -402,6 +402,25 @@ XEmacs user should have this variable set to nil, because
(const :tag "When outside special context" t)
(const :tag "Everywhere except timestamps" always)))
+(defcustom org-loop-over-headlines-in-active-region nil
+ "Shall some commands act upon headlines in the active region?
+
+When set to `t', some commands will be performed in all headlines
+within the active region.
+
+When set to a string, those commands will be performed on the
+matching headlines within the active region. Such string must be
+a tags/property/todo match as it is used in the agenda tags view.
+
+The list of commands is:
+- `org-schedule'
+- `org-deadline'"
+ :type '(choice (const :tag "Don't loop" nil)
+ (const :tag "All headlines in active region" t)
+ (string :tag "Tags/Property/Todo matcher"))
+ :group 'org-todo
+ :group 'org-archive)
+
(defgroup org-startup nil
"Options concerning startup of Org-mode."
:tag "Org Startup"
@@ -11807,39 +11826,43 @@ With argument REMOVE, remove any deadline from the item.
With argument TIME, set the deadline at the corresponding date. TIME
can either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
(interactive "P")
- (let* ((old-date (org-entry-get nil "DEADLINE"))
- (repeater (and old-date
- (string-match
- "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
- old-date)
- (match-string 1 old-date))))
- (if remove
- (progn
- (when (and old-date org-log-redeadline)
- (org-add-log-setup 'deldeadline nil old-date 'findpos
- org-log-redeadline))
- (org-remove-timestamp-with-keyword org-deadline-string)
- (message "Item no longer has a deadline."))
- (org-add-planning-info 'deadline time 'closed)
- (when (and old-date org-log-redeadline
- (not (equal old-date
- (substring org-last-inserted-timestamp 1 -1))))
- (org-add-log-setup 'redeadline nil old-date 'findpos
- org-log-redeadline))
- (when repeater
- (save-excursion
- (org-back-to-heading t)
- (when (re-search-forward (concat org-deadline-string " "
- org-last-inserted-timestamp)
- (save-excursion
- (outline-next-heading) (point)) t)
- (goto-char (1- (match-end 0)))
- (insert " " repeater)
- (setq org-last-inserted-timestamp
- (concat (substring org-last-inserted-timestamp 0 -1)
- " " repeater
- (substring org-last-inserted-timestamp -1))))))
- (message "Deadline on %s" org-last-inserted-timestamp))))
+ (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
+ (let (org-loop-over-headlines-in-active-region)
+ (org-map-entries
+ `(org-deadline ',remove ,time) org-loop-over-headlines-in-active-region 'region))
+ (let* ((old-date (org-entry-get nil "DEADLINE"))
+ (repeater (and old-date
+ (string-match
+ "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
+ old-date)
+ (match-string 1 old-date))))
+ (if remove
+ (progn
+ (when (and old-date org-log-redeadline)
+ (org-add-log-setup 'deldeadline nil old-date 'findpos
+ org-log-redeadline))
+ (org-remove-timestamp-with-keyword org-deadline-string)
+ (message "Item no longer has a deadline."))
+ (org-add-planning-info 'deadline time 'closed)
+ (when (and old-date org-log-redeadline
+ (not (equal old-date
+ (substring org-last-inserted-timestamp 1 -1))))
+ (org-add-log-setup 'redeadline nil old-date 'findpos
+ org-log-redeadline))
+ (when repeater
+ (save-excursion
+ (org-back-to-heading t)
+ (when (re-search-forward (concat org-deadline-string " "
+ org-last-inserted-timestamp)
+ (save-excursion
+ (outline-next-heading) (point)) t)
+ (goto-char (1- (match-end 0)))
+ (insert " " repeater)
+ (setq org-last-inserted-timestamp
+ (concat (substring org-last-inserted-timestamp 0 -1)
+ " " repeater
+ (substring org-last-inserted-timestamp -1))))))
+ (message "Deadline on %s" org-last-inserted-timestamp)))))
(defun org-schedule (&optional remove time)
"Insert the SCHEDULED: string with a timestamp to schedule a TODO item.
@@ -11847,39 +11870,43 @@ With argument REMOVE, remove any scheduling date from the item.
With argument TIME, scheduled at the corresponding date. TIME can
either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
(interactive "P")
- (let* ((old-date (org-entry-get nil "SCHEDULED"))
- (repeater (and old-date
- (string-match
- "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
- old-date)
- (match-string 1 old-date))))
- (if remove
- (progn
- (when (and old-date org-log-reschedule)
- (org-add-log-setup 'delschedule nil old-date 'findpos
- org-log-reschedule))
- (org-remove-timestamp-with-keyword org-scheduled-string)
- (message "Item is no longer scheduled."))
- (org-add-planning-info 'scheduled time 'closed)
- (when (and old-date org-log-reschedule
- (not (equal old-date
- (substring org-last-inserted-timestamp 1 -1))))
- (org-add-log-setup 'reschedule nil old-date 'findpos
- org-log-reschedule))
- (when repeater
- (save-excursion
- (org-back-to-heading t)
- (when (re-search-forward (concat org-scheduled-string " "
- org-last-inserted-timestamp)
- (save-excursion
- (outline-next-heading) (point)) t)
- (goto-char (1- (match-end 0)))
- (insert " " repeater)
- (setq org-last-inserted-timestamp
- (concat (substring org-last-inserted-timestamp 0 -1)
- " " repeater
- (substring org-last-inserted-timestamp -1))))))
- (message "Scheduled to %s" org-last-inserted-timestamp))))
+ (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
+ (let (org-loop-over-headlines-in-active-region)
+ (org-map-entries
+ `(org-schedule ',remove ,time) org-loop-over-headlines-in-active-region 'region))
+ (let* ((old-date (org-entry-get nil "SCHEDULED"))
+ (repeater (and old-date
+ (string-match
+ "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
+ old-date)
+ (match-string 1 old-date))))
+ (if remove
+ (progn
+ (when (and old-date org-log-reschedule)
+ (org-add-log-setup 'delschedule nil old-date 'findpos
+ org-log-reschedule))
+ (org-remove-timestamp-with-keyword org-scheduled-string)
+ (message "Item is no longer scheduled."))
+ (org-add-planning-info 'scheduled time 'closed)
+ (when (and old-date org-log-reschedule
+ (not (equal old-date
+ (substring org-last-inserted-timestamp 1 -1))))
+ (org-add-log-setup 'reschedule nil old-date 'findpos
+ org-log-reschedule))
+ (when repeater
+ (save-excursion
+ (org-back-to-heading t)
+ (when (re-search-forward (concat org-scheduled-string " "
+ org-last-inserted-timestamp)
+ (save-excursion
+ (outline-next-heading) (point)) t)
+ (goto-char (1- (match-end 0)))
+ (insert " " repeater)
+ (setq org-last-inserted-timestamp
+ (concat (substring org-last-inserted-timestamp 0 -1)
+ " " repeater
+ (substring org-last-inserted-timestamp -1))))))
+ (message "Scheduled to %s" org-last-inserted-timestamp)))))
(defun org-get-scheduled-time (pom &optional inherit)
"Get the scheduled time as a time tuple, of a format suitable
--
1.7.2.5
next prev parent reply other threads:[~2011-08-25 4:26 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-18 8:32 New feature: loop over siblings for some commands Bastien
2011-07-19 18:27 ` David Maus
2011-07-20 19:46 ` David Maus
2011-07-27 15:28 ` Bastien
2011-07-27 18:47 ` David Maus
2011-07-28 8:54 ` Bastien
2011-08-10 8:34 ` David Maus
2011-08-12 7:58 ` David Maus
2011-08-16 16:36 ` Bastien
2011-08-25 4:25 ` [PATCH 0/5] loop over headlines in active region David Maus
2011-08-25 6:13 ` Carsten Dominik
2011-08-28 13:58 ` David Maus
2011-08-29 9:29 ` Carsten Dominik
2011-08-30 4:36 ` David Maus
2011-08-25 10:08 ` Štěpán Němec
2011-08-28 13:57 ` David Maus
2011-09-07 19:34 ` Štěpán Němec
2011-09-09 4:06 ` David Maus
2011-09-09 10:26 ` Štěpán Němec
2011-09-09 10:41 ` Bastien
2011-09-09 10:46 ` Štěpán Němec
2011-09-09 15:10 ` David Maus
2011-09-09 15:26 ` Štěpán Němec
2011-09-09 15:52 ` David Maus
2011-10-06 8:35 ` Carsten Dominik
2011-10-08 18:59 ` David Maus
2011-10-08 20:11 ` Carsten Dominik
2011-10-08 20:55 ` David Maus
2011-08-25 4:25 ` [PATCH 1/5] Extend scope 'region to include body of last headline " David Maus
2011-08-25 5:40 ` Carsten Dominik
2011-08-30 4:33 ` David Maus
2011-08-25 4:25 ` [PATCH 2/5] Immediately return if scope is region but no region is active David Maus
2011-08-25 5:43 ` Carsten Dominik
2011-08-28 14:00 ` David Maus
2011-08-29 9:31 ` Carsten Dominik
2011-08-30 4:40 ` David Maus
2011-08-25 4:25 ` David Maus [this message]
2011-08-25 4:25 ` [PATCH 4/5] Skip invisible headlines when mapping over headlines in active region David Maus
2011-08-25 4:25 ` [PATCH 5/5] Avoid conflict between bulk command and loop-over-headlines David Maus
2011-10-22 14:23 ` Bastien
2011-07-27 15:23 ` New feature: loop over siblings for some commands 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=1314246334-5053-4-git-send-email-dmaus@ictsoc.de \
--to=dmaus@ictsoc.de \
--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).