auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrong indentation of align* env with empheq.el


From: Arash Esbati
Subject: Re: Wrong indentation of align* env with empheq.el
Date: Tue, 29 Nov 2022 10:10:16 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50

Hi Keita,

Ikumi Keita <ikumi@ikumi.que.jp> writes:

> It seems that it doesn't in the range I tried, but I don't agree with
> that idea so much. In my opinion, let-binding of
> `LaTeX-current-environment' should be restricted to rather low level
> functions where it is absolutely evident that it doesn't have bad side
> effects. Doing in general-purpose functions like `LaTeX-env-args' can
> lead to a mysterious behavior which is hard to debug for future
> developers.

After having a second thought, I agree with you that my proposal isn't
that good.

> If you still want to stay with that idea, how about moving the
> let-binding into `LaTeX--env-parse-args'? Then we can avoid unintended
> interaction of `LaTeX-current-environment' and
> `LaTeX-insert-environment', and simplify `LaTeX-env-item-args' and
> `LaTeX-env-label-args' at the same time.

I think we can have that easier by let-binding
`LaTeX-current-environment' around the call to `LaTeX--env-parse-args'.
I mean something like this.  WDYT?

--8<---------------cut here---------------start------------->8---
diff --git a/latex.el b/latex.el
index 6303c337..c2168060 100644
--- a/latex.el
+++ b/latex.el
@@ -1114,10 +1114,10 @@ The first item is inserted by the function 
`LaTeX--env-item'."
 (defun LaTeX-env-item-args (environment &rest args)
   "Insert ENVIRONMENT followed by ARGS and first item.
 The first item is inserted by the function `LaTeX--env-item'."
+  (LaTeX-insert-environment environment)
   (let ((LaTeX-current-environment environment))
-    (LaTeX-insert-environment environment)
-    (LaTeX--env-parse-args args)
-    (LaTeX--env-item environment)))
+    (LaTeX--env-parse-args args))
+  (LaTeX--env-item environment))

 (defcustom LaTeX-label-alist
   '(("figure" . LaTeX-figure-label)
@@ -1329,8 +1329,8 @@ Just like array and tabular."

 (defun LaTeX-env-label-args (environment &rest args)
   "Run `LaTeX-env-label' on ENVIRONMENT and insert ARGS."
+  (LaTeX-env-label environment)
   (let ((LaTeX-current-environment environment))
-    (LaTeX-env-label environment)
     (LaTeX--env-parse-args args)))

 (defun LaTeX-env-list (environment)
@@ -1458,8 +1458,8 @@ Just like array and tabular."

 (defun LaTeX-env-args (environment &rest args)
   "Insert ENVIRONMENT and arguments defined by ARGS."
+  (LaTeX-insert-environment environment)
   (let ((LaTeX-current-environment environment))
-    (LaTeX-insert-environment environment)
     (LaTeX--env-parse-args args)))

 (defun LaTeX-env-label-as-keyval (_optional &optional keyword keyvals 
environment)
--8<---------------cut here---------------end--------------->8---

Otherwise, I see two other options which are:

 • Use another name, say `LaTeX-current-environment-for-insertion',
   which is ugly

 • Drop it completely and use the function in the hooks

Best, Arash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]