auctex
[Top][All Lists]
Advanced

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

[AUCTeX] Customizing behavior TeX-insert-quote in comments


From: Reiner Steib
Subject: [AUCTeX] Customizing behavior TeX-insert-quote in comments
Date: Wed, 09 Aug 2006 22:46:34 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

[ From the TEX-D-L (German Language TeX Users Group Communication List) ]

On Wed, Aug 09 2006, Sven Kockrick wrote:

| Liebe TeXies,
|
| ich benutze unter Debian Etch emacs-snapshot-gtk mit AUCTeX
| 11.83. Das automatische Ersetzen von " zu "> bzw. "< und --
| zu "= bei der Eingabe funktioniert im normalen Text zu
| bester Zufriedenheit. In Kommentarzeilen (immer nach '%')
| jedoch ist der Mechanismus nicht aktiv: Die Eingabe von "
| erzeugt ein " und -- bringt ein -- hervor. Ich habe die
| Konfigurationsmenus rauf- und runter gesucht, ewige Zeiten
| gegoogelt, FAQs befragt und auch die AUCTeX-Quellen
| angesehen, ohne etwas gefunden zu haben, was mir
| hilft. Langsam gehen mir die Ideen aus, wo/wie ich noch
| suchen kann.
|
| Kann mir hier vielleicht jemand weiterhelfen? Kann man
| AUCTeX ├╝berhaupt so konfigurieren, dass die Eingabeersetzung
| immer (auch in Kommentaren) funzt und wie/wo kann man das
| einstellen?

In short & translated:

Sven wants that " (when using a german style [1]) also inserts "> and
"< (didn't you mean "` and "'?) in comments (like it does in ordinary
text).

The behavior of " (TeX-insert-quote) in comments isn't customizable,
yet.  The following patch makes it customizable.  A similar change
would be required for `LaTeX-babel-insert-hyphen' (BTW, maybe we
should put this test in a function instead of duplicating the code).

But I'm not sure if it's the right approach.  Especially it's not
clear to me why we check for comments and math two times (font-lock
and `texmathp').  Comments?

--8<---------------cut here---------------start------------->8---
--- tex.el      27 Jul 2006 20:18:24 +0200      5.584
+++ tex.el      09 Aug 2006 22:37:55 +0200      
@@ -4603,6 +4603,17 @@
 it is.")
 (make-variable-buffer-local 'TeX-quote-language)
 
+(defcustom TeX-quote-force-quote-faces '(font-latex-verbatim-face
+                                        font-latex-math-face
+                                        font-lock-comment-face)
+  ;; FIXME: Better doc string?
+  "List of faces that inhibit the electric behavior of `TeX-insert-quote'.
+If one of these faces is present at point, `TeX-insert-quote'
+inserts a literal quote."
+  :group 'TeX-quote
+  ;; :version '(auctex . "11.84")
+  :type '(repeat (face)))
+
 (defun TeX-insert-quote (force)
   "Insert the appropriate quotation marks for TeX.
 Inserts the value of `TeX-open-quote' (normally ``) or `TeX-close-quote'
@@ -4613,15 +4624,14 @@
   (if (or force
          ;; Do not insert TeX quotes in verbatim, math or comment constructs.
          (and (fboundp 'font-latex-faces-present-p)
-              (font-latex-faces-present-p '(font-latex-verbatim-face
-                                            font-latex-math-face
-                                            font-lock-comment-face))
-              (font-latex-faces-present-p '(font-latex-verbatim-face
-                                            font-latex-math-face
-                                            font-lock-comment-face)
+              (font-latex-faces-present-p TeX-quote-force-quote-faces)
+              (font-latex-faces-present-p TeX-quote-force-quote-faces
                                           (1- (point))))
+         ;; Why do we need two checks for math and comments? --rsteib
          (texmathp)
-         (and (TeX-in-comment) (not (eq major-mode 'doctex-mode))))
+         (and (and (memq 'font-lock-comment-face TeX-quote-force-quote-faces)
+                   (TeX-in-comment))
+              (not (eq major-mode 'doctex-mode))))
       (self-insert-command (prefix-numeric-value force))
     (TeX-update-style)
     (let* ((lang-override (if (eq (car TeX-quote-language) 'override)
--8<---------------cut here---------------end--------------->8---

Bye, Reiner.

[1]
,----[ (info "(auctex)European") ]
| `german'
| `ngerman'
|      Runs style hook `TeX-language-de-hook'.  Gives `"' word syntax,
|      makes the <"> key insert a literal `"', and pressing it twice will
|      give you opening or closing German quotes (`"`' or `"'').  Typing
|      <-> twice will insert `"='.
`----
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




reply via email to

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