summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2014-01-11 23:51:33 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2014-01-11 23:54:22 +0100
commitcad81696b8bd212b61e1760fec850761b0449221 (patch)
tree7198761d91f3a44c5cad258770ae97eaa3c2b829
parentfd5edd35ae33ef9fbd15a8e4413455ce99f96007 (diff)
downloadorg-mode-cad81696b8bd212b61e1760fec850761b0449221.tar.gz
Change no brace sub/superscript syntax
* lisp/org.el (org-match-substring-regexp): Simplify syntax when not using braces. Also make the variable a defconst. (org-match-substring-with-braces-regexp): Make the variable a defconst and remove a useless group in regexp. * lisp/org-element.el (org-element-subscript-parser, org-element-superscript-parser): Adapt to group changes.
-rw-r--r--lisp/org-element.el17
-rw-r--r--lisp/org.el17
2 files changed, 15 insertions, 19 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 511468e..4932a5c 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3385,13 +3385,12 @@ Return a list whose CAR is `subscript' and CDR a plist with
Assume point is at the underscore."
(save-excursion
(unless (bolp) (backward-char))
- (let ((bracketsp (if (looking-at org-match-substring-with-braces-regexp)
- t
- (not (looking-at org-match-substring-regexp))))
+ (looking-at org-match-substring-regexp)
+ (let ((bracketsp (match-beginning 4))
(begin (match-beginning 2))
- (contents-begin (or (match-beginning 5)
+ (contents-begin (or (match-beginning 4)
(match-beginning 3)))
- (contents-end (or (match-end 5) (match-end 3)))
+ (contents-end (or (match-end 4) (match-end 3)))
(post-blank (progn (goto-char (match-end 0))
(skip-chars-forward " \t")))
(end (point)))
@@ -3434,12 +3433,12 @@ Return a list whose CAR is `superscript' and CDR a plist with
Assume point is at the caret."
(save-excursion
(unless (bolp) (backward-char))
- (let ((bracketsp (if (looking-at org-match-substring-with-braces-regexp) t
- (not (looking-at org-match-substring-regexp))))
+ (looking-at org-match-substring-regexp)
+ (let ((bracketsp (match-beginning 4))
(begin (match-beginning 2))
- (contents-begin (or (match-beginning 5)
+ (contents-begin (or (match-beginning 4)
(match-beginning 3)))
- (contents-end (or (match-end 5) (match-end 3)))
+ (contents-end (or (match-end 4) (match-end 3)))
(post-blank (progn (goto-char (match-end 0))
(skip-chars-forward " \t")))
(end (point)))
diff --git a/lisp/org.el b/lisp/org.el
index 3ab895c..1cc6620 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5638,21 +5638,20 @@ stacked delimiters is N. Escaping delimiters is not possible."
next (concat "\\(?:" nothing left next right "\\)+" nothing)))
(concat left "\\(" re "\\)" right)))
-(defvar org-match-substring-regexp
+(defconst org-match-substring-regexp
(concat
"\\(\\S-\\)\\([_^]\\)\\("
- "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
+ "\\(?:" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
"\\|"
- "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)"
+ "\\(?:" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)"
"\\|"
- "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)")
+ "\\(?:\\*\\|[+-]?[[:alnum:].,\\]*[[:alnum:]]\\)\\)")
"The regular expression matching a sub- or superscript.")
-(defvar org-match-substring-with-braces-regexp
+(defconst org-match-substring-with-braces-regexp
(concat
- "\\(\\S-\\)\\([_^]\\)\\("
- "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
- "\\)")
+ "\\(\\S-\\)\\([_^]\\)"
+ "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)")
"The regular expression matching a sub- or superscript, forcing braces.")
(defun org-make-link-regexps ()
@@ -6089,8 +6088,6 @@ by a #."
(defvar org-latex-and-related-regexp nil
"Regular expression for highlighting LaTeX, entities and sub/superscript.")
-(defvar org-match-substring-regexp)
-(defvar org-match-substring-with-braces-regexp)
(defun org-compute-latex-and-related-regexp ()
"Compute regular expression for LaTeX, entities and sub/superscript.