Time comparisons for property searches.
This commit is contained in:
parent
507700505a
commit
7becc742cd
|
@ -18,14 +18,43 @@
|
|||
** Overview
|
||||
** Details
|
||||
|
||||
*** New variable =org-export-html-style-extra=
|
||||
*** New setup for HTML style information
|
||||
In order to create a more CSS-like setup of the HTML style
|
||||
information, the following changes have been made:
|
||||
- The default style has moved to a constant,
|
||||
=org-export-html-style-default= and should not be changed
|
||||
anymore.
|
||||
- The default of the variable =org-export-html-style= is now
|
||||
just the empty string. This variable should receive
|
||||
settings that are Org-wide. When using org-publish, this
|
||||
variable is associated with the =:style= property and can
|
||||
be used to establish project-wide settings.
|
||||
- There is a new variable =org-export-html-style-extra= that
|
||||
should be used for file-local setings. Org-publish can, if
|
||||
necessary, access this variable with the =:style-extra=
|
||||
property.
|
||||
- When a file is published, the values of
|
||||
- org-export-html-style-default
|
||||
- org-export-html-style
|
||||
- org-export-html-style-extra
|
||||
are all inserted into the HTML header, in the given
|
||||
sequence.
|
||||
|
||||
This variable can be used to just /add/ to the default style
|
||||
in =org-export-html-style=. So if you want only small
|
||||
modifications to the default style, you no longer need to to
|
||||
copy the entire default style to your customization.
|
||||
This follows a proposal by Rustom Mody.
|
||||
|
||||
*** A way to compare times during a property search
|
||||
If the comparison value in a property search is a string that
|
||||
is enclosed in angular brackets, a time comparison will be
|
||||
done. For example
|
||||
|
||||
: +DEADLINE>="<2008-12-24 15:20>"
|
||||
|
||||
looks for entries with a deadline on or after that time.
|
||||
Special allowed values are "<now>" (with time) and "<today>"
|
||||
(date only).
|
||||
|
||||
This is based on a request by Manish.
|
||||
|
||||
*** Simplified way to specify file links
|
||||
|
||||
In a link, you can now leave uout the "file:" prefix if you
|
||||
|
|
70
doc/org.texi
70
doc/org.texi
|
@ -3757,22 +3757,40 @@ the same commands are used as for tag searches (@pxref{Tag searches}), and
|
|||
the same logic applies. For example, here is a search string:
|
||||
|
||||
@example
|
||||
+work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2+With=@{Sarah\|Denny@}
|
||||
+work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2 \
|
||||
+With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
The type of comparison will depend on how the comparison value is written:
|
||||
@itemize @minus
|
||||
@item
|
||||
If the comparison value is a plain number, a numerical comparison is done,
|
||||
and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
|
||||
@samp{>=}, and @samp{<>}. If the comparison value is enclosed in double
|
||||
quotes, a string comparison is done, and the same operators are allowed. If
|
||||
the comparison value is enclosed in curly braces, a regexp match is
|
||||
performed, with @samp{=} meaning that the regexp matches the property value,
|
||||
and @samp{<>} meaning that it does not match. So the search string in the
|
||||
example finds entries tagged @samp{:work:} but not @samp{:boss:}, which also
|
||||
have a priority value @samp{A}, a @samp{:Coffee:} property with the value
|
||||
@samp{unlimited}, an @samp{Effort} property that is numerically smaller than
|
||||
2, and a @samp{:With:} property that is matched by the regular expression
|
||||
@samp{Sarah\|Denny}.
|
||||
@samp{>=}, and @samp{<>}.
|
||||
@item
|
||||
If the comparison value is enclosed in double
|
||||
quotes, a string comparison is done, and the same operators are allowed.
|
||||
@item
|
||||
If the comparison value is enclosed in double quotes @emph{and} angular
|
||||
brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
|
||||
assumed to be date/time specifications in the standard Org way@footnote{The
|
||||
only special values that will be recognized are @samp{"<now>"} for now, and
|
||||
@samp{"<today"} today at 0:00 hours, i.e. without a time specification.}, and
|
||||
the comparison will be done accordingly.
|
||||
@item
|
||||
If the comparison value is enclosed
|
||||
in curly braces, a regexp match is performed, with @samp{=} meaning that the
|
||||
regexp matches the property value, and @samp{<>} meaning that it does not
|
||||
match.
|
||||
@end itemize
|
||||
|
||||
So the search string in the example finds entries tagged @samp{:work:} but
|
||||
not @samp{:boss:}, which also have a priority value @samp{A}, a
|
||||
@samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
|
||||
property that is numerically smaller than 2, a @samp{:With:} property that is
|
||||
matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
|
||||
on or after December 24, 2008.
|
||||
|
||||
You can configure Org mode to use property inheritance during a search, but
|
||||
beware that this can slow down searches considerably. See @ref{Property
|
||||
|
@ -7344,29 +7362,31 @@ document - your style specifications may change these:
|
|||
.target @r{target for links}
|
||||
@end example
|
||||
|
||||
The default style specification can be configured through the option
|
||||
@code{org-export-html-style}. You can also just @emph{add} to the default
|
||||
(instead of overwriting it) by using the option
|
||||
@code{org-export-html-style-extra}. If you want to use a file-local style,
|
||||
you may use file variables, best wrapped into a COMMENT section at the end of
|
||||
the outline tree. For example@footnote{Under Emacs 21, the continuation
|
||||
lines for a variable value should have no @samp{#} at the start of the
|
||||
line.}:
|
||||
Each exported files contains a compact default style that defines these
|
||||
classes in a basic way. You may overwrite these settings, or add to them by
|
||||
using the variables @code{org-export-html-style} (for Org-wide settings) and
|
||||
@code{org-export-html-style-extra} (for more granular settings, like
|
||||
file-local settings). If you want to use a file-local style, you may use
|
||||
file variables, best wrapped into a COMMENT section at the end of the outline
|
||||
tree. For example@footnote{Under Emacs 21, the continuation lines for a
|
||||
variable value should have no @samp{#} at the start of the line.}:
|
||||
|
||||
@example
|
||||
* COMMENT html style specifications
|
||||
|
||||
# Local Variables:
|
||||
# org-export-html-style-extra:
|
||||
# "p @{font-weight: normal; color: gray; @}
|
||||
# h1 @{color: black; @}"
|
||||
# "<style>
|
||||
# p @{font-weight: normal; color: gray; @}
|
||||
# h1 @{color: black; @}
|
||||
# </style>"
|
||||
# End:
|
||||
@end example
|
||||
|
||||
Remember to execute @kbd{M-x normal-mode} after changing this to make
|
||||
the new style visible to Emacs. This command restarts Org mode for the
|
||||
current buffer and forces Emacs to re-evaluate the local variables
|
||||
section in the buffer.
|
||||
Remember to execute @kbd{M-x normal-mode} after changing this to make the new
|
||||
style immediately visible to Emacs. This command restarts Org mode for the
|
||||
current buffer and forces Emacs to re-evaluate the local variables section in
|
||||
the buffer.
|
||||
|
||||
@c FIXME: More about header and footer styles
|
||||
@c FIXME: Talk about links and targets.
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
2008-07-01 Carsten Dominik <dominik@science.uva.nl>
|
||||
|
||||
* org.el (org-time=, org-time<, org-time<=, org-time>)
|
||||
(org-time>=, org-time<>, org-2ft): New functions.
|
||||
(org-op-to-function): Also provide for the time testing fucntions.
|
||||
|
||||
2008-06-30 Carsten Dominik <dominik@science.uva.nl>
|
||||
|
||||
* org-exp.el (org-export-html-style-default): New constant.
|
||||
|
||||
2008-06-29 Carsten Dominik <dominik@science.uva.nl>
|
||||
|
||||
* org-exp.el (org-export-html-style-extra): New variable.
|
||||
|
|
44
lisp/org.el
44
lisp/org.el
|
@ -9441,8 +9441,10 @@ also TODO lines."
|
|||
cat-p (equal pn "CATEGORY")
|
||||
re-p (equal (string-to-char pv) ?{)
|
||||
str-p (equal (string-to-char pv) ?\")
|
||||
time-p (save-match-data (string-match "^\"<.*>\"$" pv))
|
||||
pv (if (or re-p str-p) (substring pv 1 -1) pv))
|
||||
(setq po (org-op-to-function po str-p))
|
||||
(if time-p (setq pv (org-matcher-time pv)))
|
||||
(setq po (org-op-to-function po (if time-p 'time str-p)))
|
||||
(if (equal pn "CATEGORY")
|
||||
(setq gv '(get-text-property (point) 'org-category))
|
||||
(setq gv `(org-cached-entry-get nil ,pn)))
|
||||
|
@ -9497,21 +9499,46 @@ also TODO lines."
|
|||
(cons match0 matcher)))
|
||||
|
||||
(defun org-op-to-function (op &optional stringp)
|
||||
"Turn an operator into the appropriate function."
|
||||
(setq op
|
||||
(cond
|
||||
((equal op "<" ) '(< string< ))
|
||||
((equal op ">" ) '(> org-string> ))
|
||||
((member op '("<=" "=<")) '(<= org-string<= ))
|
||||
((member op '(">=" "=>")) '(>= org-string>= ))
|
||||
((member op '("=" "==")) '(= string= ))
|
||||
((member op '("<>" "!=")) '(org<> org-string<> ))))
|
||||
(nth (if stringp 1 0) op))
|
||||
((equal op "<" ) '(< string< org-time<))
|
||||
((equal op ">" ) '(> org-string> org-time>))
|
||||
((member op '("<=" "=<")) '(<= org-string<= org-time<=))
|
||||
((member op '(">=" "=>")) '(>= org-string>= org-time>=))
|
||||
((member op '("=" "==")) '(= string= org-time=))
|
||||
((member op '("<>" "!=")) '(org<> org-string<> org-time<>))))
|
||||
(nth (if (eq stringp 'time) 2 (if stringp 1 0)) op))
|
||||
|
||||
(defun org<> (a b) (not (= a b)))
|
||||
(defun org-string<= (a b) (or (string= a b) (string< a b)))
|
||||
(defun org-string>= (a b) (not (string< a b)))
|
||||
(defun org-string> (a b) (and (not (string= a b)) (not (string< a b))))
|
||||
(defun org-string<> (a b) (not (string= a b)))
|
||||
(defun org-time= (a b) (= (org-2ft a) (org-2ft b)))
|
||||
(defun org-time< (a b) (< (org-2ft a) (org-2ft b)))
|
||||
(defun org-time<= (a b) (<= (org-2ft a) (org-2ft b)))
|
||||
(defun org-time> (a b) (> (org-2ft a) (org-2ft b)))
|
||||
(defun org-time>= (a b) (>= (org-2ft a) (org-2ft b)))
|
||||
(defun org-time<> (a b) (org<> (org-2ft a) (org-2ft b)))
|
||||
(defun org-2ft (s)
|
||||
"Convert S to a floating point time.
|
||||
If S is already a number, just return it. If it is a string, parse
|
||||
it as a time string and apply `float-time' to it. f S is nil, just return 0."
|
||||
(cond
|
||||
((numberp s) s)
|
||||
((stringp s)
|
||||
(condition-case nil
|
||||
(float-time (apply 'encode-time (org-parse-time-string s)))
|
||||
(error 0.)))
|
||||
(t 0.)))
|
||||
|
||||
(defun org-matcher-time (s)
|
||||
(cond
|
||||
((equal s "<now>") (float-time))
|
||||
((equal s "<today>")
|
||||
(float-time (append '(0 0 0) (nthcdr 3 (decode-time)))))
|
||||
(t (org-2ft s))))
|
||||
|
||||
(defun org-match-any-p (re list)
|
||||
"Does re match any element of list?"
|
||||
|
@ -14539,4 +14566,3 @@ Still experimental, may disappear in the future."
|
|||
;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
|
||||
|
||||
;;; org.el ends here
|
||||
|
||||
|
|
Loading…
Reference in New Issue