emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Aaron Ecay <aaronecay@gmail.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Cc: Nicolas Goaziou <n.goaziou@gmail.com>
Subject: [parser] subscripts and underlines interacting badly
Date: Tue, 10 Dec 2013 21:30:07 -0500	[thread overview]
Message-ID: <87ppp415n4.fsf@gmail.com> (raw)

[-- 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

             reply	other threads:[~2013-12-11  2:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11  2:30 Aaron Ecay [this message]
2013-12-11  8:22 ` [parser] subscripts and underlines interacting badly 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ppp415n4.fsf@gmail.com \
    --to=aaronecay@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).