Arash,

> With the setting above, what is the value of the variable
> `electric-indent-mode' when you open a .tex file, nil or t?

Did you check that?

I did.  I opened a testemacs.tex and said C-h v "electric-indent-mode".  Here 
are the first few lines of the result.

electric-indent-mode is a variable defined in ‘electric.el’.
Its value is nil
Original value was t
Local in buffer testemacs.tex; global value is t

That result looks sensible to me if it means that for .tex files it is nil, 
while for others it is t, maybe?  This is part of my current .emacs:

;; Turn off auto indent in AUC TeX
;; https://tex.stackexchange.com/q/468047/339
;; and https://emacs.stackexchange.com/a/30148
(defun remove-electric-indent-mode ()
  (electric-indent-local-mode -1))

(add-hook 'LaTeX-mode-hook 'remove-electric-indent-mode)
(add-hook 'tex-mode-hook 'remove-electric-indent-mode)

I ran 'emacs -Q' from the command line entered these lines in the buffer

(defun remove-electric-indent-mode ()
  (electric-indent-local-mode -1))
(add-hook 'LaTeX-mode-hook 'remove-electric-indent-mode)

and clicked on Lisp-Interaction > Evaluate defun.  I got no errors.  I then 
opened a .tex file.  It had this, but with "test" immediately after 
\end{itemize}.  When I hit <Enter> I got the "test" indented.

xxxx

\begin{itemize}
\item
    \begin{itemize}
    \item
    \end{itemize}
    test


\end{itemize}

I put the the whole .emacs, below in case that is helpful, since it is only 41 
lines.  Other than that, I think I have a standard Ubuntu emacs setup.

Thank you,
Jim

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(inhibit-startup-screen t)
 '(package-selected-packages '(auctex cmake-mode))
 '(safe-local-variable-values '((TeX-engine . lualatex) (TeX-engine . luatex)))
 '(save-place-mode t)
 '(show-paren-mode t))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

;; JH below here

;; Show highlighted region
(set-face-attribute 'region nil :background "#666" :foreground "#ffffff")

;; Make sure AUCTeX is available
; (require 'package)
; (add-to-list 'package-archives '("auctex" . "https://melpa.org/packages/";))

;; Asymptote editing https://asymptote.sourceforge.io/doc/Editing-modes.html
(add-to-list 'load-path "/usr/local/share/asymptote")
(autoload 'asy-mode "asy-mode.el" "Asymptote major mode." t)
(autoload 'lasy-mode "asy-mode.el" "hybrid Asymptote/Latex major mode." t)
(autoload 'asy-insinuate-latex "asy-mode.el" "Asymptote insinuate LaTeX." t)
(add-to-list 'auto-mode-alist '("\\.asy$" . asy-mode))

;; Turn off auto indent in AUC TeX
;; https://tex.stackexchange.com/q/468047/339
;; and https://emacs.stackexchange.com/a/30148
(defun remove-electric-indent-mode ()
  (electric-indent-local-mode -1))

(add-hook 'LaTeX-mode-hook 'remove-electric-indent-mode)
(add-hook 'tex-mode-hook 'remove-electric-indent-mode)
;; (setq LaTeX-indent-level 0)
;; (setq LaTeX-item-indent 0)
;; (setq TeX-brace-indent-level 0)

________________________________________
From: Arash Esbati <ar...@gnu.org>
Sent: Tuesday, December 5, 2023 15:26
To: Hefferon, Jim S.
Cc: auctex-help
Subject: Re: Turn off auto-indent

⚠ External Sender ⚠


"Hefferon, Jim S." <jheffe...@smcvt.edu> writes:

>> If I open a .tex file, do 'M-x electric-indent-local-mode RET' in order
>> to turn off the mode locally, I get this with your example:
>
>> xxxx
>>   \begin{itemize}
>
>>   \end{itemize}
>> test
>
>> xxxx
>
> Yes, Arash, exactly what I want.  How do I make that permanent?

I think your current setup with `remove-electric-indent-mode' in
`LaTeX-mode-hook' is OK.  Therefore I asked:

> With the setting above, what is the value of the variable
> `electric-indent-mode' when you open a .tex file, nil or t?

Did you check that?

I suspect the problem is somewhere else in your setup.  Maybe you want
to start with 'emacs -Q', eval this

(defun remove-electric-indent-mode ()
  (electric-indent-local-mode -1))
(add-hook 'LaTeX-mode-hook 'remove-electric-indent-mode)

and activate AUCTeX followed by opening a .tex file?  So the standard
debugging process, that should give you a clue.

P.S. Please keep the mailing-list in CC, thanks.

Best, Arash

Reply via email to