0

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:
3
  • 1
    Can you provide a complete .tex file and the steps what you did? I can't reproduce what you describe with the snippet above (NB: I don't know the songs package). Commented Jan 14, 2023 at 11:24
  • Thanks. I can put point somewhere inside \begin{songs}...\end{songs}, hit C-c . to mark the environment, do M-x indent-region RET and the content is indented as expected and not the way shown above. Start with emacs -Q, activate AUCTeX and try it again; maybe it is cdlatex doing something weird, I don't have it installed, so I can't tell. Commented Jan 15, 2023 at 10:39
  • @ArashEsbati thanksfor your reply, and sorry for my delay. Actually, in my emacs -Q I still get the old behavior. What Emacs are you using? I'm on GNU 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) Commented Jan 30, 2023 at 12:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.