mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-29 07:58:21 +00:00
Factor out function for substituting posix class in regular expression
* org-macs.el (org-substitute-posix-classes): New function. Substitute posix classes in regular expression. (org-re): Use new function.
This commit is contained in:
parent
5423b329c1
commit
19c6b14644
@ -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-gensyms (line col)
|
||||
|
Loading…
Reference in New Issue
Block a user