From: David Maus <dmaus@ictsoc.de>
To: Ivanov Dmitry <usr345@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re[4]: programming for org-mode
Date: Sun, 08 Aug 2010 08:43:07 +0200 [thread overview]
Message-ID: <87mxsxvc3o.wl%dmaus@ictsoc.de> (raw)
In-Reply-To: <510683939.20100807192935@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1725 bytes --]
Ivanov Dmitry wrote:
>Thanks, David. I improved the scheme, added 2 question. Please, take a look.
1/
,----
| 09. (if (or (equal "(" (substring prop 0 1)) (equal "'" (substring prop 0 1)))
|
| vs.
|
| 09. (if (string-match "^'?(.*)$" prop)
`----
I wouldn't call it a flaw in the original check but a pragmatic
solution for the problem at this point. Ideally we want to check if
`prop' is a lisp expression so we can call `read' to return the
expression as lisp object. To achieve this we would need a function
that checks if the string `prop' is a valid s-expression[1]: Balanced
parentheses and valid lisp atoms. I am not an expert in regular
expressions but I think such a check can't be done with regexps but
requires an implementation of a lisp parser.
Example: (string-match "^'?(.*)$" "((foo baz)")) would return t but
"((foo baz)" is not a valid s-expression.
If we want (read prop) not to fail on an invalid s-exp but to threat
them as strings we can try to catch the error when executing `read':
,----
| (condition-case nil
| (read prop)
| (error prop))
`----
This would return the lisp object for `prop' if `prop' is a valid lisp
expression and the string `prop' otherwise (C-h f condition-case RET).
2/
,----
| 13. (progn (set-text-properties 0 (length prop) nil prop)
| 14. prop)))
`----
Setting the text-properties to nil indeed removes all
... text-properties, including colors. The `progn' is unnecessary
because the body of the else clause is not limited to one lisp
expression (C-h f if RET).
HTH,
-- David
[1] Note that the terms "s-expression", "lisp-expression", and "lisp
object" refer to one and the same structure.
[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]
[-- Attachment #2: 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 prev parent reply other threads:[~2010-08-08 16:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-15 4:52 programming for org-mode Ivanov Dmitry
2010-07-15 17:26 ` Eric Schulte
2010-07-15 20:15 ` David Maus
2010-07-15 20:21 ` David Maus
2010-07-15 21:40 ` Nick Dokos
2010-07-15 21:53 ` Eric Schulte
2010-07-15 22:17 ` Nick Dokos
2010-08-05 12:33 ` Re[2]: " Ivanov Dmitry
[not found] ` <AANLkTi=wrOCCrZxRZTGgvNKGjy2jmnogiA91bYnHAExV@mail.gmail.com>
2010-08-06 7:33 ` Re[4]: " Ivanov Dmitry
2010-08-07 13:12 ` Re[2]: " David Maus
2010-08-07 15:29 ` Re[4]: " Ivanov Dmitry
2010-08-08 6:43 ` David Maus [this message]
2010-08-08 15:49 ` Re[6]: " Ivanov Dmitry
2010-08-09 19:16 ` David Maus
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mxsxvc3o.wl%dmaus@ictsoc.de \
--to=dmaus@ictsoc.de \
--cc=emacs-orgmode@gnu.org \
--cc=usr345@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.