auctex
[Top][All Lists]
Advanced

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

Re: [AUCTeX] \verb like macro allowing input on more than one line


From: Tassilo Horn
Subject: Re: [AUCTeX] \verb like macro allowing input on more than one line
Date: Thu, 16 Oct 2014 10:24:55 +0200
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux)

jfbu <address@hidden> writes:

Hi Jean-Francois,

> I have a verbatim like macro with delimiters, I call it \everb, which
> contrarily to \verb accepts multi-line input.
>
> I customized variable LaTeX-verbatim-macros-with-delims but the
> font-locking applies only to cases where argument is on one line:
>
> \everb|foo bar| % ok
>
> \everb|foo
> bar|            % no font locking
>
> Is there a way do enably font-locking in the latter case?

Not really.  I could easily change the relevant regular expression in
font-latex.el so that newlines in `LaTeX-verbatim-macros-with-delims'
would be allowed but I'm not convinced that this is a good idea.  All
such macros I know of (\verb, \lstinline, \mintinline or the macros
generated by minted, e.g., \javainline) have to be closed on the same
line.  If they were highlighted when their argument spans multiple
lines, it would give a false indication of being correct.

What you can do, however, is something like this:

--8<---------------cut here---------------start------------->8---
;; Verbatim macros that may have a newline in their argument
(defvar fjbu/LaTeX-verbatim-multiline-macros-with-delims-local
  '("everb"))

(defun fjbu/LaTeX-activate-font-lock-for-multiline-verb-macros ()
  (add-to-list 'font-latex-syntactic-keywords
               `(,(concat "\\\\\\(?:" 
fjbu/LaTeX-verbatim-multiline-macros-with-delims-local "\\)"
                          "\\(address@hidden)\\(?:\n\\|.\\)*?"
                          "\\(" (regexp-quote TeX-esc) "*\\)\\(\\1\\)")
                 (1 "\"") (2 ".") (3 "\""))))

(add-hook 'LaTeX-mode-hook
          #'fjbu/LaTeX-activate-font-lock-for-multiline-verb-macros)
--8<---------------cut here---------------end--------------->8---

HTH,
Tassilo




reply via email to

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