Discussion:
[AUCTeX] how to disable indentation for tabular-like environment
François Patte
2016-05-20 09:43:37 UTC
Permalink
Bonjour,

I would like to stop automatic indentation in tabular-like environment
(tabular, longtable...)

I followed this:
http://tex.stackexchange.com/questions/241779/indentation-of-tabular-like-environments-in-auctex-11-88

But this does not work at all....

What isthe "magic"?

Thank you.
--
François Patte
UFR de mathématiques et informatique
Laboratoire CNRS MAP5, UMR 8145
Université Paris Descartes
45, rue des Saints PÚres
F-75270 Paris Cedex 06
Tél. +33 (0)1 8394 5849
http://www.math-info.univ-paris5.fr/~patte
Mosè Giordano
2016-05-21 13:12:12 UTC
Permalink
Hi François,
Post by François Patte
Bonjour,
I would like to stop automatic indentation in tabular-like environment
(tabular, longtable...)
http://tex.stackexchange.com/questions/241779/indentation-of-tabular-like-environments-in-auctex-11-88
But this does not work at all....
What isthe "magic"?
Once you set and apply `LaTeX-indent-environment-list' there is no
"magic" you don't need to do anything else. Maybe you didn't apply
the change or it wasn't saved for all future sessions? What's the
value of `LaTeX-indent-environment-list' in your LaTeX buffer?

Bye,
Mosè
François Patte
2016-05-21 14:52:20 UTC
Permalink
Hi François,
Post by François Patte
Bonjour,
I would like to stop automatic indentation in tabular-like environment
(tabular, longtable...)
http://tex.stackexchange.com/questions/241779/indentation-of-tabular-like-environments-in-auctex-11-88
But this does not work at all....
What isthe "magic"?
Once you set and apply `LaTeX-indent-environment-list' there is no
"magic" you don't need to do anything else. Maybe you didn't apply
the change or it wasn't saved for all future sessions? What's the
value of `LaTeX-indent-environment-list' in your LaTeX buffer?
I have this in my .emacs-custom.el:

'(LaTeX-indent-environment-list
(quote
(("longtable")
("verbatim" current-indentation)
("verbatim*" current-indentation)
("align" LaTeX-indent-tabular)
("align*" LaTeX-indent-tabular)
("array" LaTeX-indent-tabular)
("eqnarray" LaTeX-indent-tabular)
("eqnarray*" LaTeX-indent-tabular)
("displaymath")
("equation")
("equation*")
("picture")
("tabbing")
("table")
("table*"))))

And AucTex continues to indent longtable environment as it did
previously.... ie: an unreadable source file as soon as you have a table
with very long rows
--
François Patte
UFR de mathématiques et informatique
Laboratoire CNRS MAP5, UMR 8145
Université Paris Descartes
45, rue des Saints PÚres
F-75270 Paris Cedex 06
Tél. +33 (0)1 8394 5849
http://www.math-info.univ-paris5.fr/~patte
Mosè Giordano
2016-05-21 17:36:32 UTC
Permalink
Post by François Patte
And AucTex continues to indent longtable environment as it did
previously.... ie: an unreadable source file as soon as you have a table
with very long rows
The problem was that file styles overrode custom settings, hanks for
spotting this! I fixed it in git. If you aren't using development
version of AUCTeX you'll get the fix with next ELPA or stable version.

Bye,
Mosè
Arash Esbati
2016-05-23 12:01:30 UTC
Permalink
Hi Mosè,
Post by Mosè Giordano
Post by François Patte
And AucTex continues to indent longtable environment as it did
previously.... ie: an unreadable source file as soon as you have a table
with very long rows
The problem was that file styles overrode custom settings, hanks for
spotting this! I fixed it in git. If you aren't using development
version of AUCTeX you'll get the fix with next ELPA or stable version.
I wonder if you wanted to do this in currvita.el:

(add-to-list 'LaTeX-item-list '("cvlist" . LaTeX-item-argument) t)

You changed only the year in the copyright statement.

Best, Arash
Mosè Giordano
2016-05-29 14:36:09 UTC
Permalink
Hi Arash,
Post by Arash Esbati
Hi Mosè,
Post by Mosè Giordano
Post by François Patte
And AucTex continues to indent longtable environment as it did
previously.... ie: an unreadable source file as soon as you have a table
with very long rows
The problem was that file styles overrode custom settings, hanks for
spotting this! I fixed it in git. If you aren't using development
version of AUCTeX you'll get the fix with next ELPA or stable version.
(add-to-list 'LaTeX-item-list '("cvlist" . LaTeX-item-argument) t)
You changed only the year in the copyright statement.
No, I didn't want to do that change (`LaTeX-item-list' isn't a
customizable variable, I see little need to append elements to it). I
touched that file because it has a reference to
`LaTeX-indent-environment-list', but I didn't intend to do anything on
it ;-)

Bye,
Mosè
Denis Bitouzé
2016-12-15 17:37:34 UTC
Permalink
Post by Mosè Giordano
Post by François Patte
And AucTex continues to indent longtable environment as it did
previously.... ie: an unreadable source file as soon as you have a table
with very long rows
The problem was that file styles overrode custom settings, hanks for
spotting this! I fixed it in git. If you aren't using development
version of AUCTeX you'll get the fix with next ELPA or stable version.
Could you please elaborate the trick? I added:

┌────
│ (add-to-list 'LaTeX-indent-environment-list '("myenv" current-indentation))
└────

to my `.emacs' but the got the error:

┌────
│ Warning (initialization): An error occurred while loading ‘/home/bitouze/.emacs’:

│ Symbol's value as variable is void: LaTeX-indent-environment-list
└────

despite I'm using the last AUCTeX version: (elpa) auctex-11.89.7.

Thanks.
--
Denis
Mosè Giordano
2016-12-15 18:56:33 UTC
Permalink
Hi Denis,
Post by Denis Bitouzé
┌────
│ (add-to-list 'LaTeX-indent-environment-list '("myenv" current-indentation))
└────
┌────

│ Symbol's value as variable is void: LaTeX-indent-environment-list
└────
despite I'm using the last AUCTeX version: (elpa) auctex-11.89.7.
When you use `add-to-list' is almost always a good idea to wrap it in
a `with-eval-after-load' (or `eval-after-load' in older Emacsens),
unless you know when the variable is defined in your init file:

(with-eval-after-load "latex"
(add-to-list 'LaTeX-indent-environment-list '("myenv" current-indentation)))

This should do the trick.

Bye,
Mosè
Denis Bitouzé
2016-12-15 19:27:52 UTC
Permalink
Post by Mosè Giordano
Hi Denis,
Hi Mosè,
Post by Mosè Giordano
When you use `add-to-list' is almost always a good idea to wrap it in
a `with-eval-after-load' (or `eval-after-load' in older Emacsens),
Okay, I've written your advise as a comment at 1st line in my
`.emacs'! :)
Post by Mosè Giordano
(with-eval-after-load "latex"
(add-to-list 'LaTeX-indent-environment-list '("myenv" current-indentation)))
This should do the trick.
Indeed, no more error: thanks.

Maybe I didn't understand what `current-indentation' is supposed to do
but with the following:

┌────
│ \begin{myenv}
│ \begin{frame}
│ Foo.
│ \end{frame}
│ \end{myenv}
└────

and the cursor on the line:

┌────
│ \begin{frame}
└────

pressing <TAB> does indent the line.
--
Denis
Mosè Giordano
2016-12-15 21:22:39 UTC
Permalink
Post by Denis Bitouzé
Maybe I didn't understand what `current-indentation' is supposed to do
┌────
│ \begin{myenv}
│ \begin{frame}
│ Foo.
│ \end{frame}
│ \end{myenv}
└────
┌────
│ \begin{frame}
└────
pressing <TAB> does indent the line.
`current-indentation` is usually employed in verbatim-like
environments: as it leaves indentation as it is, doesn't change. It
keeps "current indentation". What do you want to achieve?

Bye,
Mosè
Denis Bitouzé
2016-12-16 07:17:55 UTC
Permalink
Post by Mosè Giordano
Post by Denis Bitouzé
Maybe I didn't understand what `current-indentation' is supposed to do
┌────
│ \begin{myenv}
│ \begin{frame}
│ Foo.
│ \end{frame}
│ \end{myenv}
└────
┌────
│ \begin{frame}
└────
pressing <TAB> does indent the line.
`current-indentation` is usually employed in verbatim-like
environments: as it leaves indentation as it is, doesn't change.
That's the reason I'm puzzled: I expected pressing <TAB> doesn't indent
the line if the cursor is on the line:

┌────
│ \begin{frame}
└────
Post by Mosè Giordano
It keeps "current indentation". What do you want to achieve?
I'd like to achieve for `myenv' environment the same behavior as the
`document' environment. For instance, with the following content:

┌────
│ \documentclass{article}
│ \begin{document}
│ Foo.
│ \end{document}
└────

and the cursor is on the line:

┌────
│ Foo.
└────

pressing <TAB> doesn't indent the line.
--
Denis
Mosè Giordano
2016-12-16 13:38:07 UTC
Permalink
Hi Denis,
Post by Denis Bitouzé
I'd like to achieve for `myenv' environment the same behavior as the
┌────
│ \documentclass{article}
│ \begin{document}
│ Foo.
│ \end{document}
└────
┌────
│ Foo.
└────
pressing <TAB> doesn't indent the line.
The `LaTeX-document-regexp' option should be what you're looking for.

Bye,
Mosè
Denis Bitouzé
2016-12-16 14:00:28 UTC
Permalink
Hi Mosè,
Post by Mosè Giordano
Post by Denis Bitouzé
I'd like to achieve for `myenv' environment the same behavior as the
┌────
│ \documentclass{article}
│ \begin{document}
│ Foo.
│ \end{document}
└────
┌────
│ Foo.
└────
pressing <TAB> doesn't indent the line.
The `LaTeX-document-regexp' option should be what you're looking for.
Regexp? Sigh... why life is to complicated?! ;)

Anyway, I couldn't find any reference concerning
`LaTeX-document-regexp'. Any pointer?
--
Denis
Mosè Giordano
2016-12-16 14:09:03 UTC
Permalink
Post by Arash Esbati
Hi Mosè,
Post by Mosè Giordano
Post by Denis Bitouzé
I'd like to achieve for `myenv' environment the same behavior as the
┌────
│ \documentclass{article}
│ \begin{document}
│ Foo.
│ \end{document}
└────
┌────
│ Foo.
└────
pressing <TAB> doesn't indent the line.
The `LaTeX-document-regexp' option should be what you're looking for.
Regexp? Sigh... why life is to complicated?! ;)
I don't know why it was conceived as a regexp rather than as a list of
environment names (a regexp can be then built automatically).
Post by Arash Esbati
Anyway, I couldn't find any reference concerning
`LaTeX-document-regexp'. Any pointer?
There are a number of AUCTeX's features hidden in the source code,
this increases the pleasure of discovering new features every day ;-)
Jokes apart,

(setq LaTeX-document-regexp "document\\|foo")

and you're done.

Bye,
Mosè
Denis Bitouzé
2016-12-16 14:17:24 UTC
Permalink
Post by Mosè Giordano
Post by Denis Bitouzé
Regexp? Sigh... why life is to complicated?! ;)
I don't know why it was conceived as a regexp rather than as a list of
environment names (a regexp can be then built automatically).
Good news! :)
Post by Mosè Giordano
Post by Denis Bitouzé
Anyway, I couldn't find any reference concerning
`LaTeX-document-regexp'. Any pointer?
There are a number of AUCTeX's features hidden in the source code,
this increases the pleasure of discovering new features every day ;-)
I don't like speleology 'cause I'm claustrophobic :)
Post by Mosè Giordano
Jokes apart,
(setq LaTeX-document-regexp "document\\|foo")
and you're done.
Indeed, thanks!

But what's the point with `\\|foo'? AFAICS:

┌────
│ (setq LaTeX-document-regexp "myenv")
└────

does the trick as well.
--
Denis
Mosè Giordano
2016-12-16 14:25:13 UTC
Permalink
Post by Denis Bitouzé
┌────
│ (setq LaTeX-document-regexp "myenv")
└────
does the trick as well.
\(a\|b\)

matches "a" or "b" (but in the variable you don't need to put the
outer parentheses, and you have to double escape the backslash), you
have to include both "document" and "myenv" in order to indent both in
the same way. With your setting I'm not sure the "document"
environment will be indented correctly.

Bye,
Mosè
Denis Bitouzé
2016-12-16 14:34:05 UTC
Permalink
Post by Mosè Giordano
Post by Denis Bitouzé
┌────
│ (setq LaTeX-document-regexp "myenv")
└────
does the trick as well.
\(a\|b\)
matches "a" or "b" (but in the variable you don't need to put the
outer parentheses, and you have to double escape the backslash), you
have to include both "document" and "myenv" in order to indent both in
the same way. With your setting I'm not sure the "document"
environment will be indented correctly.
I see. So you meant `myenv' instead of `foo', don't you?

Anyway, regarding your explanation, I couldn't see the point with the
`\' before `\|myenv' in:

┌────
│ (setq LaTeX-document-regexp "document\\|myenv")
└────
--
Denis
Mosè Giordano
2016-12-16 14:44:09 UTC
Permalink
Post by Denis Bitouzé
I see. So you meant `myenv' instead of `foo', don't you?
Yes, I didn't look back to the name of the environment ;-)
Post by Denis Bitouzé
Anyway, regarding your explanation, I couldn't see the point with the
┌────
│ (setq LaTeX-document-regexp "document\\|myenv")
└────
The plain regexp would actually be

document\|myenv

but in Lisp code you have to escape the backslash, so you should use


document\\|myenv

See https://www.emacswiki.org/emacs/RegularExpression#RegexpsInEmacs

Bye,
Mosè
Denis Bitouzé
2016-12-16 14:47:01 UTC
Permalink
Post by Mosè Giordano
Post by Denis Bitouzé
I see. So you meant `myenv' instead of `foo', don't you?
Yes, I didn't look back to the name of the environment ;-)
Hence my puzzlement :)
Post by Mosè Giordano
Post by Denis Bitouzé
Anyway, regarding your explanation, I couldn't see the point with the
┌────
│ (setq LaTeX-document-regexp "document\\|myenv")
└────
The plain regexp would actually be
document\|myenv
but in Lisp code you have to escape the backslash, so you should use
document\\|myenv
See https://www.emacswiki.org/emacs/RegularExpression#RegexpsInEmacs
OK, thanks!
--
Denis
Tamas Papp
2016-12-16 13:27:38 UTC
Permalink
Post by Mosè Giordano
Post by Denis Bitouzé
┌────
│ (add-to-list 'LaTeX-indent-environment-list '("myenv" current-indentation))
└────
┌────

│ Symbol's value as variable is void: LaTeX-indent-environment-list
└────
despite I'm using the last AUCTeX version: (elpa) auctex-11.89.7.
When you use `add-to-list' is almost always a good idea to wrap it in
a `with-eval-after-load' (or `eval-after-load' in older Emacsens),
(with-eval-after-load "latex"
(add-to-list 'LaTeX-indent-environment-list '("myenv" current-indentation)))
This should do the trick.
An alternative approach is use-package, eg

(use-package latex
:config (add-to-list 'LaTeX-indent-environment-list
'("myenv" current-indentation)))

See https://github.com/jwiegley/use-package

Best,

Tamas
Denis Bitouzé
2016-12-16 13:53:03 UTC
Permalink
Post by Tamas Papp
An alternative approach is use-package, eg
(use-package latex
:config (add-to-list 'LaTeX-indent-environment-list
'("myenv" current-indentation)))
See https://github.com/jwiegley/use-package
Interesting package I'll probably... use :) Thanks for the pointer.

Best.
--
Denis
Loading...