[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX] Forcing indentation in math environments
From: |
Julien Cubizolles |
Subject: |
[AUCTeX] Forcing indentation in math environments |
Date: |
Fri, 20 Feb 2015 15:40:26 +0100 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) |
I want to control indentation in math environments. I've defined the
following function
--8<---------------cut here---------------start------------->8---
(defun jc-math-mode-indent ()
"Force indentation in math mode. "
(interactive "p")
;; (delete-horizontal-space)
(cond
((equal current-prefix-arg nil)
(indent-relative))
)
)
--8<---------------cut here---------------end--------------->8---
used in LaTeX-environment-list:
--8<---------------cut here---------------start------------->8---
(("verbatim" current-indentation)
("verbatim*" current-indentation)
("array" jc-math-mode-indent)
("displaymath" jc-math-mode-indent)
("eqnarray" jc-math-mode-indent)
("eqnarray*" jc-math-mode-indent)
("equation" jc-math-mode-indent)
("equation*" jc-math-mode-indent)
("picture")
("tabbing")
("table")
("table*")
("tabular")
("tabular*")
("code")
("tikzpicture")
("pspicture")
("align" jc-math-mode-indent)
("align*" jc-math-mode-indent)
("table")
("tabular")
("pspicture")
("tikzpicture")
("axis")
("psgraph")
("maple")
("figure")
("scope"))
--8<---------------cut here---------------end--------------->8---
It behaves the way I want:
TAB indents relative to the previous line
C-u TAB aligns with the previous line.
The thing is I'm not sure why it's working :-) since strange things also
happen:
* If yas-minor-mode is on, the point is at the beginning of the text
after using TAB, which is what I want; it's at the beginning of the
line if yas is not on. I could choose something else than TAB for
yas-expansion but this side-effect is actually what I prefer
* I don't see why the (cond ...) is needed but it is: C-u TAB behaves
the same as TAB otherwise, as if I used indent-relative instead of my
custom function.
* If I try to add (delete-horizontal-space) (commented out for now), TAB
acts as C-u TAB.
Any idea how to properly achieve:
* TAB does indent-relative
* C-u TAB aligns with the previous line
* C-u n TAB does indent-relative n times
with point remaining at the same position in the text, regardless of yas
being on or off ?
Thanks.
- [AUCTeX] Forcing indentation in math environments,
Julien Cubizolles <=