>>> "AE" == Arash Esbati <ar...@gnu.org> writes:

Hi Arash
> Hi all,
> I had a closer look at my proposal in this message[1] and I think I have
> a working setup for indenting conditionals in AUCTeX.  I've patched the
> functions `LaTeX-indent-calculate', `LaTeX-indent-calculate-last' and
> `LaTeX-indent-level-count' and hitting TAB in the following snippet
> works as expected:

Since there has been progress concerning the indentation, notable also
in algpseudocode.el I would like to point out a problem I reported some
time ago and which causes some headaches for proper indenting.

These are latex constructs like 

\begin{equation}
  \label{eq:cnv_2022_03_24_389c19861457ad3e9b90g:94}
  \left|c_{k}\right|=\left|\frac{\alpha_{k}-\omega 
\beta_{k}}{\alpha_{r}}\right| \rightarrow\left\{\begin{array}{ll}
\left|\frac{\alpha_{k}}{\alpha_{r}}\right| & \text { si } \beta_{k}=0 \\
\infty & \text { si } \beta_{k} \neq 0
\end{array} \quad \text { cuando }|\omega| \rightarrow \infty .\right.
\end{equation}
that still get indented as 

\begin{equation}
  \label{eq:cnv_2022_03_24_389c19861457ad3e9b90g:94}
  \left|c_{k}\right|=\left|\frac{\alpha_{k}-\omega 
\beta_{k}}{\alpha_{r}}\right| \rightarrow\left\{\begin{array}{ll}
                                                                    
\left|\frac{\alpha_{k}}{\alpha_{r}}\right| & \text { si } \beta_{k}=0 \\
                                                                    \infty & 
\text { si } \beta_{k} \neq 0
                                                                  \end{array} 
\quad \text { cuando }|\omega| \rightarrow \infty .\right.
\end{equation}


The source of the problem is that the \begin{array} should be at the
beginning of the line, or at least not having «text» before it (not sure about 
the \end{array}.

Be it as it may. I wrote the ridiculous  function  

(defun my-change-begin-array-to-newline-begin-array-old ()
  (interactive)
  (save-excursion
  (replace-regexp "\\\\begin{array}\\(\\(.\\|\n\\)*?\\)"
                  "\n\\\\begin{array}\\1")))

 which was reasonable fast, but taking Tassilos remarks into account I
 tried.


(defun my-change-begin-array-to-newline-begin-array ()
  (interactive)
    (while (re-search-forward "\\\\begin{array}\\(\\(.\\|\n\\)*?\\)" nil t)
      (replace-match "\n\\\\begin{array}\\1" nil nil)))


But this was much slower.

In any case would someone like to implement this better and even more
general that is all \begin{something} should start at with a newline?

Regards

Uwe Brauer 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to