From: John Sullivan Date: Sun, 15 Feb 2009 03:59:54 +0000 (-0500) Subject: Finally commit patch from Bradley Kuhn at the SFLC to allow - to be used as date... X-Git-Url: https://repo.or.cz/w/planner-el.git/commitdiff_plain/abc7ce7701e094b28cc08404bd09eef703e56252 Finally commit patch from Bradley Kuhn at the SFLC to allow - to be used as date separator. Add mention to documentation. --- diff --git a/ChangeLog b/ChangeLog index 7905545..11082e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-02-14 John Sullivan + + * planner.el, planner-deadline.el, planner-notes-index.el, + planner-rank.el, planner-rdf.el, planner-timeclock-summary.el, + planner-trunk.el: Finally merge patch from Bradley Kuhn at the + Software Freedom Law Center to allow "-" to be used as the date + separator. A customizable variable, planner-date-separator, allows + the user to choose which separator they prefer. The regexes that + match dates throughout the planner codebase have been changed to + match both. Closes #8205. + 2009-02-08 John Sullivan * planner-el.texi (Publishing Planner pages): Fix typo, closes diff --git a/planner-deadline.el b/planner-deadline.el index a24b5b1..2798741 100644 --- a/planner-deadline.el +++ b/planner-deadline.el @@ -2,6 +2,7 @@ ;; Copyright (C) 2004, 2005, 2008 Free Software Foundation, Inc. ;; Parts copyright (C) 2004, 2005, 2008 Dryice Dong Liu +;; Parts copyright (C) 2006, 2007 Software Freedom Law Center ;; Author: Sandra Jean Chua (Sacha) ;; URL: http://www.wjsullivan.net/PlannerMode.html @@ -51,7 +52,7 @@ Point will be on the same line as the task." :options '(planner-deadline-update) :group 'planner-deadline) -(defcustom planner-deadline-regexp "\\({{Deadline:\\s-+\\([0-9]+\\.[0-9]+\\.[0-9]+\\)[^}\n]*}}\\)" +(defcustom planner-deadline-regexp "\\({{Deadline:\\s-+\\([0-9]+[\\.\\-][0-9]+[\\.\\-][0-9]+\\)[^}]*}}\\)" "Regular expression for deadline data. The special deadline string should be regexp group 1. The date (YYYY.MM.DD) should be regexp group 2." diff --git a/planner-el.texi b/planner-el.texi index 6bee701..79cd13a 100644 --- a/planner-el.texi +++ b/planner-el.texi @@ -14,7 +14,7 @@ @copying This manual is for Planner version 3.42. -Copyright @copyright{} 2001, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.@* +Copyright @copyright{} 2001, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.@* Parts copyright @copyright{} 2005 Jim Ottaway@* Parts copyright @copyright{} 2005 Dryice Dong Liu @@ -1513,8 +1513,10 @@ wonderful ideas about planning in Emacs! @comment node-name, next, previous, up @section Starting with Day Pages -@command{planner-goto-today} opens today's page. Day pages are named -@samp{YYYY.MM.DD} and contain your notes for the day. +@command{planner-goto-today} opens today's page. Day pages are named +@samp{YYYY.MM.DD} and contain your notes for the day. They can also be +named @samp{YYYY-MM-DD} if you prefer -- just customize the value of +@var{planner-date-separator}. You should see a file that looks like this: diff --git a/planner-notes-index.el b/planner-notes-index.el index 2681a7c..0bccc8f 100644 --- a/planner-notes-index.el +++ b/planner-notes-index.el @@ -1,6 +1,7 @@ ;;; planner-notes-index.el --- Note indexing support for the Emacs planner ;; Copyright (C) 2004, 2005, 2006, 2008 Free Software Foundation, Inc. +;; Parts copyright (C) 2006, 2007 Software Freedom Law Center ;;; Commentary: @@ -210,10 +211,11 @@ Examples: (insert "
" (if (and (>= day 1) (<= day last)) - (format "[[%s.%02d]]" month day) + (format (concat "[[%s" planner-date-separator "%02d]]") month day) "") "
\n") - (let ((data (assoc (format "%s.%02d" month day) + (let ((data (assoc (format (concat "%s" planner-date-separator "%02d") + month day) headlines)) extra) (planner-notes-index-insert-as-list diff --git a/planner-rank.el b/planner-rank.el index 38913b2..10ca9b9 100644 --- a/planner-rank.el +++ b/planner-rank.el @@ -3,6 +3,7 @@ ;; Copyright (C) 2005, 2008 Dryice Dong Liu . All rights reserved. ;; Parts copyright (C) 2005, 2008 Free Software Foundation, Inc. +;; Parts copyright (C) 2006, 2007 Software Freedom Law Center ;; Keywords: emacs planner important emergent rank deadline ;; Author: Dryice Liu @@ -154,7 +155,7 @@ urgency value, and return the calculated rank value." (add-hook 'planner-deadline-change-hook 'planner-rank-update-current-task) (defconst planner-rank-regexp -"\\(\\s-*{{Rank:\\s-+\\([0-9]\\.[0-9]+\\)\\s-+-\\s-+I=\\([0-9]\\)\\s-+U=\\([0-9]\\)}}\\)" +"\\(\\s-*{{Rank:\\s-+\\([0-9][\\.\\-][0-9]+\\)\\s-+-\\s-+I=\\([0-9]\\)\\s-+U=\\([0-9]\\)}}\\)" "Regular expression for rank data. Regexp group 1 is the whole rank string. Regexp group 2 is the rank value. diff --git a/planner-rdf.el b/planner-rdf.el index a10abdf..58a3188 100644 --- a/planner-rdf.el +++ b/planner-rdf.el @@ -2,6 +2,7 @@ ;; Copyright (C) 2004, 2008 Rainer Volz ;; Parts copyright (C) 2005, 2008 Free Software Foundation, Inc. +;; Parts copyright (C) 2006, 2007 Software Freedom Law Center ;; Author: Rainer Volz, http://www.rainervolz.de ;; Version: 0.1 @@ -585,7 +586,7 @@ of the standard output to provide customised content." (defun planner-rdf-insert-page-info (name tasks notes) "Create a page object." (insert "\n") - (let ((type (if (string-match "^[0-9]\\{4\\}\\.[0-9]\\{2\\}\\.[0-9]\\{2\\}" name) + (let ((type (if (string-match "^[0-9]\\{4\\}[\\.\\-][0-9]\\{2\\}[\\.\\-][0-9]\\{2\\}" name) planner-rdf-pagetype-day planner-rdf-pagetype-project))) (insert "\t\n") @@ -619,7 +620,7 @@ of the standard output to provide customised content." (insert "\t" (file-name-nondirectory file) "\n") (insert "\t" planner-rdf-base "page-" name "\n") (insert "\ttext\n") - (if (string-match "^[0-9]\\{4\\}\\.[0-9]\\{2\\}\\.[0-9]\\{2\\}" name) + (if (string-match "^[0-9]\\{4\\}[\\.\\-][0-9]\\{2\\}[\\.\\-][0-9]\\{2\\}" name) (progn (insert "\t" planner-rdf-pagetype-day "\n") (insert diff --git a/planner-timeclock-summary.el b/planner-timeclock-summary.el index d19835b..5deaaac 100644 --- a/planner-timeclock-summary.el +++ b/planner-timeclock-summary.el @@ -5,6 +5,7 @@ ;; Parts copyright (C) 2004, 2005, 2008 Chris Parsons (chris.p AT rsons.org) ;; Parts copyright (C) 2004, 2005, 2008 Free Software Foundation, Inc. ;; Parts copyright (C) 2005, 2008 Peter K. Lee +;; Parts copyright (C) 2006, 2007 Software Freedom Law Center ;; Keywords: emacs planner timeclock report summary ;; Author: Dryice Liu @@ -463,7 +464,7 @@ The section is updated only if it exists." (insert "* " planner-timeclock-summary-section "\n\n") (insert (if (and thepage (string-match planner-date-regexp thepage)) (planner-timeclock-summary-make-text-table-day - (planner-replace-regexp-in-string "\\." "/" + (planner-replace-in-string thepage "[\\.\\-]" "/" t thepage t t)) (planner-timeclock-summary-make-text-table-day nil nil @@ -533,8 +534,8 @@ Dates are strings in the form YYYY.MM.DD and can be nil." (concat start-date " - " end-date)) "\n\n" (planner-timeclock-summary-make-text-table-day - (planner-replace-regexp-in-string "\\." "/" start-date t t) - (planner-replace-regexp-in-string "\\." "/" end-date t t) + (planner-replace-regexp-in-string "[\\.\\-]" "/" start-date t t) + (planner-replace-regexp-in-string "[\\.\\-]" "/" end-date t t) filter)) (planner-mode)) (goto-char (point-min))) @@ -604,7 +605,7 @@ given." (insert "Timeclock summary report for " date "\n\n") (planner-mode) (planner-timeclock-summary-make-table-day - (planner-replace-regexp-in-string "\\." "/" date t t) (point))) + (planner-replace-regexp-in-string "[\\.\\-]" "/" date t t) (point))) (goto-char (point-min))) (defun planner-timeclock-summary-table-span-cell-left () diff --git a/planner-trunk.el b/planner-trunk.el index 7a945ed..58d784e 100644 --- a/planner-trunk.el +++ b/planner-trunk.el @@ -4,6 +4,7 @@ ;; Copyright (C) 2005, 2008 Dryice Dong Liu . All rights reserved. ;; Parts copyright (C) 2005, 2008 Keith Amidon ;; Parts copyright (C) 2005, 2008 Free Software Foundation, Inc. +;; Parts copyright (C) 2006, 2007 Software Freedom Law Center ;; Keywords: emacs planner trunk group tasks ;; Authors: Dryice Liu @@ -113,7 +114,7 @@ use, it will become obvious why this is desirable." :type '(repeat (list :tag "Trunk rule" (choice :tag "Page regexp" - (const "\\`[0-9][0-9][0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9]\\'" + (const "\\`[0-9][0-9][0-9][0-9][\\.\\-][0-9][0-9][\\.\\-][0-9][0-9]\\'" :tag "Day pages") (const "." :tag "All pages") (regexp :tag "Regexp")) diff --git a/planner.el b/planner.el index be04ded..09d9259 100644 --- a/planner.el +++ b/planner.el @@ -18,6 +18,7 @@ ;; Parts copyright (C) 2005, 2008 Sergey Vlasov (vsu AT altlinux.ru) ;; Parts copyright (C) 2005, 2008 Yann Hodique (hodique AT lifl DOT fr) ;; Parts copyright (C) 2005, 2008 Peter K. Lee +;; Parts copyright (C) 2006, 2007 Software Freedom Law Center ;; Emacs Lisp Archive Entry ;; Filename: planner.el @@ -598,6 +599,21 @@ By default, dates are based on the current page." :prefix "planner-" :group 'planner) +; Note that if you add another choice other than '.' or '-' here, you'll need +; to grep through the code for [\\.\\-] and replace it with a regex that matches +; all possible date-separators. I thought about making a variable that builds +; all the regexes used elsewhere, but it made the code messy, it seemed, and +; I didn't imagine too many other separators people would want. Myabe '/', but +; that would cause it's own world of hurt. -- bkuhn, 2007-01-09 + +(defcustom planner-date-separator "." + "This character will be used to separate year, month and day numbers + when formatting dates" + :type '(choice + (const :tag "Dates should be in the form YYYY.MM.DD" ".") + (const :tag "Dates should be in the form YYYY-MM-DD" "-")) + :group 'planner) + (defcustom planner-carry-tasks-forward 3 "If non-nil, carry unfinished tasks forward automatically. If a positive integer, scan that number of days in the past. @@ -1071,7 +1087,7 @@ does to the diary buffer." ;; (muse-colors-buffer)))) (defvar planner-date-regexp - "\\<\\([1-9][0-9][0-9][0-9]\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\>") + "\\<\\([1-9][0-9][0-9][0-9]\\)[\\.\\-]\\([0-9]+\\)[\\.\\-]\\([0-9]+\\)\\>") (defun planner-setup-highlighting () "Set up fontification for planner." @@ -1145,6 +1161,7 @@ instead of a string." (funcall planner-delete-file-function filename))) (kill-buffer (current-buffer)))) + (defun planner-prepare-file () "Insert some standard sections into an empty planner file." (when (= (buffer-size) 0) @@ -1306,7 +1323,9 @@ using day pages." (format "%s %s" (or prompt "When") (format-time-string - "(%Y.%m.%d, %m.%d, %d): "))))) + (concat "(%Y" planner-date-separator "%m" + planner-date-separator "%d, %m" + planner-date-separator "%d, %d): ")))))) (or planner-calendar-selected-date (with-current-buffer old-buffer (planner-expand-name text))))) @@ -1334,14 +1353,17 @@ Should be a string of the form YYYY.MM.DD. If nil, do not timewarp.") (defun planner-date-to-filename (date) "Return the planner filename corresponding to DATE. DATE is a list (month day year) or an internal date representation." - (if (= (length date) 3) - (format "%04d.%02d.%02d" (elt date 2) (elt date 0) (elt date 1)) + (let ( (date-form-string (concat "%04d" planner-date-separator "%02d" + planner-date-separator "%02d") ) ) + (progn + (if (= (length date) 3) + (format date-form-string (elt date 2) (elt date 0) (elt date 1)) (if (= (length date) 2) (setq date (decode-time date))) - (format "%04d.%02d.%02d" + (format date-form-string (elt date 5) ; year (elt date 4) ; month - (elt date 3)))) ; day + (elt date 3)))))) ; day (defun planner-calculate-date-from-day-offset (origin offset) "From ORIGIN, calculate the date OFFSET days into the past or future. @@ -1457,8 +1479,8 @@ defaults." ((string= "." name) (if (not planner-use-day-pages) (planner-date-to-filename now) (planner-today))) - ((string-match (concat "^\\([1-9][0-9][0-9][0-9]\\.\\)?" - "\\(\\([0-9]+\\)\\.\\)?" + ((string-match (concat "^\\([1-9][0-9][0-9][0-9][\\.\\-]\\)?" + "\\(\\([0-9]+\\)[\\.\\-]\\)?" "\\([0-9]+\\)\\(#.*\\)?$") name) (setq name-year (if (match-string 1 name) @@ -1500,8 +1522,7 @@ defaults." (string-match (concat "^\\([-+]\\)\\s-*\\([0-9]*\\)\\s-*\\(" (mapconcat 'car planner-expand-name-days-alist "\\|") - "\\)\\s-*\\(\\.\\|\\(\\(\\([0-9]+\\.\\)?[0-9]+\\.\\)?" - "[0-9]+\\)\\)?$") + "\\)\\s-*\\([\\.\\-]\\|\\(\\(\\([0-9]+[\\.\\-]\\)?[0-9]+[\\-\\.]\\)?[0-9]+\\)\\)?$") name)) (let* ((day (cdr (assoc (match-string 3 name) planner-expand-name-days-alist)))