emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] Have LaTeX mode use normal double quotes in comments.


From: Karl Fogel
Subject: [PATCH] Have LaTeX mode use normal double quotes in comments.
Date: Mon, 29 Aug 2016 14:44:12 -0500

(Probably everything I say here is true of TeX mode as well, but I've only been 
working in LaTeX mode.)

In LaTeX mode, typing a double quote (") runs `tex-insert-quote' in 
lisp/textmodes/tex-mode.el.  That function inserts `` or '' depending on 
whether you're opening or closing the quoted string.  However, when one is in a 
LaTeX comment, one usually doesn't want the fancy double quotes -- much more 
often, at least in my editing, one just wants normal double quotes.  Here's the 
contrast:

  % Comments begin with "%" and usually call for "normal" double quotes.
  Whereas for uncommented text, I always say ``The fancier the better!''

So, three questions:

* Any objections to the patch below?

* It seems weird to use "(nth 8 (save-excursion (syntax-ppss)))" to ask the 
question "Are we in a comment?"  I could further abstract that out into a 
helper function, just in tex-mode.el, since `tex-font-lock-verb' also does 
something similar and thus could call the helper too.

* My guess is most others would usually want normal double-quote in comments, 
but who knows, maybe users' default needs in this regard are more varied than I 
think.  Should this behavior be configurable?  I could certainly make it, and 
could leave the default as-is or switch the default.  Thoughts welcome.

I'm new to tex-mode.el, so wanted to check here on all the above issues before 
committing anything.

Best regards,
-Karl

index 710899f..816eedd 100644
--- lisp/textmodes/tex-mode.el
+++ lisp/textmodes/tex-mode.el
@@ -1311,6 +1311,8 @@ tex-insert-quote
   ;;
   (if (or arg (memq (char-syntax (preceding-char)) '(?/ ?\\))
           (eq (get-text-property (point) 'face) 'tex-verbatim)
+          ;; If inside a comment, use normal double quotes:
+          (nth 8 (save-excursion (syntax-ppss)))
           ;; Discover if a preceding occurrence of `tex-open-quote'
           ;; should be morphed to a normal double quote.
           ;;



reply via email to

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