Subject: bug#52852: 13.0.15; TeX-insert-quote fails near the beginning of buffer

From: Andrea Greselin <[email-masked]>
Date: Tue, 28 Dec 2021 16:22:52 +0100

Hello,

when ‘TeX-quote-after-quote’ is nil, ‘TeX-insert-quote’ fails when
called from a position closer to the beginning of buffer than the
length of an opening quotation mark. That’s due to a ‘forward-char’
trying to go back to see if the thing preceding the point is an
opening quote.

To reproduce the bug, open a buffer in ‘LaTeX-mode’, type a character
and invoke ‘TeX-insert-quote’. It just prints the message “Beginning
of buffer” without inserting anything.

I think it’s reasonable to insert an opening quote whenever there
isn’t room for one behind the point. I’ve attached a patch that
implements this behaviour.

All the best,
Andrea
diff --git a/auctex-13.0.15/tex.el b/auctex-13.0.15/tex.el
index 3cf8f65..d73c240 100644
--- a/auctex-13.0.15/tex.el
+++ b/auctex-13.0.15/tex.el
@@ -6163,7 +6163,7 @@ With prefix argument FORCE, always inserts \" characters."
                         (t
                          (delete-char -1)
                          close-quote)))
-        (insert (cond ((bobp)
+        (insert (cond ((<= (point) (length open-quote))
                        open-quote)
                       ((= (preceding-char) (string-to-char TeX-esc))
                        ?\")