3

So basically, for reasons unknown we don't use regular LaTeX style quotes at my company, instead just using regular double quotes. However, tex-mode in emacs automatically substitutes the " key for ``''. I can't find any way of disabling this.

I've tried setting tex-open-quote and tex-close-quote to ", which works to some degree, but when inserting quotes inside a \verb!!, it still substitutes the first ! with `'' for some unknown reason.

I'm using Doom-Emacs, but I doubt this has anything to do with the functionality.

Is there any way of completely disabling this functionality, or at least unmapping the " key from tex-insert-quote?

Tyler
  • 21,719
  • 1
  • 52
  • 92
ryan27968
  • 133
  • 2
  • Have you tried disabling it in pure Emacs without init file? (`emacs -q`) –  Aug 20 '19 at 15:10
  • Typing " twice should result in a classical ". – StarBug Aug 20 '19 at 15:44
  • Firstly, that doesn't really solve my problem, as I don't want to have to double tap quotes every time. Secondly, that doesn't even work in my emacs. There's likely something broken in either my config or in doom-emacs itself. – ryan27968 Aug 20 '19 at 15:47
  • Just to clarify, are you using AUC-Tex? – StarBug Aug 20 '19 at 15:57
  • I don't believe so. I haven't installed anything additional, I'm just using the defaults from doom-emacs. `C-h m` says my major mode is `tex-mode` and I don't spot any other tex-related minor modes. – ryan27968 Aug 20 '19 at 16:02

3 Answers3

3

This appears to be smartparens doing (another package that Doom uses). Even if you unmap the double quote key like so:

(map! :after tex
      :map TeX-mode-map
      "\"" nil)

;; this is equivalent to
(with-eval-after-load 'tex
  (define-key TeX-mode-map "\"" nil))

Smartparens' defaults will still kick in when you type a double quote. You can disable this troublesome rule with:

(after! smartparens-latex
  (sp-local-pair '(tex-mode plain-tex-mode latex-mode LaTeX-mode)
                  "``" "''" :actions :rem))

;; This is equivalent to
(with-eval-after-load 'smartparens-latex
  (sp-local-pair '(tex-mode plain-tex-mode latex-mode LaTeX-mode)
                  "``" "''" :actions :rem))

I'll look into merging this into the lang/latex module upstream.

Henrik
  • 340
  • 1
  • 6
  • 1
    Thanks, this got me on the right track, although the maps that you suggested don't quite work. I've tweaked a bit and gotten it working. My working fix in the related github issue: https://github.com/hlissner/doom-emacs/issues/1688 If you fix your solution, I'll accept your answer as it narrowed down the true culprit. – ryan27968 Aug 22 '19 at 08:54
  • 1
    In vanilla emacs, it was neccessary for me to use both `(setq TeX-quote-after-quote t)` and `(with-eval-after-load 'smartparens-latex (sp-local-pair '(tex-mode plain-tex-mode latex-mode LaTeX-mode) "``" "''" :actions :rem))` to get desired behaviour -- which is being able to insert double quotes as expected. – Tomáš Kruliš Jul 15 '21 at 13:24
0

You can rebind the " key in tex-mode with the following:

(eval-after-load "tex-mode"
  (define-key tex-mode-map "\"" 'self-insert-command))

self-insert-command turns " back into a normal key, it will just insert itself when you press it. If you want it to do anything else, use a different function here.

Tyler
  • 21,719
  • 1
  • 52
  • 92
  • No luck. For some reason your binding command did not work, although I was able to get the binding to work using some doom-emacs helper macros. Either way, it still inserts the latex funky quotes. I've done `C-h "` while in insert mode and can confirm it has indeed mapped correctly to `self-insert-command`, yet it still replaces the quotes. – ryan27968 Aug 20 '19 at 15:28
  • Hmm... I've just tried your remap with `emacs -q` as suggested by @DoMiNeLa10 and it does work correctly. It seems doom-emacs must be interfering somehow. Will consult on the doom-emacs github. – ryan27968 Aug 20 '19 at 15:38
0

In case you are using AUCTex, you can use

(setq TeX-quote-after-quote t)

From the manual: If TeX-quote-after-quote is non-nil, typing " will insert a literal double quote.

StarBug
  • 479
  • 4
  • 10