auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] A problem with \parencite and fill-paragraph


From: Arash Esbati
Subject: Re: [AUCTeX] A problem with \parencite and fill-paragraph
Date: Thu, 30 Mar 2017 22:01:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2

Ikumi Keita <address@hidden> writes:

>>>>>> address@hidden writes:
>
> [summary]
> Since the list `LaTeX-paragraph-commands-internal' includes "par",
> `paragraph-start' is set to the regexp which matches the every string
> "\par" in the buffer, even if it is the first four letters of
> "\parencite".

Hi Keita,

your observation is correct (needless to say, as always!).

>> Is there any solution (or workaround) to this problem?
>
> A breif test suggests that this particular situation would be solved
> by changing the definition of `LaTeX-paragraph-commands-regexp-make' to:
> ----------------------------------------------------------------------
> (defun LaTeX-paragraph-commands-regexp-make ()
>   "Return a regular expression matching defined paragraph commands."
>   (concat (regexp-quote TeX-esc) "\\("
>         (regexp-opt (append LaTeX-paragraph-commands
>                                                       ;; add here \b
>                             LaTeX-paragraph-commands-internal)) "\\)\\b"))
> ----------------------------------------------------------------------
> However, it seems that this change breaks the filling of the constructs
> involving "\[" and "\]".

You need \B to match the end of a "not-word".  What do you think about a
change like this?

--8<---------------cut here---------------start------------->8---
\documentclass{article}
\begin{document}

\begin{verbatim}
Eval:
(defun LaTeX-paragraph-commands-regexp-make ()
  "Return a regular expression matching defined paragraph commands."
  (let (cmds symbs)
    (dolist (mac (append LaTeX-paragraph-commands
                         LaTeX-paragraph-commands-internal))
      (if (string-match "[a-zA-Z]" mac)
          (push mac cmds)
        (push mac symbs)))
    (concat (regexp-quote TeX-esc) "\\("
            (regexp-opt cmds)
            "\\b"
            "\\|"
            (regexp-opt symbs)
            "\\B"
            "\\)")))

eval-defun as well:
(defvar LaTeX-paragraph-commands-regexp
  (LaTeX-paragraph-commands-regexp-make))

Run:
(LaTeX-set-paragraph-start)
\end{verbatim}

Fill: %
asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf xxxx 
\parencite{asdf}

asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf xxxx \cite{asdf}

\[
  a+b
\]
\parencite{asdf}
\end{document}
--8<---------------cut here---------------end--------------->8---

Best, Arash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]