emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/gutin/.emacs.d/.local/straight/build/org-mode/)]
@ 2020-09-27 18:48 gutin
  2020-09-28 17:59 ` Richard Lawrence
       [not found] ` <875z7xbxns.fsf@aquinas>
  0 siblings, 2 replies; 6+ messages in thread
From: gutin @ 2020-09-27 18:48 UTC (permalink / raw)
  To: emacs-orgmode



Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report? 
See

     https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
---------------------------------------------------------------------
---

If a pair of dollar signs is followed by a dash, then math mode doesn't
work.

Emacs  : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.22, cairo version 1.17.3)
 of 2020-08-28
Package: Org mode version 9.4 (nil @
/home/gutin/.emacs.d/.local/straight/build/org-mode/)

current state:
==============
(setq
 org-footnote-auto-label 'plain
 org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-
configure-edit-buffer
                     doom-modeline-set-org-src-modeline)
 org-fontify-whole-heading-line t
 org-link-shell-confirm-function 'yes-or-no-p
 org-mode-local-vars-hook '(eldoc-mode)
 org-babel-after-execute-hook '(org-redisplay-inline-images)
 org-insert-heading-respect-content t
 org-after-refile-insert-hook '(save-buffer)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-refile-targets '((nil :maxlevel . 3) (org-agenda-files :maxlevel .
3))
 org-html-format-inlinetask-function 'org-html-format-inlinetask-
default-function
 org-enforce-todo-dependencies t
 org-odt-format-headline-function 'org-odt-format-headline-default-
function
 org-special-ctrl-a/e t
 org-imenu-depth 8
 org-agenda-files '("~/org/")
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-
default
 org-reveal-start-hook '(org-decrypt-entry)
 org-modules '(ol-bibtex)
 org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
 org-mode-hook '(doom--setq-gcmh-high-cons-threshold-for-org-mode-h
er/add-org-mode-expansions
                 +lookup--init-org-mode-handlers-h
                 (closure (t) (&rest _) (add-hook 'before-save-hook
'org-encrypt-entries nil t))
                 #[0 "\300\301\302\303\304$\207"
                   [add-hook change-major-mode-hook org-show-all append
local] 5]
                 #[0 "\300\301\302\303\304$\207"
                   [add-hook change-major-mode-hook org-babel-show-
result-all append local] 5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes
                 #[0 "\301\211\207" [imenu-create-index-function org-
imenu-get-tree] 2]
                 doom-disable-show-paren-mode-h doom-disable-show-
trailing-whitespace-h
                 +org-enable-auto-reformat-tables-h +org-enable-auto-
update-cookies-h
                 +org-make-last-point-visible-h evil-org-mode toc-org-
enable embrace-org-mode-hook
                 org-eldoc-load)
 org-clock-persist 'history
 org-export-with-smart-quotes t
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME
CONTENTS)"]
 org-outline-path-complete-in-steps nil
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-agenda-finalize-hook '(+org-exclude-agenda-buffers-from-workspace-
h
                            +org-defer-mode-in-agenda-buffers-h)
 org-startup-indented t
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3
"\n\n(fn ENTRY)"]
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _
CONTENTS)"]
 org-agenda-deadline-faces '((1.001 . error) (1.0 . org-warning) (0.5 .
org-upcoming-deadline)
                             (0.0 . org-upcoming-distant-deadline))
 org-crypt-key nil
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(+org-yas-expand-maybe-h +org-indent-maybe-h org-
babel-hide-result-toggle-maybe
                      org-babel-header-arg-expand +org-cycle-only-
current-subtree-h
                      +org-clear-babel-results-h)
 org-hide-leading-stars t
 org-load-hook '(+org-init-org-directory-h +org-init-appearance-h +org-
init-agenda-h
                 +org-init-attachments-h +org-init-babel-h +org-init-
babel-lazy-loader-h
                 +org-init-capture-defaults-h +org-init-capture-frame-h 
+org-init-custom-links-h
                 +org-init-export-h +org-init-habit-h +org-init-hacks-h 
+org-init-keybinds-h
                 +org-init-popup-rules-h +org-init-protocol-h +org-
init-protocol-lazy-loader-h
                 +org-init-smartparens-h)
 org-link-abbrev-alist '(("doom-repo" . "
https://github.com/hlissner/doom-emacs/%s")
                         ("wolfram" . "
https://wolframalpha.com/input/?i=%s")
                         ("wikipedia" . "
https://en.wikipedia.org/wiki/%s")
                         ("duckduckgo" . "https://duckduckgo.com/?q=%s"
)
                         ("gmap" . "https://maps.google.com/maps?q=%s")
                         ("gimages" . "https://google.com/images?q=%s")
                         ("google" . "https://google.com/search?q=")
                         ("youtube" . "https://youtube.com/watch?v=%s")
                         ("github" . "https://github.com/%s"))
 org-export-backends '(md ascii html icalendar latex odt)
 org-clock-in-resume t
 org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME
CONTENTS WIDTH)"]
 org-attach-store-link-p t
 org-list-demote-modify-bullet '(("+" . "-") ("-" . "+") ("*" . "+")
("1." . "a."))
 org-archive-subtree-save-file-p t
 org-agenda-span 10
 org-agenda-loop-over-headlines-in-active-region nil
 org-src-lang-modes '(("arduino" . arduino) ("redis" . redis) ("php" .
php) ("md" . markdown) ("C" . c)
                      ("C++" . c++) ("asymptote" . asy) ("bash" . sh)
("beamer" . latex)
                      ("calc" . fundamental) ("cpp" . c++) ("ditaa" .
artist) ("dot" . fundamental)
                      ("elisp" . emacs-lisp) ("ocaml" . tuareg)
("screen" . shell-script)
                      ("shell" . sh) ("sqlite" . sql))
 org-src-preserve-indentation t
 org-fontify-quote-and-verse-blocks t
 org-catch-invisible-edits 'smart
 org-occur-hook '(org-first-headline-recenter)
 org-agenda-mode-hook '(+org-habit-resize-graph-h evil-org-agenda-mode)
 org-agenda-window-setup 'current-window
 org-indirect-buffer-display 'current-window
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-
drawers org-cycle-show-empty-lines
                  org-optimize-window-after-visibility-change)
 org-todo-keywords '((sequence "TODO(t)" "PROJ(p)" "STRT(s)" "WAIT(w)"
"HOLD(h)" "|" "DONE(d)"
                      "KILL(k)")
                     (sequence "[ ](T)" "[-](S)" "[?](W)" "|"
"[X](D)"))
 org-support-shift-select t
 org-speed-command-hook '(org-speed-command-activate org-babel-speed-
command-activate)
 org-tags-column 0
 org-capture-mode-hook '(+org-show-target-in-capture-header-h evil-
insert-state)
 org-clock-persist-file "/home/gutin/.emacs.d/.local/etc/org-clock-
save.el"
 org-attach-id-dir "/home/gutin/org/.attach/"
 org-M-RET-may-split-line nil
 org-odt-format-inlinetask-function 'org-odt-format-inlinetask-default-
function
 org-latex-prefer-user-labels t
 org-publish-timestamp-directory
"/home/gutin/.emacs.d/.local/cache/org-timestamps/"
 org-display-remote-inline-images 'download
 org-refile-use-outline-path 'file
 org-priority-faces '((65 . error) (66 . warning) (67 . success))
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-font-lock-set-keywords-hook '(doom-themes-enable-org-
fontification)
 org-id-locations-file "/home/gutin/org/.orgids"
 org-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("id" :follow org-id-open)
                       ("bibtex" :follow org-bibtex-open :store org-
bibtex-store-link)
                       ("orgit-rev" :store orgit-rev-store :follow
orgit-rev-open :export
                        orgit-rev-export :complete orgit-rev-complete-
link)
                       ("orgit-log" :store orgit-log-store :follow
orgit-log-open :export
                        orgit-log-export :complete orgit-log-complete-
link)
                       ("orgit" :store orgit-status-store :follow
orgit-status-open :export
                        orgit-status-export :complete orgit-status-
complete-link)
                       ("yt" :follow org-yt-follow :image-data-fun org-
yt-image-data-fun)
                       ("img" :image-data-fun +org-inline-image-data-
fn)
                       ("doom-modules" :complete
                        (closure
                         ((dir-fn closure
                           ((plist) (dir-var . doom-modules-dir) (key .
"doom-modules") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . doom-modules-
dir) (key . "doom-modules") t)
                         nil (if requires (mapc #'require (doom-enlist
requires)))
                         (+org--relative-path (+org--read-link-path key
(funcall dir-fn))
                          (funcall dir-fn))
                         )
                        :follow
                        (closure
                         ((dir-fn closure
                           ((plist) (dir-var . doom-modules-dir) (key .
"doom-modules") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . doom-modules-
dir) (key . "doom-modules") t)
                         (link) (org-link-open-as-file (expand-file-
name link (funcall dir-fn)) nil))
                        :face
                        (closure
                         ((dir-fn closure
                           ((plist) (dir-var . doom-modules-dir) (key .
"doom-modules") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . doom-modules-
dir) (key . "doom-modules") t)
                         (link)
                         (let*
                          ((path (expand-file-name link (funcall dir-
fn)))
                           (option-index (string-match-p
"::\\(.*\\)\\'" path))
                           (file-name (substring path 0 option-index)))
                          (if (file-exists-p file-name) 'org-link
'error))
                         )
                        )
                       ("doom-docs" :complete
                        (closure
                         ((dir-fn closure ((plist) (dir-var . doom-
docs-dir) (key . "doom-docs") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . doom-docs-dir)
(key . "doom-docs") t)
                         nil (if requires (mapc #'require (doom-enlist
requires)))
                         (+org--relative-path (+org--read-link-path key
(funcall dir-fn))
                          (funcall dir-fn))
                         )
                        :follow
                        (closure
                         ((dir-fn closure ((plist) (dir-var . doom-
docs-dir) (key . "doom-docs") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . doom-docs-dir)
(key . "doom-docs") t)
                         (link) (org-link-open-as-file (expand-file-
name link (funcall dir-fn)) nil))
                        :face
                        (closure
                         ((dir-fn closure ((plist) (dir-var . doom-
docs-dir) (key . "doom-docs") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . doom-docs-dir)
(key . "doom-docs") t)
                         (link)
                         (let*
                          ((path (expand-file-name link (funcall dir-
fn)))
                           (option-index (string-match-p
"::\\(.*\\)\\'" path))
                           (file-name (substring path 0 option-index)))
                          (if (file-exists-p file-name) 'org-link
'error))
                         )
                        )
                       ("doom" :complete
                        (closure
                         ((dir-fn closure ((plist) (dir-var . doom-
emacs-dir) (key . "doom") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . doom-emacs-dir) 
(key . "doom") t)
                         nil (if requires (mapc #'require (doom-enlist
requires)))
                         (+org--relative-path (+org--read-link-path key
(funcall dir-fn))
                          (funcall dir-fn))
                         )
                        :follow
                        (closure
                         ((dir-fn closure ((plist) (dir-var . doom-
emacs-dir) (key . "doom") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . doom-emacs-dir) 
(key . "doom") t)
                         (link) (org-link-open-as-file (expand-file-
name link (funcall dir-fn)) nil))
                        :face
                        (closure
                         ((dir-fn closure ((plist) (dir-var . doom-
emacs-dir) (key . "doom") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . doom-emacs-dir) 
(key . "doom") t)
                         (link)
                         (let*
                          ((path (expand-file-name link (funcall dir-
fn)))
                           (option-index (string-match-p
"::\\(.*\\)\\'" path))
                           (file-name (substring path 0 option-index)))
                          (if (file-exists-p file-name) 'org-link
'error))
                         )
                        )
                       ("org" :complete
                        (closure
                         ((dir-fn closure ((plist) (dir-var . org-
directory) (key . "org") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . org-directory)
(key . "org") t)
                         nil (if requires (mapc #'require (doom-enlist
requires)))
                         (+org--relative-path (+org--read-link-path key
(funcall dir-fn))
                          (funcall dir-fn))
                         )
                        :follow
                        (closure
                         ((dir-fn closure ((plist) (dir-var . org-
directory) (key . "org") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . org-directory)
(key . "org") t)
                         (link) (org-link-open-as-file (expand-file-
name link (funcall dir-fn)) nil))
                        :face
                        (closure
                         ((dir-fn closure ((plist) (dir-var . org-
directory) (key . "org") t) nil
                           (symbol-value dir-var))
                          (requires) (plist) (dir-var . org-directory)
(key . "org") t)
                         (link)
                         (let*
                          ((path (expand-file-name link (funcall dir-
fn)))
                           (option-index (string-match-p
"::\\(.*\\)\\'" path))
                           (file-name (substring path 0 option-index)))
                          (if (file-exists-p file-name) 'org-link
'error))
                         )
                        )
                       ("attachment" :image-data-fun +org-inline-image-
data-fn :follow
                        org-attach-follow :complete org-attach-
complete-link)
                       ("file+sys") ("file+emacs") ("shell" :follow
org-link--open-shell)
                       ("news" :follow
                        #[514 "\301\300\302Q\"\207" ["news" browse-url
":"] 6 "\n\n(fn URL ARG)"])
                       ("mailto" :follow
                        #[514 "\301\300\302Q\"\207" ["mailto" browse-
url ":"] 6 "\n\n(fn URL ARG)"])
                       ("https" :follow
                        #[514 "\301\300\302Q\"\207" ["https" browse-url 
":"] 6 "\n\n(fn URL ARG)"]
                        :image-data-fun +org-http-image-data-fn)
                       ("http" :follow
                        #[514 "\301\300\302Q\"\207" ["http" browse-url
":"] 6 "\n\n(fn URL ARG)"]
                        :image-data-fun +org-http-image-data-fn)
                       ("ftp" :follow
                        #[514 "\301\300\302Q\"\207" ["ftp" browse-url
":"] 6 "\n\n(fn URL ARG)"])
                       ("help" :follow org-link--open-help)
                       ("file" :complete org-link-complete-file :face
                        (closure (t) (path)
                         (if (or (file-remote-p path) (file-exists-p
path)) 'org-link 'error))
                        )
                       ("elisp" :follow org-link--open-elisp) ("doi"
:follow org-link--open-doi))
 org-latex-format-headline-function 'org-latex-format-headline-default-
function
 org-capture-templates '(("t" "Personal todo" entry (file+headline
+org-capture-todo-file "Inbox")
                          "* [ ] %?\n%i\n%a" :prepend t)
                         ("n" "Personal notes" entry (file+headline
+org-capture-notes-file "Inbox")
                          "* %u %?\n%i\n%a" :prepend t)
                         ("j" "Journal" entry (file+olp+datetree +org-
capture-journal-file)
                          "* %U %?\n%i\n%a" :prepend t)
                         ("p" "Templates for projects")
                         ("pt" "Project-local todo" entry
                          (file+headline +org-capture-project-todo-file 
"Inbox") "* TODO %?\n%i\n%a"
                          :prepend t)
                         ("pn" "Project-local notes" entry
                          (file+headline +org-capture-project-notes-
file "Inbox") "* %U %?\n%i\n%a"
                          :prepend t)
                         ("pc" "Project-local changelog" entry
                          (file+headline +org-capture-project-
changelog-file "Unreleased")
                          "* %U %?\n%i\n%a" :prepend t)
                         ("o" "Centralized templates for projects")
                         ("ot" "Project todo" entry #'+org-capture-
central-project-todo-file
                          "* TODO %?\n %i\n %a" :heading "Tasks"
:prepend nil)
                         ("on" "Project notes" entry #'+org-capture-
central-project-notes-file
                          "* %U %?\n %i\n %a" :heading "Notes" :prepend
t)
                         ("oc" "Project changelog" entry #'+org-
capture-central-project-changelog-file
                          "* %U %?\n %i\n %a" :heading "Changelog"
:prepend t)
                         )
 org-link-translation-function 'toc-org-unhrefify
 org-link-elisp-confirm-function nil
 org-todo-keyword-faces '(("[-]" . +org-todo-active) ("STRT" . +org-
todo-active)
                          ("[?]" . +org-todo-onhold) ("WAIT" . +org-
todo-onhold)
                          ("HOLD" . +org-todo-onhold) ("PROJ" . +org-
todo-project))
 org-capture-after-finalize-hook '(+org-capture-cleanup-frame-h)
 org-latex-format-inlinetask-function 'org-latex-format-inlinetask-
default-function
 org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME
CONTENTS)"]
 org-image-actual-width nil
 org-eldoc-breadcrumb-separator " → "
 org-html-format-headline-function 'org-html-format-headline-default-
function
 org-entities-user '(("flat" "\\flat" nil "" "" "266D" "♭") ("sharp"
"\\sharp" nil "" "" "266F" "♯"))
 org-src-window-setup 'other-window
 org-confirm-babel-evaluate nil
 org-use-sub-superscripts '{}
 org-directory "~/org/"
 org-preview-latex-image-directory
"/home/gutin/.emacs.d/.local/cache/org-latex/"
 org-tags-exclude-from-inheritance '("crypt")
 org-html-validation-link nil
 org-attach-use-inheritance t
 org-agenda-inhibit-startup t
 org-agenda-start-on-weekday nil
 org-default-notes-file "/home/gutin/org/notes.org"
 org-id-locations-file-relative t
 org-list-allow-alphabetical t
 org-agenda-skip-unavailable-files t
 )



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

* Re: Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/gutin/.emacs.d/.local/straight/build/org-mode/)]
  2020-09-27 18:48 Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/gutin/.emacs.d/.local/straight/build/org-mode/)] gutin
@ 2020-09-28 17:59 ` Richard Lawrence
       [not found] ` <875z7xbxns.fsf@aquinas>
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Lawrence @ 2020-09-28 17:59 UTC (permalink / raw)
  To: emacs-orgmode

Hi Gutin,

gutin <jkabrg@gmail.com> writes:

> If a pair of dollar signs is followed by a dash, then math mode doesn't
> work.

Can you say a bit more about what you are trying to do, what you are
expecting to happen, and what you are seeing instead?

Since you refer to math mode, I assume you are exporting to LaTeX. I
just tested this:

some text
$$-1$$
other text

and it exports fine to LaTeX on my machine (Emacs 26.1, Org 9.4).
What's broken for you?

-- 
Best,
Richard


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

* Re: Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/gutin/.emacs.d/.local/straight/build/org-mode/)]
       [not found]   ` <e119937a866c6ec4903b122321eec58b561a7175.camel@gmail.com>
@ 2020-09-28 18:42     ` Richard Lawrence
  2020-09-29 16:42       ` Berry, Charles via General discussions about Org-mode.
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Lawrence @ 2020-09-28 18:42 UTC (permalink / raw)
  To: gutin, emacs-orgmode

Hi Gutin,

gutin <jkabrg@gmail.com> writes:

> What I meant is that if you type
>
>   $*$-algebra
>
> and hit C-c C-x C-l, then the "$*$" doesn't get replaced with a
> mathematical image. A similar problem happens when you export to Latex:
> The dollar signs get escaped.

I believe this is intentional. There are too many other uses of dollar
signs that people might want to use in Org documents that might be
broken if Org treated them as math mode delimiters; so the regexp that
matches math mode delimiters is deliberately limited in scope.

The recommended workaround is to use the \(...\) style of delimiter for
math mode instead, which is much less ambiguous. Here is a function that
makes this easy, by inserting these delimiters when you type "$". It's
been posted on this mailing list before, and I use a version of it
myself; it's very useful!

   ;; from Nicolas Richard <theonewiththeevillook@yahoo.fr>
   ;; Date: Fri, 8 Mar 2013 16:23:02 +0100
   ;; Message-ID: <87vc913oh5.fsf@yahoo.fr>
   (defun yf/org-electric-dollar nil
     "When called once, insert \\(\\) and leave point in between.
   When called twice, replace the previously inserted \\(\\) by one $."
          (interactive)
          (if (and (looking-at "\\\\)") (looking-back "\\\\("))
              (progn (delete-char 2)
                     (delete-char -2)
                     (insert "$"))
            (insert "\\(\\)")
            (backward-char 2)))
   (define-key org-mode-map (kbd "$") 'yf/org-electric-dollar

Hope that helps!

-- 
Best,
Richard


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

* Re: Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/gutin/.emacs.d/.local/straight/build/org-mode/)]
  2020-09-28 18:42     ` Richard Lawrence
@ 2020-09-29 16:42       ` Berry, Charles via General discussions about Org-mode.
  2020-09-29 18:53         ` Richard Lawrence
  0 siblings, 1 reply; 6+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-09-29 16:42 UTC (permalink / raw)
  To: Richard Lawrence; +Cc: gutin, org-mode mailing list

See below.

> On Sep 28, 2020, at 11:42 AM, Richard Lawrence <wyley.r@gmail.com> wrote:
> 
> Hi Gutin,
> 
> gutin <jkabrg@gmail.com> writes:
> 
>> What I meant is that if you type
>> 
>>  $*$-algebra
>> 
>> and hit C-c C-x C-l, then the "$*$" doesn't get replaced with a
>> mathematical image. A similar problem happens when you export to Latex:
>> The dollar signs get escaped.
> 
> I believe this is intentional. There are too many other uses of dollar
> signs that people might want to use in Org documents that might be
> broken if Org treated them as math mode delimiters; so the regexp that
> matches math mode delimiters is deliberately limited in scope.

[rest deleted]

The case Gutin describes conforms to the documentation, viz. `$x\beta$-` should produce math mode LaTeX as I read the next paragraph. 

From (info "(org) LaTeX fragments"):

   • Text within the usual LaTeX math delimiters.  To avoid conflicts
     with currency specifications, single ‘$’ characters are only
     recognized as math delimiters if the enclosed text contains at most
     two line breaks, is directly attached to the ‘$’ characters with no
     whitespace in between, and if the closing ‘$’ is followed by
     whitespace, punctuation or a dash.

But the $...$ and $$...$$ seem fragile. I recall advice to avoid them in favor of \(...\) and \[...\].

FWIW, my sanity has been aided by using yf/org-electric-dollar[1], which inserts `\(\)` when I type `$` and leaves point where you need it to enter math mode LaTex. A dash after the closing parenthesis is no problem.

HTH,

Chuck


[1] https://orgmode.org/list/87vc913oh5.fsf@yahoo.fr/
;; from Nicolas Richard <theonewiththeevillook@yahoo.fr>
;; Date: Fri, 8 Mar 2013 16:23:02 +0100
;; Message-ID: <87vc913oh5.fsf@yahoo.fr>






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

* Re: Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/gutin/.emacs.d/.local/straight/build/org-mode/)]
  2020-09-29 16:42       ` Berry, Charles via General discussions about Org-mode.
@ 2020-09-29 18:53         ` Richard Lawrence
  2020-09-29 22:06           ` Berry, Charles via General discussions about Org-mode.
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Lawrence @ 2020-09-29 18:53 UTC (permalink / raw)
  To: Berry, Charles; +Cc: gutin, org-mode mailing list

"Berry, Charles" <ccberry@health.ucsd.edu> writes:

> The case Gutin describes conforms to the documentation, viz. `$x\beta$-` should produce math mode LaTeX as I read the next paragraph. 
>
> From (info "(org) LaTeX fragments"):
>
>    • Text within the usual LaTeX math delimiters.  To avoid conflicts
>      with currency specifications, single ‘$’ characters are only
>      recognized as math delimiters if the enclosed text contains at most
>      two line breaks, is directly attached to the ‘$’ characters with no
>      whitespace in between, and if the closing ‘$’ is followed by
>      whitespace, punctuation or a dash.

Hmm, good point.

It looks to me like the relevant function is
org-element-latex-fragment-parser, and the code for that hasn't changed
much in several years (last change was 2017). (Also, I was wrong,
parsing latex fragments is not done with just a regexp.) I can confirm
that this function parses "$foo" in "$foo$ bar" as a latex fragment, but
not in "$foo$-bar"

Not sure if the problem here is the code or the documentation. Perhaps
the documentation should be updated to reflect the current behavior?

-- 
Best,
Richard


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

* Re: Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/gutin/.emacs.d/.local/straight/build/org-mode/)]
  2020-09-29 18:53         ` Richard Lawrence
@ 2020-09-29 22:06           ` Berry, Charles via General discussions about Org-mode.
  0 siblings, 0 replies; 6+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-09-29 22:06 UTC (permalink / raw)
  To: Richard Lawrence; +Cc: gutin, org-mode mailing list

See below.

> On Sep 29, 2020, at 11:53 AM, Richard Lawrence <wyley.r@gmail.com> wrote:
> 
> "Berry, Charles" <ccberry@health.ucsd.edu> writes:
> 
>> The case Gutin describes conforms to the documentation, viz. `$x\beta$-` should produce math mode LaTeX as I read the next paragraph. 
>> 
>> From (info "(org) LaTeX fragments"):
>> 
>>   • Text within the usual LaTeX math delimiters.  To avoid conflicts
>>     with currency specifications, single ‘$’ characters are only
>>     recognized as math delimiters if the enclosed text contains at most
>>     two line breaks, is directly attached to the ‘$’ characters with no
>>     whitespace in between, and if the closing ‘$’ is followed by
>>     whitespace, punctuation or a dash.
> 
> Hmm, good point.
> 
> It looks to me like the relevant function is
> org-element-latex-fragment-parser, and the code for that hasn't changed
> much in several years (last change was 2017). (Also, I was wrong,
> parsing latex fragments is not done with just a regexp.) I can confirm
> that this function parses "$foo" in "$foo$ bar" as a latex fragment, but
> not in "$foo$-bar"
> 
> Not sure if the problem here is the code or the documentation. Perhaps
> the documentation should be updated to reflect the current behavior?
> 

Using 

"\\(-\\|\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)"

as the regexp for the `looking-at-p` seems to resolve this. To save you some eyestrain, there is "-\\|" added near the beginning right after "\\(" to match the trailing dash.

Per (info (elisp) "Syntax Class Table"), neither \\s. nor \\s- include the dash. \\s_ includes dash, but also $, so that seems like trouble. 

Caveat: I've not run `make test`, so am unsure if there is a subtle gotcha hidden here.

HTH,

Chuck

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

end of thread, other threads:[~2020-09-29 22:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-27 18:48 Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/gutin/.emacs.d/.local/straight/build/org-mode/)] gutin
2020-09-28 17:59 ` Richard Lawrence
     [not found] ` <875z7xbxns.fsf@aquinas>
     [not found]   ` <e119937a866c6ec4903b122321eec58b561a7175.camel@gmail.com>
2020-09-28 18:42     ` Richard Lawrence
2020-09-29 16:42       ` Berry, Charles via General discussions about Org-mode.
2020-09-29 18:53         ` Richard Lawrence
2020-09-29 22:06           ` Berry, Charles via General discussions about Org-mode.

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).