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.