From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Maus Subject: Re: Re[4]: programming for org-mode Date: Sun, 08 Aug 2010 08:43:07 +0200 Message-ID: <87mxsxvc3o.wl%dmaus@ictsoc.de> References: <3910304564.20100715085202@gmail.com> <87vd8gejvk.fsf@gmail.com> <226505391.20100805163301@gmail.com> <87lj8ia7nj.wl%dmaus@ictsoc.de> <510683939.20100807192935@gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="===============1021675824==" Return-path: Received: from [140.186.70.92] (port=51343 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oi98p-0002Ja-Of for emacs-orgmode@gnu.org; Sun, 08 Aug 2010 12:54:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OhzbX-0007pv-MJ for emacs-orgmode@gnu.org; Sun, 08 Aug 2010 02:43:32 -0400 Received: from mysql1.xlhost.de ([213.202.242.106]:58920) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OhzbX-0007eb-G5 for emacs-orgmode@gnu.org; Sun, 08 Aug 2010 02:43:31 -0400 In-Reply-To: <510683939.20100807192935@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Ivanov Dmitry Cc: emacs-orgmode@gnu.org --===============1021675824== Content-Type: multipart/signed; boundary="pgp-sign-Multipart_Sun_Aug__8_08:43:06_2010-1"; micalg=pgp-sha256; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit --pgp-sign-Multipart_Sun_Aug__8_08:43:06_2010-1 Content-Type: text/plain; charset=US-ASCII 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. --pgp-sign-Multipart_Sun_Aug__8_08:43:06_2010-1 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iF4EABEIAAYFAkxeUfoACgkQma24O1pEeObFzAEAnKOy9cQeXaUY16sIyjCnR21u qNgkWoB909StdxuMl6YA/jvlxecSSRx+lVqulZWn44dxon5Ug8eJoolkBWdd4HWZ =8ASc -----END PGP SIGNATURE----- --pgp-sign-Multipart_Sun_Aug__8_08:43:06_2010-1-- --===============1021675824== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============1021675824==--