Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

[auctex] Non-indentation et non-mise en forme

9 réponses
Avatar
Denis Bitouzé
Bonjour,

j'utilise le package listings et je me suis concoct=E9 un nouvel
environnement, ColorListing, =E0 l'int=E9rieur duquel je ne souhaite ni
indentation, ni mise en forme automatique (c'est-=E0-dire que je veux que
les commandes M-q ou C-q-r soient inop=E9rantes sur cet environnement).

=C0 ce sujet, j'ai trouv=E9 ce fil dans les archives :

http://groups.google.fr/group/fr.comp.applications.emacs/browse_thread/thre=
ad/b839341524e9d7e3

et j'ai tent=E9 d'appliquer ce que sugg=E8re Matthieu Moy, c'est-=E0-dire
que, dans mon .emacs, apr=E8s le chargement d'auctex :

(load "auctex.el" nil t t)

j'ai ins=E9r=E9 :

;; begin/end ColorListing align=E9s =E0 gauche ...
(setq LaTeX-verbatim-regexp (concat LaTeX-verbatim-regexp
"\\|ColorListing"))
;; ... et pas d'indentation automatique =E0 l'int=E9rieur.
(add-to-list 'LaTeX-indent-environment-list
'("ColorListing" current-indentation))

mais =E7a m'envoie balader :

Warning (initialization): An error occurred while loading
`/home/bitouze/.emacs':

Symbol's value as variable is void: LaTeX-verbatim-regexp

Quelqu'un pourrait-il m'aider =E0 r=E9gler ce probl=E8me ?

Autre chose : pour =E9viter d'avoir =E0 saisir la commande \lstinline|...|
chaque fois que je veux ins=E9rer un fragment de code au sein d'un
paragraphe de texte, j'ai d=E9fini :

\lstMakeShortInline|

ce qui me permet de ne plus saisir que |...|. Il est par contre
indispensable que ce qui est contenu entre les | ne subisse pas de
coupure de ligne lorsque je proc=E8de =E0 une mise en forme automatique. L=
=E0
aussi, quelqu'un pourrait-il m'aider =E0 obtenir ceci ?

Merci d'avance.
--=20
Denis

9 réponses

Avatar
Sébastien Vauban
Bonjour Denis,

Denis Bitouzé wrote:
Bonjour,

j'utilise le package listings et je me suis concocté un nouvel
environnement, ColorListing, à l'intérieur duquel je ne souhait e ni
indentation, ni mise en forme automatique (c'est-à-dire que je veux que
les commandes M-q ou C-q-r soient inopérantes sur cet environnement).

[...] dans mon .emacs, après le chargement d'auctex :

(load "auctex.el" nil t t)

j'ai inséré :

;; begin/end ColorListing alignés à gauche ...
(setq LaTeX-verbatim-regexp (concat LaTeX-verbatim-regexp
"|ColorListing"))
;; ... et pas d'indentation automatique à l'intérieur.
(add-to-list 'LaTeX-indent-environment-list
'("ColorListing" current-indentation))

mais ça m'envoie balader :

Warning (initialization): An error occurred while loading
`/home/bitouze/.emacs':

Symbol's value as variable is void: LaTeX-verbatim-regexp

Quelqu'un pourrait-il m'aider à régler ce problème ?



Moi, j'avais fait la même chose pour l'environnement TikZ en ne faisan t que
ceci :

--8<---------------cut here---------------start------------->8---
;; leave the `tikzpicture' code unfilled when doing `M-q'
(add-to-list 'LaTeX-indent-environment-list '("tikzpicture"))
--8<---------------cut here---------------end--------------->8---

Cela marche-t-il pour toi ?

Sincèrement,
Seb

--
Sébastien Vauban
Avatar
Alain Ketterlin
Denis Bitouzé writes:

http://groups.google.fr/group/fr.comp.applications.emacs/browse_thread/th read/b839341524e9d7e3

et j'ai tenté d'appliquer ce que suggère Matthieu Moy, c'est- à-dire
que, dans mon .emacs, après le chargement d'auctex :

(load "auctex.el" nil t t)

j'ai inséré :

;; begin/end ColorListing alignés à gauche ...
(setq LaTeX-verbatim-regexp (concat LaTeX-verbatim-regexp
"|ColorListing"))
;; ... et pas d'indentation automatique à l'intérieur.
(add-to-list 'LaTeX-indent-environment-list
'("ColorListing" current-indentation))

Warning (initialization): An error occurred while loading
`/home/bitouze/.emacs':



La discussion que tu mentionnes donne la solution, qui est d'utiliser un
hook. Cela dit, pourquoi ne pas passer par customize ?

Autre chose : pour éviter d'avoir à saisir la commande lstinli ne|...|
chaque fois que je veux insérer un fragment de code au sein d'un
paragraphe de texte, j'ai défini :

lstMakeShortInline|

ce qui me permet de ne plus saisir que |...|. Il est par contre
indispensable que ce qui est contenu entre les | ne subisse pas de
coupure de ligne lorsque je procède à une mise en forme automat ique. Là
aussi, quelqu'un pourrait-il m'aider à obtenir ceci ?



Peut-être via fill-nobreak-predicate ? (qui est customizable :-)

-- Alain.
Avatar
Denis Bitouzé
Le jeudi 23/09/10 à 12h02,
Sébastien Vauban a écrit :

Bonjour Denis,



Bonjour Sébastien,

Moi, j'avais fait la même chose pour l'environnement TikZ en ne
faisant que ceci :

--8<---------------cut here---------------start------------->8---
;; leave the `tikzpicture' code unfilled when doing `M-q'
(add-to-list 'LaTeX-indent-environment-list '("tikzpicture"))
--8<---------------cut here---------------end--------------->8---

Cela marche-t-il pour toi ?



Non, même punition :

Warning (initialization): An error occurred while loading
`/home/bitouze/.emacs':

Symbol's value as variable is void: LaTeX-indent-environment-list

Peux-tu me situer ces lignes dans la partie liée à auctex dans
ton .emacs ?

Merci !

Sincèrement.
--
Denis
Avatar
Denis Bitouzé
Le jeudi 23/09/10 à 12h05,
Alain Ketterlin a écrit :

La discussion que tu mentionnes donne la solution, qui est d'utiliser
un hook.



Rhaaaa, c'est quoi cette bête-là ?

Cela dit, pourquoi ne pas passer par customize ?



Effectivement... Je trouve ces pages de personnalisation assez
intimidantes mais, finalement, ça s'est bien passé ! ;)

> Autre chose : pour éviter d'avoir à saisir la commande
> lstinline|...| chaque fois que je veux insérer un fragment de code
> au sein d'un paragraphe de texte, j'ai défini :
>
> lstMakeShortInline|
>
> ce qui me permet de ne plus saisir que |...|. Il est par contre
> indispensable que ce qui est contenu entre les | ne subisse pas de
> coupure de ligne lorsque je procède à une mise en forme
> automatique. Là aussi, quelqu'un pourrait-il m'aider à obtenir
> ceci ?

Peut-être via fill-nobreak-predicate ? (qui est customizable :-)



Dans quel (sous-(sous-(sous-(sous-(sous-(sous-(sous-(sous-))))))))
menu ? :)

Merci !
--
Denis
Avatar
Sébastien Vauban
Cher Denis,

Denis Bitouzé wrote:
Le jeudi 23/09/10 à 12h02,
Sébastien Vauban a écrit :

Bonjour Denis,



Bonjour Sébastien,

Moi, j'avais fait la même chose pour l'environnement TikZ en ne
faisant que ceci :

--8<---------------cut here---------------start------------->8---
;; leave the `tikzpicture' code unfilled when doing `M-q'
(add-to-list 'LaTeX-indent-environment-list '("tikzpicture"))
--8<---------------cut here---------------end--------------->8---

Cela marche-t-il pour toi ?



Non, même punition :

Warning (initialization): An error occurred while loading
`/home/bitouze/.emacs':

Symbol's value as variable is void: LaTeX-indent-environment-list



--8<---------------cut here---------------start------------->8---
LaTeX-indent-environment-list is a variable defined in `latex.el'.
Its value is shown below.

Documentation:
Alist of environments with special indentation.
The second element in each entry is the function to calculate the
indentation level in columns.

You can customize this variable.

Value:
(("tikzpicture")
("verbatim" current-indentation)
("verbatim*" current-indentation)
("array")
("displaymath")
("eqnarray")
("eqnarray*")
("equation")
("equation*")
("picture")
("tabbing")
("table")
("table*")
("tabular")
("tabular*"))
--8<---------------cut here---------------end--------------->8---


Peux-tu me situer ces lignes dans la partie liée à auctex dans
ton .emacs ?



Si tu insistes... Voir section 5.4

--8<---------------cut here---------------start------------->8---
;;** 2 (info "(auctex)Installation") of AUCTeX

;; support for LaTeX documents
(GNUEmacs
(try-idle-require 'latex) ;; = AUCTeX
(eval-after-load "latex"
'(progn

(message "Evaluate code AFTER HAVING LOADED `latex'...")

;; (try-require 'tex-site)
;; should not be used anymore with current AUCTeX releases


;; ;; LaTeX-sensitive spell checking
;; (add-hook 'tex-mode-hook
;; (lambda ()
;; (make-local-variable 'ispell-parser)
;; (setq ispell-parser 'tex)))


;;** 3 (info "(auctex)Quick Start")

;; Press `C-c C-c File RET RET' to run `dvips'
;; (note that the command is `File' and not `Dvips' as one might
;; expect)

;; Press `C-c C-c Print RET RET' to run `GSview'
;; (also somewhat misleading name)

;; If you want to print the document, do it from GSview.


;;** 5 (info "(auctex)Advanced Features")

;;*** 5.2 (info "(auctex)Completion")

(section "5.2 (auctex)Completion")

;; if this is non-nil when AUCTeX is loaded, the TeX escape
;; character `' will be bound to `TeX-electric-macro'
(setq TeX-electric-escape t)


;;*** 5.4 (info "(auctex)Indenting")

(section "5.4 (auctex)Indenting")

;; leave the `tikzpicture' code unfilled when doing `M-q'
(add-to-list 'LaTeX-indent-environment-list '("tikzpicture"))

;; number of spaces to add to the indentation for each `begin'
;; not matched by a `end'
(setq LaTeX-indent-level 4)

;; number of spaces to add to the indentation for `item''s in list
;; environments
(setq LaTeX-item-indent 0) ; -4

;; number of spaces to add to the indentation for each `{' not
;; matched by a `}'
(setq TeX-brace-indent-level 0) ; 4

;; auto-indentation (suggested by the AUCTeX manual -- instead of
;; adding a local key binding to `RET' in the `LaTeX-mode-hook')
(setq TeX-newline-function 'newline-and-indent)


;;** 6 Controlling Screen (info "(auctex)Display")

;;*** 6.1 (info "(auctex)Font Locking")

(section "6.1 (auctex)Font Locking")

;; (for Org mode) add the `comment' environment to the variable
;; `LaTeX-verbatim-environments' so that, if the `#+TBLFM' line
;; contains an odd number of dollar characters, this does not
;; cause problems with font-lock in latex-mode
(add-to-list 'LaTeX-verbatim-environments "comment")
;; (add-to-list 'LaTeX-verbatim-environments "mcnuweb")
;; ;; FIXME Does not work in .nw files


;;** 7 (info "(auctex)Running TeX and friends") Processors, Viewers and Oth er Programs

;;*** 7.1 Executing (info "(auctex)Commands")

(section "7.1 Executing (auctex)Commands")

;; use PDF mode by default (instead of DVI)
(setq-default TeX-PDF-mode t)


;;*** 7.2 (info "(auctex)Viewing") the formatted output

(section "7.2 (auctex)Viewing the formatted output")

;; use a saner PDF viewer (evince, SumatraPDF)
(setcdr (assoc "^pdf$" TeX-output-view-style)
(cond (running-ms-windows
'("." ""C:/Program Files/SumatraPDF/SumatraPDF. exe" %o"))
;; under Windows, we could open the PDF file with
;; `start "" xxx.pdf' (in a command prompt)
(t
'("." "evince %o"))))

;; A decent viewer reloads the PDF automatically when the file has
;; changed while staying on the same page (no need to close &
;; reopen).

;; Support for forward search with PDF files was added. That me ans
;; the viewer jumps to the page in the output file corresponding
;; to the position in the source file. Currently this only works
;; if you use the pdfsync LaTeX package and xpdf or SumatraPDF as
;; your PDF viewer.

;; for AUCTeX 11.86
(add-to-list 'TeX-view-program-list
'("SumatraPDF"
""C:/Program Files/SumatraPDF/SumatraPDF.exe" %o"))

(when running-ms-windows
(setcdr (assoc 'output-pdf TeX-view-program-selection)
'("SumatraPDF")))


;;*** 7.3 (info "(auctex)Debugging") Catching the errors

(section "7.3 (auctex)Debugging Catching the errors")

;; don't show output of TeX compilation in other window
(setq TeX-show-compilation nil)


;;** 8 (info "(auctex)Multifile") Documents

;; AUCTeX will will assume the file is a master file itself
(setq-default TeX-master t)


;;** 9 Automatic (info "(auctex)Parsing Files")

;; enable parse on load (if no style hook is found for the file)
(setq TeX-parse-self t)

;; enable automatic save of parsed style information when saving
;; the buffer
(setq TeX-auto-save t)


;;** 11 (info "(auctex)Automatic") Customization

;;*** 11.1 (info "(auctex)Automatic Global") Customization for the Site

(section "11.1 (auctex)Automatic Global Customization for the S ite")

;; directory containing automatically generated TeX information.
;; Must end with a slash
(setq TeX-auto-global
"~/.emacs.d/auctex-auto-generated-info/")


;;*** 11.3 (info "(auctex)Automatic Local") Customization for a Directory

(section "11.3 (auctex)Automatic Local Customization for a Dire ctory")

;; directory containing automatically generated TeX information.
;; Must end with a slash
(setq TeX-auto-local
"~/.emacs.d/auctex-auto-generated-info/")
--8<---------------cut here---------------end--------------->8---

HTH,
Seb

--
Sébastien Vauban
Avatar
Alain Ketterlin
Denis Bitouzé writes:

Cela dit, pourquoi ne pas passer par customize ?



Effectivement... Je trouve ces pages de personnalisation assez
intimidantes mais, finalement, ça s'est bien passé ! ;)



A mon avis, c'est une bonne solution pour tout ce qui concerne les
variables.

> Il est par contre indispensable que ce qui est contenu entre les |
> ne subisse pas de coupure de ligne lorsque je procède à une mise en
> forme automatique. Là aussi, quelqu'un pourrait-il m'aider à
> obtenir ceci ?

Peut-être via fill-nobreak-predicate ? (qui est customizable :-)



Dans quel (sous-(sous-(sous-(sous-(sous-(sous-(sous-(sous-))))))))
menu ? :)



M-x customize-variable RET fill-nobreak-predicate RET

:-). Par contre, il faut écrire la fonction qui teste si on est bien à
l'intérieur d'un |...| (par exemple en vérifiant que le nombre de pipes
entre le début de la ligne et le point est impair). C'est laissé en
exercice au lecteur :-).

-- Alain.
Avatar
Denis Bitouzé
Le jeudi 23/09/10 à 13h12,
Alain Ketterlin a écrit :

> Dans quel (sous-(sous-(sous-(sous-(sous-(sous-(sous-(sous-))))))))
> menu ? :)

M-x customize-variable RET fill-nobreak-predicate RET

:-).



OK.

Par contre, il faut écrire la fonction qui teste si on est bien à
l'intérieur d'un |...| (par exemple en vérifiant que le nombre de
pipes



Oui mais non : Magritte a dit « Ceci n'est pas une pipe ».

entre le début de la ligne et le point est impair). C'est
laissé en exercice au lecteur :-).



Eh m'sieur, j'ai un mot d'excuse de mes parents qui explique pourquoi
j'avais piscine le jour du cours de Lisp ; et, sans le cours, je peux
pas faire les exos, m'sieur !
--
Denis
Avatar
Denis Bitouzé
Le jeudi 23/09/10 à 12h24,
Denis Bitouzé a écrit :

Effectivement... Je trouve ces pages de personnalisation assez
intimidantes mais, finalement, ça s'est bien passé ! ;)



Un problème persiste cependant : au sein d'un environnement le
begin{ColorListing} peut ne pas se trouver en début de ligne en cas de
formatage automatique :

begin{itemize}
item Coucou
begin{ColorListing}
Bla bla
bla
end{ColorListing}
end{itemize}

J'ai bien vu dans une option :

Latex Verbatim Regexp

qui est indiquée comme étant « Regexp matching environments with
indentation at col 0 for begin/end. » et qui a pour le moment pour
valeur :

verbatim*?

Comment puis-je faire pour y ajouter ColorListing ?

Merci d'avance.
--
Denis
Avatar
Denis Bitouzé
Le jeudi 23/09/10 à 19h04,
Denis Bitouzé a écrit :

J'ai bien vu dans une option :

Latex Verbatim Regexp

qui est indiquée comme étant « Regexp matching environments with
indentation at col 0 for begin/end. » et qui a pour le moment pour
valeur :

verbatim*?

Comment puis-je faire pour y ajouter ColorListing ?



Il suffit en fait d'ajouter des environnements aux moyen de
|environnement. Dans le cas qui m'occupe, cette liste est désormais :

verbatim*?|ColorListing|BlackListing|syntax|quasisyntax

Merci à tous.
--
Denis