emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [parser] subscripts and underlines interacting badly
@ 2013-12-11  2:30 Aaron Ecay
  2013-12-11  8:22 ` Nicolas Goaziou
  0 siblings, 1 reply; 14+ messages in thread
From: Aaron Ecay @ 2013-12-11  2:30 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org; +Cc: Nicolas Goaziou

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

Hello,

I have encountered two related misbehaviors in the parser/exporter.

The first manifests if you type the following line into an org-mode
buffer and execute M-: (org-element-context) with point on the ‘f’; the
result is a subscript object, whereas I would have expected an
underline:

'_foo_

I think both possibilities are returned by
org-element--get-next-object-candidates, and subscript “wins” because it
precedes the other in the list.  I’m not sure how this should be
addressed, but maybe Nicolas knows.

I encountered the second issue when trying to hack around the first by
setting org-use-sub-superscripts to '{}.  It seems this variable is not
considered by the parser.  I think the attached patch fixes this issue.

Thanks,

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-element-respect-the-org-use-sub-superscripts-var.patch --]
[-- Type: text/x-diff, Size: 1370 bytes --]

From f5f6d10e5d55f68d57abd2f7a947f72cb90081d0 Mon Sep 17 00:00:00 2001
From: Aaron Ecay <aaronecay@gmail.com>
Date: Tue, 10 Dec 2013 21:19:23 -0500
Subject: [PATCH] org-element: respect the `org-use-sub-superscripts' variable

* lisp/org-element.el (org-element-sub/superscript-successor): respect
the `org-use-sub-superscripts' variable
---
 lisp/org-element.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 9183a67..d0e6bf9 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3394,11 +3394,15 @@ CONTENTS is the contents of the object."
 
 Return value is a cons cell whose CAR is either `subscript' or
 `superscript' and CDR is beginning position."
-  (save-excursion
-    (unless (bolp) (backward-char))
-    (when (re-search-forward org-match-substring-regexp nil t)
-      (cons (if (string= (match-string 2) "_") 'subscript 'superscript)
-	    (match-beginning 2)))))
+  (when org-use-sub-superscripts
+    (save-excursion
+      (unless (bolp) (backward-char))
+      (when (re-search-forward (if (eq org-use-sub-superscripts '{})
+				   org-match-substring-with-braces-regexp
+				 org-match-substring-regexp)
+			       nil t)
+	(cons (if (string= (match-string 2) "_") 'subscript 'superscript)
+	      (match-beginning 2))))))
 
 
 ;;;; Superscript
-- 
1.8.5.1


[-- Attachment #3: Type: text/plain, Size: 15 bytes --]

-- 
Aaron Ecay

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-12-18 15:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-11  2:30 [parser] subscripts and underlines interacting badly Aaron Ecay
2013-12-11  8:22 ` Nicolas Goaziou
2013-12-11 18:36   ` Aaron Ecay
2013-12-11 20:55     ` Nicolas Goaziou
2013-12-12  7:56       ` Aaron Ecay
2013-12-12 17:33         ` Nicolas Goaziou
2013-12-12 19:42           ` Aaron Ecay
2013-12-12 20:47             ` Nicolas Goaziou
2013-12-16  3:15               ` Aaron Ecay
2013-12-16  3:24                 ` [PATCH] quick patch to org-habit todo state keywords Ted Wiles
2013-12-16  4:27                   ` Aaron Ecay
2013-12-17 16:57                 ` [parser] subscripts and underlines interacting badly Nicolas Goaziou
2013-12-18  6:57                   ` Aaron Ecay
2013-12-18 15:01                     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).