From: Ivanov Dmitry <usr345@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] /contrib/lisp/org-collector.el
Date: Tue, 10 Aug 2010 14:13:51 +0400 [thread overview]
Message-ID: <733883921.20100810141351@gmail.com> (raw)
[-- 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
next reply other threads:[~2010-08-10 10:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-10 10:13 Ivanov Dmitry [this message]
2010-08-10 15:24 ` [PATCH] /contrib/lisp/org-collector.el Eric Schulte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=733883921.20100810141351@gmail.com \
--to=usr345@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public 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).