[Top][All Lists]

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

bug#47757: 13.0.6; Point position after indent-for-tab-command with LaTe

From: Tassilo Horn
Subject: bug#47757: 13.0.6; Point position after indent-for-tab-command with LaTeX-syntactic-comments
Date: Wed, 14 Apr 2021 10:28:05 +0200
User-agent: mu4e 1.5.11; emacs 28.0.50

Gustavo Barros <gusbrs.2016@gmail.com> writes:

Hi Gustavo,

> As of the latest AUCTeX release, when `LaTeX-syntactic-comments' is t,
> as it is by default, calling `indent-for-tab-command' ("TAB") before
> the start of the comment text on the line will move point to the start
> of the comment text.  I believe this to be unexpected, but I might be
> missing something from expected behavior.  Either way, I can provide
> at least one example of inconvenience resulting from this when it
> interacts with `electric-indent-mode' (also on by default).

I was able to reproduce the behavior by your very good recipe.
Basically, I like the behavior to move point to the actual comment text
but the combination with `electric-indent-mode' is indeed very annyoing.
I've changed it on our git master so that it'll jump after the % only if
the currently executing interactive command is an indentation command
(and not, e.g., `TeX-newline').

Here's the changed definition.  Please eval it and see if you spot some
raw edges.

--8<---------------cut here---------------start------------->8---
(defun LaTeX-back-to-indentation (&optional force-type)
  "Move point to the first non-whitespace character on this line.
If it is commented and comments are formatted syntax-aware move
point to the first non-whitespace character after the comment
character(s), but only if `this-command' is an actual indentation
command.  The optional argument FORCE-TYPE can be used to force
point being moved to the inner or outer indentation in case of a
commented line.  The symbols 'inner and 'outer are recognized."
  (if (or (and force-type
               (eq force-type 'inner))
          (and (not force-type)
               (or (and (TeX-in-line-comment)
                        (eq major-mode 'doctex-mode))
                   (and (TeX-in-commented-line)
                        ;; Only move after the % if we're actually
                        ;; performing an indent command and something
                        ;; else like our `TeX-newline-function' which
                        ;; will be invoked automatically by
                        ;; `electric-indent-mode' (bug#47757).
                        (memq this-command
        ;; Should this be anchored at the start of the line?
         (concat "\\(?:" TeX-comment-start-regexp "+[ \t]*\\)+")
         (line-end-position) t))
    (back-to-indentation))) ;; <-- C-x C-e here!
--8<---------------cut here---------------end--------------->8---


reply via email to

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