diff options
author | Ivanov Dmitry <usr345@gmail.com> | 2010-08-10 09:22:24 -0600 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-08-10 09:22:24 -0600 |
commit | b36cf7a4374d9f92359fbd9918e3940d808ff80d (patch) | |
tree | f9f57388ce5674d6559f436996208d748feb3a55 | |
parent | a978d99a6eb147574c9252fbc798c592ab910d44 (diff) | |
download | org-mode-b36cf7a4374d9f92359fbd9918e3940d808ff80d.tar.gz |
org-collector: better comments and more robust conversion of string to elisp
* contrib/lisp/org-collector.el (org-read-prop): added a more detailed
comment, changed 2 if stements to 1 cond to make the code more
comprehensible, added
(condition-case nil
(read prop)
(error prop))
instead of
(read prop)
so, if any error occurs during the conversion of prop to lisp
expression - a string will be returned.
-rw-r--r-- | contrib/lisp/org-collector.el | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/contrib/lisp/org-collector.el b/contrib/lisp/org-collector.el index 2646b3f..1d4f042 100644 --- a/contrib/lisp/org-collector.el +++ b/contrib/lisp/org-collector.el @@ -111,18 +111,31 @@ a column, or through the generation of an error.") (defun org-read-prop (prop) "Convert the string property PROP to a number if appropriate. -Otherwise if prop looks like a list (meaning it starts with a -'(') then read it as lisp, otherwise return it unmodified as a -string." +If prop looks like a list (meaning it starts with a '(') then +read it as lisp expression, otherwise return it unmodified as a +string. + +Results of calling: +\(org-read-prop \"12\") -> 12 +\(org-read-prop \"(1 2 3)\") -> (1 2 3) +\(org-read-prop \"+0\") -> 0 +\(org-read-prop \"aaa\") -> \"aaa\"" (if (and (stringp prop) (not (equal prop ""))) (let ((out (string-to-number prop))) (if (equal out 0) - (if (or (equal "(" (substring prop 0 1)) (equal "'" (substring prop 0 1))) - (read prop) - (if (string-match "^\\(+0\\|-0\\|0\\)$" prop) - 0 - (progn (set-text-properties 0 (length prop) nil prop) - prop))) + (cond + ((or + (equal "(" (substring prop 0 1)) + (equal "'" (substring prop 0 1))) + + (condition-case nil + (read prop) + (error prop))) + ((string-match "^\\(+0\\|-0\\|0\\)$" prop) + 0) + (t + (set-text-properties 0 (length prop) nil prop) + prop)) out)) prop)) @@ -219,4 +232,4 @@ variables and values specified in props" (delq nil results)) '())) (provide 'org-collector) -;;; org-collector ends here
\ No newline at end of file +;;; org-collector ends here |