[Top][All Lists]

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

Re: [AUCTeX] problem with LaTeX-{current,modify}-environment

From: Mosè Giordano
Subject: Re: [AUCTeX] problem with LaTeX-{current,modify}-environment
Date: Tue, 17 Jun 2014 22:53:35 +0200

Hi Jaap,

2014-06-17 16:45 GMT+02:00 Jaap Eldering <address@hidden>:
> Hi all,
> I'm not sure this should be considered a bug, but
> LaTeX-current-environment and LaTeX-modify-environment seem to behave in
> slightly non-compatible ways. I'm using the code here[1] to toggle
> between (un)starred versions of environments. This works as expected
> when the point is inside the \begin{...} \end{...} pairs of the
> environment, but when the point is on one of the begin/end macros, it
> reads the environment name from the next outer environment, but modifies
> the inner one.

I can reproduce this on the \begin macro but not on the \end one.

Here is an improved version of the `LaTeX-star-environment-dwim' which
cater for the point-on-begin-macro case.

--8<---------------cut here---------------start------------->8---
(defun LaTeX-star-environment-dwim ()
  "Convert between the starred and the not starred version of the
current environment."
  (let ((current-environment
     ;; Check whether we are on the \begin macro.
     (if (equal (TeX-current-macro) "begin")
           (skip-chars-forward "^\}")
           (re-search-backward "{\\([a-zA-Z*]*\\)" nil t)
           (match-string 1))
    ;; If the current environment is starred.
    (if (string-match "\*$" current-environment)
    ;; Remove the star from the current environment.
    (LaTeX-modify-environment (substring current-environment 0 -1))
      ;; Else add a star to the current environment.
      (LaTeX-modify-environment (concat current-environment "*")))))
--8<---------------cut here---------------end--------------->8---


reply via email to

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