emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: [PATCH] Add support for $…$ latex fragments followed by a dash
@ 2022-01-27 18:54 autofrettage
  0 siblings, 0 replies; 21+ messages in thread
From: autofrettage @ 2022-01-27 18:54 UTC (permalink / raw)
  To: emacs-orgmode

Rudolf wrote:

> Further, \(\) brings 100% more characters than $$, resulting in more noise in the sentence.

Now where did I put my APL keyboard...

Cheers
Rasmus


^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: [PATCH] Add support for $…$ latex fragments followed by a dash
@ 2022-01-25 18:09 Goran Zuzic
  0 siblings, 0 replies; 21+ messages in thread
From: Goran Zuzic @ 2022-01-25 18:09 UTC (permalink / raw)
  To: sebastien.miquel; +Cc: emacs-orgmode, e.fraga

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

On a personal note, I would be very happy to see this patch merged. It has
been annoying me for years, see for instance this thread:
https://emacs.stackexchange.com/questions/37207/org-latex-fragment-succeeded-by-a-dash-is-not-showing

Goran

[-- Attachment #2: Type: text/html, Size: 406 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread
* [PATCH] Add support for $…$ latex fragments followed by a dash
@ 2022-01-24 16:42 Sébastien Miquel
  2022-01-25  7:56 ` Eric S Fraga
  2022-01-26  6:33 ` Tom Gillespie
  0 siblings, 2 replies; 21+ messages in thread
From: Sébastien Miquel @ 2022-01-24 16:42 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Rudolf Adamkovič

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

Hi,

The attached patch adds support for $…$ latex fragments followed by a
dash, such as $n$-th.

This pattern is quite common, and the issue was mentionned by Rudolf
Adamkovič, here: https://list.orgmode.org/m2mtjvefrf.fsf@me.com/.

This extension of the syntax doesn't conflict with the use of $'s in
table formulas, or for currency, AFAICT.

Regards,

-- 
Sébastien Miquel

[-- Attachment #2: 0001-org-element-Support-LaTeX-fragments-followed-by-a-da.patch --]
[-- Type: text/x-patch, Size: 3159 bytes --]

From b023fff129a5cc3b1f12b9f170f2e018dc34d237 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@posteo.eu>
Date: Sun, 23 Jan 2022 13:28:03 +0100
Subject: [PATCH] =?UTF-8?q?org-element:=20Support=20$=E2=80=A6$=20LaTeX=20?=
 =?UTF-8?q?fragments=20followed=20by=20a=20dash?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-element.el (org-element-latex-fragment-parser):
* lisp/org.el (org-latex-regexps): Allow a dash right after a
$…$ fragment.
* testing/lisp/test-org-element.el (test-org-element/latex-fragment-parser):
Add test.

Allows such uses as `$n$-th' or `$n$-dimensional'.
---
 lisp/org-element.el              | 2 +-
 lisp/org.el                      | 4 ++--
 testing/lisp/test-org-element.el | 4 ++++
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index b82475a14..40a604578 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3416,7 +3416,7 @@ Assume point is at the beginning of the LaTeX fragment."
 		     (not (memq (char-before (match-beginning 0))
 				'(?\s ?\t ?\n ?, ?.)))
 		     (looking-at-p
-		      "\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)")
+		      "\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|-\\|$\\)")
 		     (point)))))
 	     (post-blank
 	      (if (not after-fragment) (throw 'no-object nil)
diff --git a/lisp/org.el b/lisp/org.el
index 2d439cd05..3a164ee77 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -629,8 +629,8 @@ An entry can be toggled between COMMENT and normal with
   '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
     ;; ("$" "\\([ \t(]\\|^\\)\\(\\(\\([$]\\)\\([^ \t\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \t\n,.$]\\)\\4\\)\\)\\([ \t.,?;:'\")]\\|$\\)" 2 nil)
     ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
-    ("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|$\\)" 2 nil)
-    ("$"  "\\([^$]\\|^\\)\\(\\(\\$\\([^ \t\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \t\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|$\\)" 2 nil)
+    ("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|-\\|$\\)" 2 nil)
+    ("$"  "\\([^$]\\|^\\)\\(\\(\\$\\([^ \t\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \t\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|-\\|$\\)" 2 nil)
     ("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
     ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil)
     ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 6d7376a96..2055e3a7b 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1776,6 +1776,10 @@ e^{i\\pi}+1=0
    (eq 'latex-fragment
        (org-test-with-temp-text "$a$'"
 	 (org-element-type (org-element-context)))))
+  (should
+   (eq 'latex-fragment
+       (org-test-with-temp-text "$a$-"
+	 (org-element-type (org-element-context)))))
   ;; Test forbidden characters inside $...$.
   (should-not
    (eq 'latex-fragment
-- 
2.34.1


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

end of thread, other threads:[~2022-02-07  1:03 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 18:54 [PATCH] Add support for $…$ latex fragments followed by a dash autofrettage
  -- strict thread matches above, loose matches on Subject: below --
2022-01-25 18:09 Goran Zuzic
2022-01-24 16:42 Sébastien Miquel
2022-01-25  7:56 ` Eric S Fraga
2022-01-25 10:32   ` Sébastien Miquel
2022-01-26 17:15   ` Rudolf Adamkovič
2022-01-27  8:28     ` Ihor Radchenko
2022-01-27 19:15       ` Tim Cross
2022-01-28 14:37         ` Max Nikulin
2022-01-28 16:37           ` Timothy
2022-01-30 15:28             ` Max Nikulin
2022-02-01 14:26               ` Max Nikulin
2022-01-27 19:34       ` Sébastien Miquel
2022-02-01 21:00       ` Rudolf Adamkovič
2022-02-02  2:48         ` João Pedro de Amorim Paula
2022-02-06 19:45           ` Rudolf Adamkovič
2022-02-07  0:00             ` Tim Cross
2022-01-26  6:33 ` Tom Gillespie
2022-01-26 17:49   ` Sébastien Miquel
2022-01-26 21:49     ` Tom Gillespie
2022-01-27 19:11       ` Sébastien Miquel

Code repositories for project(s) associated with this 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).