From 8833885abb6231207fe14ec62d3ee92706ae544b Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Thu, 18 Sep 2008 10:24:57 +0200 Subject: [PATCH] Make S-right/left work in column view for any timestamp value of a property. --- ORGWEBPAGE/Changes.org | 7 +++++++ doc/org.texi | 11 +---------- lisp/ChangeLog | 12 ++++++++++++ lisp/org-colview-xemacs.el | 23 ++++++++++++++++++++++- lisp/org-colview.el | 23 ++++++++++++++++++++++- 5 files changed, 64 insertions(+), 12 deletions(-) diff --git a/ORGWEBPAGE/Changes.org b/ORGWEBPAGE/Changes.org index 7412571a4..f36da4e1d 100644 --- a/ORGWEBPAGE/Changes.org +++ b/ORGWEBPAGE/Changes.org @@ -187,6 +187,13 @@ For more information, look at the variable =org-columns-modify-value-for-display-function=. +*** In column view, date stamps now always have allowed values defined. + + If a property value is a time stamp, S-left and S-right can + now be used to shift this date around. + + This was a request by Chris Randle. + * Version 6.06 ** Overview diff --git a/doc/org.texi b/doc/org.texi index 03e5dcce6..f66a777eb 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -3625,15 +3625,6 @@ release, number of tracks, and so on. Properties can be conveniently edited and viewed in column view (@pxref{Column view}). -Properties are like tags, but with a value. For example, in a file -where you document bugs and plan releases of a piece of software, -instead of using tags like @code{:release_1:}, @code{:release_2:}, it -can be more efficient to use a property @code{:Release:} with a value -@code{1.0} or @code{2.0}. Second, you can use properties to implement -(very basic) database capabilities in an Org buffer, for example to -create a list of Music CD's you own. You can edit and view properties -conveniently in column view (@pxref{Column view}). - @menu * Property syntax:: How properties are spelled out * Special properties:: Access to other Org mode features @@ -4034,7 +4025,7 @@ current column view. Make the column narrower/wider by one character. @kindex S-M-@key{right} @item S-M-@key{right} -Insert a new column, to the right of the current column. +Insert a new column, to the left of the current column. @kindex S-M-@key{left} @item S-M-@key{left} Delete the current column. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index acf8cbd32..5a2d262c4 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,15 @@ +2008-09-18 Carsten Dominik + + * org-colview.el (org-colview-construct-allowed-dates): New + function. + (org-columns-next-allowed-value): Use + `org-colview-construct-allowed-dates'. + + * org-colview-xemacs.el (org-colview-construct-allowed-dates): New + function. + (org-columns-next-allowed-value): Use + `org-colview-construct-allowed-dates'. + 2008-09-17 Carsten Dominik * org.el (org-protect-slash): New function. diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el index 4acad13dc..038232a3f 100644 --- a/lisp/org-colview-xemacs.el +++ b/lisp/org-colview-xemacs.el @@ -735,7 +735,8 @@ an integer, select that value." (and (memq (nth 4 (assoc key org-columns-current-fmt-compiled)) '(checkbox checkbox-n-of-m checkbox-percent)) - '("[ ]" "[X]")))) + '("[ ]" "[X]")) + (org-colview-construct-allowed-dates value))) nval) (when (integerp nth) (setq nth (1- nth)) @@ -784,6 +785,26 @@ an integer, select that value." (and (nth 3 (assoc key org-columns-current-fmt-compiled)) (org-columns-update key)))))) +(defun org-colview-construct-allowed-dates (s) + "Construct a list of three dates around the date in S. +This respects the format of the time stamp in S, active or non-active, +and also including time or not. S must be just a time stamp, no text +around it." + (when (string-match (concat "^" org-ts-regexp3 "$") s) + (let* ((time (org-parse-time-string s 'nodefaults)) + (active (equal (string-to-char s) ?<)) + (fmt (funcall (if (nth 1 time) 'cdr 'car) org-time-stamp-formats))) + (unless active (setq fmt (concat "[" (substring fmt 1 -1) "]"))) + (setf (car time) (or (car time) 0)) + (setf (nth 1 time) (or (nth 1 time) 0)) + (setf (nth 2 time) (or (nth 2 time) 0)) + (setq time-before (copy-sequence time)) + (setq time-after (copy-sequence time)) + (setf (nth 3 time-before) (1- (nth 3 time))) + (setf (nth 3 time-after) (1+ (nth 3 time))) + (mapcar (lambda (x) (format-time-string fmt (apply 'encode-time x))) + (list time-before time time-after))))) + (defun org-verify-version (task) (cond ((eq task 'columns) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 761309e1a..55637d06d 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -538,7 +538,8 @@ an integer, select that value." (and (memq (nth 4 (assoc key org-columns-current-fmt-compiled)) '(checkbox checkbox-n-of-m checkbox-percent)) - '("[ ]" "[X]")))) + '("[ ]" "[X]")) + (org-colview-construct-allowed-dates value))) nval) (when (integerp nth) (setq nth (1- nth)) @@ -587,6 +588,26 @@ an integer, select that value." (and (nth 3 (assoc key org-columns-current-fmt-compiled)) (org-columns-update key)))))) +(defun org-colview-construct-allowed-dates (s) + "Construct a list of three dates around the date in S. +This respects the format of the time stamp in S, active or non-active, +and also including time or not. S must be just a time stamp, no text +around it." + (when (string-match (concat "^" org-ts-regexp3 "$") s) + (let* ((time (org-parse-time-string s 'nodefaults)) + (active (equal (string-to-char s) ?<)) + (fmt (funcall (if (nth 1 time) 'cdr 'car) org-time-stamp-formats))) + (unless active (setq fmt (concat "[" (substring fmt 1 -1) "]"))) + (setf (car time) (or (car time) 0)) + (setf (nth 1 time) (or (nth 1 time) 0)) + (setf (nth 2 time) (or (nth 2 time) 0)) + (setq time-before (copy-sequence time)) + (setq time-after (copy-sequence time)) + (setf (nth 3 time-before) (1- (nth 3 time))) + (setf (nth 3 time-after) (1+ (nth 3 time))) + (mapcar (lambda (x) (format-time-string fmt (apply 'encode-time x))) + (list time-before time time-after))))) + (defun org-verify-version (task) (cond ((eq task 'columns) -- 2.11.4.GIT