I'm writing a document with AUCTeX using the songs package. It all works well, but it requires to input chords like in the sequence \[La]. The problem is, AUCTeX ignores the first bracket (since it is escaped), but not the second one, and it complains there is no matching opening bracket. This gives a lot of warnings on the screen, blocks sexp navigation, and causes problems when indenting. For instance, I have this piece of song:
\beginsong{Dio è amore\\Bóg jest Miłością}[by={Taizé}]
\beginchorus
\[Re]Dio \[Sol]è a\[Re]more, \[Fa#m]osa a\[Sim]mare \[Sol]senza ti\[La]more. % TODO controllare tempi prime parole
\brk
\[Re]Dio \[Mim]è a\[Re]mo\[La]re. \[Sim]Non te\[La]mere \[Re]mai.
\endchorus
\endsong
When calling indent-region (C-M-\) on this text, it becomes
\beginsong{Dio è amore\\Bóg jest Miłością}[by={Taizé}]
\beginchorus
\[Re]Dio \[Sol]è a\[Re]more, \[Fa#m]osa a\[Sim]mare \[Sol]senza ti\[La]more. % TODO controllare tempi prime parole
\brk
\[Re]Dio \[Mim]è a\[Re]mo\[La]re. \[Sim]Non te\[La]mere \[Re]mai.
\endchorus
\endsong
Any ideas? Should I modify the syntax table? Can I modify it with multi character sequences?
Thanks!
EDIT: I've been (legitimately) asked for a MWE, so here it is. My init file:
(require 'latex)
(require 'tex-mode)
;;suggested from info file
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-debug-bad-boxes t)
(setq-default TeX-master nil)
(setq TeX-electric-math (cons "\\(" "\\)"))
(setq LaTeX-electric-left-right-brace t)
(setq prettify-symbols-unprettify-at-point 'right-edge)
(setq LaTeX-includegraphics-read-file 'LaTeX-includegraphics-read-file-relative)
(add-hook 'LaTeX-mode-hook 'prettify-symbols-mode)
(add-hook 'latex-mode-hook 'prettify-symbols-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-org-cdlatex)
(add-hook 'latex-mode-hook 'turn-on-org-cdlatex)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'latex-mode-hook 'visual-line-mode)
(defun my--LaTeX-CDLaTeX-utils-setup ()
"Set up variables and similar that should be active only in LaTeX (AUCTeX) buffers."
(setq-local cdlatex-takeover-dollar nil
cdlatex-takeover-parenthesis nil))
(add-hook 'LaTeX-mode-hook 'my--LaTeX-CDLaTeX-utils-setup)
(add-hook 'latex-mode-hook 'my--LaTeX-CDLaTeX-utils-setup)
(define-key LaTeX-mode-map (kbd "<tab>") (lambda () (interactive) (org-try-cdlatex-tab)))
(define-key latex-mode-map (kbd "<tab>") (lambda () (interactive) (org-try-cdlatex-tab)))
(define-key LaTeX-mode-map (kbd "C-<return>") #'cdlatex-item)
(define-key latex-mode-map (kbd "C-<return>") #'cdlatex-item)
(I omitted the part relevant to RefTeX, since it's not important). The .tex file:
\documentclass[a4paper]{article}
\usepackage[chorded]{songs}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\renewcommand{\flatsymbol}{b}
\renewcommand{\sharpsymbol}{\#}
\renewcommand{\printchord}[1]{\rmfamily\bf#1}
\renewcommand{\clineparams}{
\baselineskip=12pt
\lineskiplimit=1pt
\lineskip=1pt
}
\baselineadj=10pt
\begin{document}
\notenamesin{LA}{SI}{DO}{RE}{MI}{FA}{SOL}
\notenamesout{La}{Si}{Do}{Re}{Mi}{Fa}{Sol}
\songcolumns{1}
\songsection{Canoni di Taizé}
\begin{songs}{}
\beginsong{Dio è amore\\Bóg jest Miłością}[by={Taizé}]
\beginchorus
\[Re]Dio \[Sol]è a\[Re]more, \[Fa#m]osa a\[Sim]mare \[Sol]senza ti\[La]more. % TODO controllare tempi prime parole
\brk
\[Re]Dio \[Mim]è a\[Re]mo\[La]re. \[Sim]Non te\[La]mere \[Re]mai.
\endchorus
\endsong
\end{songs}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
songspackage).\begin{songs}...\end{songs}, hitC-c .to mark the environment, doM-x indent-region RETand the content is indented as expected and not the way shown above. Start withemacs -Q, activate AUCTeX and try it again; maybe it iscdlatexdoing something weird, I don't have it installed, so I can't tell.emacs -QI still get the old behavior. What Emacs are you using? I'm onGNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.36, cairo version 1.17.6) of 2023-01-22(built from source)