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: jfbu
Subject: Re: [AUCTeX] \verb like macro allowing input on more than one line
Date: Thu, 16 Oct 2014 13:20:41 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Le 16/10/2014 10:24, Tassilo Horn a écrit :
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


thanks for the help,

but after fiddling a bit with no success in my .dtx file,
I realized after adding this to the end
of my .emacs (or rather in a file .emacs.d/init.el, which is loaded
from .emacs) that M-x latex-mode issued an error.
Wrong type argument: characterp, "everb"

The *Messages* buffer:

Loading ---/.emacs.d/init.el (source)...done
Loading ---/.emacs.d/custom.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a. [2 times]
File mode specification error: (wrong-type-argument characterp "everb")
Applying style hooks...
Loading +++/auto/test.el (source)...done
Loading ---/.emacsaddons/auctex/style/article.elc...done
Applying style hooks... done
Loading vc-git...done
cons: Wrong type argument: characterp, "everb"

My AUCTeX is I believe still in version 11.85

in preview.el, I found:

;; $Id: preview.el,v 1.285 2010/10/14 19:30:38 angeli Exp $

however in my tex-site.el I have

(defconst AUCTeX-version "11.86"
    "AUCTeX version.
If not a regular release, the date of the last change.")

(defconst AUCTeX-date "2010-02-21"
  "AUCTeX release date using the ISO 8601 format, yyyy-mm-dd.")

Sorry about the mess, I think the tex-site.el is a remnant
of an attempt to use 11.86, but that stuff in auctex/ is
from 11.85. All files have modification dates March 2011.

I recall spending on two occasions at least quite
a bit of time on wanting to install a more recent AUCTeX,
but each time I ended up having various problems

(including some
with preview; currently I don't use at all preview).

Jean-Francois












reply via email to

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