[BUG] A custom org-num-format-function causes org-latex-preview warn when it called. [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.3/lisp/org/)]

2024-04-13 Thread Garid Zorigoo
* What I'm experiencing:
A custom ~org-num-format-function~ causes ~org-latex-preview~ warn when it
is called.

* Exact "Warning" I'm getting.
⛔ Warning (org-element-cache): org-element--cache: Org parser error in
ask.org::648. Resetting.
 The error was: (error "Invalid search bound (wrong side of point)")
 Backtrace:
nil

* Info about when this Warning comes:
- Warning comes up when equation change from "previewed-state (image)" back
to "text-state"
- Warning only comes when the equation is changed.

* Setup (the custom ~org-num-format-function~)
#+begin_src elisp
(defun my/org-num-format (numbering)
(concat
 (number-to-string (car numbering)) "." (mapconcat (lambda (x) (format
"%02d" x)) (cdr numbering) ".") " "))

(setq org-num-format-function #'my/org-num-format)
#+end_src

#+RESULTS:
: my/org-num-format

* To Reproduce

1. Change the org-num-format-function as written above
2. (In org-file) Turn-on ~org-num-mode~
3. (In org-file) On any equation, change it.
4. run ~org-latex-preview~ to preview the equation image.
5, run ~org-latex-preview~ go back to text mode. (here warning comes)
(If warning doesn't appear try from step 3 again)
(When org-num-mode turned off, it doesn't produce warning)

   $\alpha$


Emacs  : GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.41, cairo version 1.18.0)
Package: Org mode version 9.6.15 (release_9.6.15 @
/usr/share/emacs/29.3/lisp/org/)


Re: [BUG] Org export LaTeX: Multiple dashes in ~code~/=verbatim= turn into wrong number of dashes [9.5.5 (release_9.5.5 @ /usr/share/emacs/28.2/lisp/org/)]

2023-04-11 Thread Garid Zorigoo



I think I even found a solution much easier solution.

Just replace each - dash with {-} when exporting latex.

In other words:

|---+-|
| Original org  | New suggestion  |
|---+-|
|   | ... |
| * code    | \section{code}  |
| 1. ~-~    | \label{sec:org532ffa5}  |
| 2. ~--~   | \begin{enumerate}   |
| 3. ~---~  | \item \texttt{{-}}  |
| 4. ~~ | \item \texttt{{-}{-}}   |
| 5. ~-~    | \item \texttt{{-}{-}{-}}    |
| 6. ~a--b~ | \item \texttt{{-}{-}{-}{-}} |
|   | \item \texttt{{-}{-}{-}{-}{-}}  |
| * verbatim    | \item \texttt{a{-}{-}{-}{-}{-}{-}b} |
| 1. =-=    | \end{enumerate} |
| 2. =--=   | |
| 3. =---=  | \section{verbatim}  |
| 4. == | \label{sec:org4a05ec4}  |
| 5. =-=    | \begin{enumerate}   |
| 6. =a--b= | \item \texttt{{-}}  |
|   | \item \texttt{{-}{-}}   |
|   | \item \texttt{{-}{-}{-}}    |
|   | \item \texttt{{-}{-}{-}{-}} |
|   | \item \texttt{{-}{-}{-}{-}{-}}  |
|   | \item \texttt{a{-}{-}{-}{-}{-}{-}b} |
|   | \end{enumerate} |
|   | ... |
|---+-|

This will ensure each - character as a separate character.
This seems much easier to implement and readable.

Garid Z.




[BUG] Org export LaTeX: Multiple dashes in ~code~/=verbatim= turn into wrong number of dashes [9.5.5 (release_9.5.5 @ /usr/share/emacs/28.2/lisp/org/)]

2023-04-11 Thread Garid Zorigoo
I'm exporting the following org file (left-side) to a LaTeX pdf file.
The org file contains the multiple dashes in the ~code~ =verbatim=
format. The exported PDF file doesn't have the correct number of dashes.

|+---|
| Original org   |   Exported  tex file  section |
|+---|
||   |
|* code  |\section{code} |
| 1. ~-~ |\label{sec:org532ffa5} |
| 2. ~--~|\begin{enumerate}  |
| 3. ~---~   |\item \texttt{-}   |
| 4. ~~  |\item \texttt{-{}-}|
| 5. ~-~ |\item \texttt{-{}--}   |
| 6. ~a--b~  |\item \texttt{-{}--{}-}|
||\item \texttt{-{}--{}--}   |
|* verbatim  |\item \texttt{a-{}--{}--{}-b}  |
| 1. =-= |\end{enumerate}|
| 2. =--=|   |
| 3. =---=   |\section{verbatim} |
| 4. ==  |\label{sec:org4a05ec4} |
| 5. =-= |\begin{enumerate}  |
| 6. =a--b=  |\item \texttt{-}   |
||\item \texttt{-{}-}|
||\item \texttt{-{}--}   |
||\item \texttt{-{}--{}-}|
||\item \texttt{-{}--{}--}   |
||\item \texttt{a-{}--{}--{}-b}  |
||\end{enumerate}|
||...|
|+---|

These multiple dashes need `{}` separator in between (i.e. `-{}-`).
However, I believe that ~~ should become \texttt{-{}-{}-{}-{}-}
(actual 4 dashes) instead of \texttt{-{}--{}-} (dash + en.dash + dash)?

It may be needed {} in between every dash. (I read from here
)

Basically what I'm saying is that. I might need the following in
order to have the correct number of dashes.

|+--|
| Original org   |   Maybe it should have exported  |
|+--|
||   ...|
|* code  |   \section{code} |
| 1. ~-~ |   \label{sec:org532ffa5} |
| 2. ~--~|   \begin{enumerate}  |
| 3. ~---~   |   \item \texttt{-}   |
| 4. ~~  |   \item \texttt{-{}-}|
| 5. ~-~ |   \item \texttt{-{}-{}-} |
| 6. ~a--b~  |   \item \texttt{-{}-{}-{}-}  |
||   \item \texttt{-{}-{}-{}-{}-}   |
|* verbatim  |   \item \texttt{a-{}-{}-{}-{}-{}-b}  |
| 1. =-= |   \end{enumerate}|
| 2. =--=|  |
| 3. =---=   |   \section{verbatim} |
| 4. ==  |   \label{sec:org4a05ec4} |
| 5. =-= |   \begin{enumerate}  |
| 6. =a--b=  |   \item \texttt{-}   |
||   \item \texttt{-{}-}|
||   \item \texttt{-{}-{}-} |
||   \item \texttt{-{}-{}-{}-}  |
||   \item \texttt{-{}-{}-{}-{}-}   |
||   \item \texttt{a-{}-{}-{}-{}-{}-b}  |
||   \end{enumerate}|
||...   |
|+--|

The possible place this bug might reside:
It's possible that while exporting, it replaces -- with -{}-.
So 4 dashes () has 2 -- so each couple gets replaced
with -{}- finally forming -{}--{}-.


I was suggested to report this possible bug in the following forum question

.


If this was an intentional feature I'm sorry.


Garid Z.



Emacs  : GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.36, cairo version 1.17.6)
 of 2023-01-03
Package: Org mode version 9.5.5 (release_9.5.5 @
/usr/share/emacs/28.2/lisp/org/)