From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Maus Subject: [PATCH 4/7] New function: Substitute posix classes in regular expression Date: Tue, 2 Aug 2011 11:23:37 +0200 Message-ID: <1312277020-7888-5-git-send-email-dmaus@ictsoc.de> References: <1312277020-7888-1-git-send-email-dmaus@ictsoc.de> Return-path: Received: from eggs.gnu.org ([140.186.70.92]:53313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoBCu-0000AS-GH for emacs-orgmode@gnu.org; Tue, 02 Aug 2011 05:24:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QoBCt-0000H7-9N for emacs-orgmode@gnu.org; Tue, 02 Aug 2011 05:24:12 -0400 Received: from app1b.xlhost.de ([213.202.242.162]:59934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoBCs-0000H1-VJ for emacs-orgmode@gnu.org; Tue, 02 Aug 2011 05:24:11 -0400 In-Reply-To: <1312277020-7888-1-git-send-email-dmaus@ictsoc.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: David Maus * org-macs.el (org-substitute-posix-classes): New function. Substitute posix classes in regular expression. (org-re): Rewritten to use new function. --- lisp/org-macs.el | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index ab21ef7..198d210 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -93,21 +93,23 @@ Also, do not record undo information." before-change-functions after-change-functions) ,@body)))) +(defun org-substitute-posix-classes (re) + "Substitute posix classes in regular expression RE." + (let ((ss re)) + (save-match-data + (while (string-match "\\[:alnum:\\]" ss) + (setq ss (replace-match "a-zA-Z0-9" t t ss))) + (while (string-match "\\[:word:\\]" ss) + (setq ss (replace-match "a-zA-Z0-9" t t ss))) + (while (string-match "\\[:alpha:\\]" ss) + (setq ss (replace-match "a-zA-Z" t t ss))) + (while (string-match "\\[:punct:\\]" ss) + (setq ss (replace-match "\001-@[-`{-~" t t ss))) + ss))) + (defmacro org-re (s) "Replace posix classes in regular expression." - (if (featurep 'xemacs) - (let ((ss s)) - (save-match-data - (while (string-match "\\[:alnum:\\]" ss) - (setq ss (replace-match "a-zA-Z0-9" t t ss))) - (while (string-match "\\[:word:\\]" ss) - (setq ss (replace-match "a-zA-Z0-9" t t ss))) - (while (string-match "\\[:alpha:\\]" ss) - (setq ss (replace-match "a-zA-Z" t t ss))) - (while (string-match "\\[:punct:\\]" ss) - (setq ss (replace-match "\001-@[-`{-~" t t ss))) - ss)) - s)) + (if (featurep 'xemacs) `(org-substitute-posix-classes ,s) s)) (defmacro org-preserve-lc (&rest body) (org-with-uninterned (line col) -- 1.7.2.5