emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] /contrib/lisp/org-collector.el
@ 2010-08-10 10:13 Ivanov Dmitry
  2010-08-10 15:24 ` Eric Schulte
  0 siblings, 1 reply; 2+ messages in thread
From: Ivanov Dmitry @ 2010-08-10 10:13 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 368 bytes --]

* 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.

** The scheme of the new function if attached.

[-- Attachment #2: org-collector.el.diff --]
[-- Type: application/octet-stream, Size: 2225 bytes --]

diff --git a/contrib/lisp/org-collector.el b/contrib/lisp/org-collector.el
index 2646b3f..e358caf 100644
--- a/contrib/lisp/org-collector.el
+++ b/contrib/lisp/org-collector.el
@@ -110,21 +110,30 @@ a column, or through the generation of an error.")
      '(error column-prop-error org-collector-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 (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)))
-	  out))
-    prop))
+      "Convert the string property PROP to a number if appropriate. 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)
+                        (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))
 
 (defun org-dblock-write:propview (params)
   "collect the column specification from the #+cols line

[-- Attachment #3: org-collector.pdf --]
[-- Type: application/pdf, Size: 6968 bytes --]

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] /contrib/lisp/org-collector.el
  2010-08-10 10:13 [PATCH] /contrib/lisp/org-collector.el Ivanov Dmitry
@ 2010-08-10 15:24 ` Eric Schulte
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Schulte @ 2010-08-10 15:24 UTC (permalink / raw)
  To: Ivanov Dmitry; +Cc: emacs-orgmode

Hi,

This patch has been applied with some very minor indentation and
whitespace changes.

Thanks for the patch and the elucidation of the comments and code.

Best -- Eric

Ivanov Dmitry <usr345@gmail.com> writes:

> * 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.
>
> ** The scheme of the new function if attached.
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-10 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-10 10:13 [PATCH] /contrib/lisp/org-collector.el Ivanov Dmitry
2010-08-10 15:24 ` Eric Schulte

Code repositories for project(s) associated with this 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).