emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Yuchen Guo <yuchen@apvc.uk>
Cc: "Rudolf Adamkovič" <salutis@me.com>,
	iemacs@gmail.com, "org-mode mailing list" <emacs-orgmode@gnu.org>
Subject: Re: Hyphen after LaTeX fragments
Date: Wed, 22 Mar 2023 12:36:45 +0000	[thread overview]
Message-ID: <87bkklnesi.fsf@localhost> (raw)
In-Reply-To: <86ileukojk.fsf@lan>

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

Yuchen Guo <yuchen@apvc.uk> writes:

> If it is deprecated in Org mode, maybe we can print a warning message in
> echo area?

Not in echo area, but we can add a linter.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-lint-Add-checker-for-.-LaTeX-fragments.patch --]
[-- Type: text/x-patch, Size: 1628 bytes --]

From 129e3aa03229fd2e5dd6ea9bf627e4d95a061744 Mon Sep 17 00:00:00 2001
Message-Id: <129e3aa03229fd2e5dd6ea9bf627e4d95a061744.1679488572.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Wed, 22 Mar 2023 13:35:22 +0100
Subject: [PATCH] org-lint: Add checker for $...$ LaTeX fragments

* lisp/org-lint.el (org-lint-LaTeX-$): New checker warning about
semi-obsolete $...$ LaTeX fragment syntax.

Link: https://orgmode.org/list/86ileukojk.fsf@lan
---
 lisp/org-lint.el | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index 0e2967b6c..8d6d22be7 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -1227,6 +1227,14 @@ (defun org-lint-incomplete-citation (ast)
                                        (org-element-property :parent text))
                  "Possibly incomplete citation markup")))))
 
+(defun org-lint-LaTeX-$ (ast)
+  "Report semi-obsolete $...$ LaTeX fragments."
+  (org-element-map ast 'latex-fragment
+    (lambda (fragment)
+      (and (string-match-p "^[$][^$]" (org-element-property :value fragment))
+           (list (org-element-property :begin fragment)
+                 "Potentially confusing LaTeX fragment format.  Prefer using more reliable \\(...\\)")))))
+
 \f
 ;;; Checkers declaration
 
@@ -1450,6 +1458,11 @@ (org-lint-add-checker 'incomplete-citation
   #'org-lint-incomplete-citation
   :categories '(cite) :trust 'low)
 
+(org-lint-add-checker 'LaTeX-$
+  "Report potentially confusing $...$ LaTeX markup."
+  #'org-lint-LaTeX-$
+  :categories '(markup))
+
 (provide 'org-lint)
 
 ;; Local variables:
-- 
2.39.1


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


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

  reply	other threads:[~2023-03-22 12:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 15:15 Hyphen after LaTeX fragments Yuchen Guo
2023-03-20  1:54 ` iemacs
2023-03-21 16:35   ` Rudolf Adamkovič
2023-03-21 16:39     ` Dominik Schrempf
2023-03-22 12:25       ` Ihor Radchenko
2023-03-22 12:35         ` Dominik Schrempf
2023-03-22 13:02           ` Ihor Radchenko
2023-03-21 17:22     ` Yuchen Guo
2023-03-22 12:36       ` Ihor Radchenko [this message]
2023-04-17 14:01         ` Ihor Radchenko
2023-04-17 15:29           ` Dominik Schrempf
  -- strict thread matches above, loose matches on Subject: below --
2023-03-13 19:44 Yuchen Guo
2023-03-14  7:02 Yuchen Guo
2023-03-14  7:04 ` Dominik Schrempf
2023-03-14 11:12 ` Max Nikulin

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=87bkklnesi.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=iemacs@gmail.com \
    --cc=salutis@me.com \
    --cc=yuchen@apvc.uk \
    /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).