bug-auctex
[Top][All Lists]
Advanced

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

bug#35128: 12.1.2; C-u ` <symbol> puts cursor before closing dollar sign


From: Ikumi Keita
Subject: bug#35128: 12.1.2; C-u ` <symbol> puts cursor before closing dollar sign
Date: Fri, 05 Apr 2019 02:31:49 +0900

Hi Tsankov,

>>>>> Todor Tsankov <address@hidden> writes:
> The math prefix command "`" with a prefix argument allows to quickly
> insert mathematical symbols surrounded by dollar signs. After this
> command, AucTeX places the cursor before the closing dollar sign, so one
> needs an extra keystroke to move forward and continue typing after that.
> This did not happen in version 11.91, where the cursor was placed after
> the closing dollar sign, so it can be considered a regression. This is
> quite annoying for me: I mostly use this command to insert single
> symbols (for example Greek letters) in the text.

Thanks for reporting the bug.  This is a regression in an attempt to
wrap the whole "\langle" and "\rangle" pair inside the dollar signs,
when one types "`" followed by "(".

I hope that the following definition for the function
`LaTeX-math-insert' would fix the bug.  Could you test it if you know
how to do that?

To other maintainers: The new definition contains a fix to behave
correctly when active region is in effect.  Now typing "`" followed by,
say, "^", wraps the text in the active region in "\hat{}", even when the
prefix C-u is given and the point is placed at the end of the active
region.  (This issue is not a regression brought by me.  It has been in
AUCTeX since long before.)

Regards,
Ikumi Keita

(defun LaTeX-math-insert (string dollar)
  "Insert \\STRING{}.  If DOLLAR is non-nil, put $'s around it.
If `TeX-electric-math' is non-nil wrap that symbols around the
string."
  (let ((active (TeX-active-mark))
        (m (make-marker))
        closer)
    (if (and active (> (point) (mark)))
        (exchange-point-and-mark))
    (when dollar
      (insert (or (car TeX-electric-math) "$"))
      (save-excursion
        (if active (goto-char (mark)))
        ;; Store closer string for later reference.
        (setq closer (or (cdr TeX-electric-math) "$"))
        (insert closer)
        ;; Set temporal marker to decide whether to put the point
        ;; after the math mode closer or not.
        (set-marker m (point))))
    (funcall LaTeX-math-insert-function string)
    ;; If the above `LaTeX-math-insert-function' resulted in
    ;; inserting, e.g., a pair of "\langle" and "\rangle" by
    ;; typing "`(", keep the point between them.  Otherwise
    ;; move the point after the math mode closer.
    (if (and dollar
             (= m (+ (point) (length closer))))
        (goto-char m))
    ;; Make temporal marker point nowhere not to slow down the
    ;; subsequent editing in the buffer.
    (set-marker m nil)))






reply via email to

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