auctex-devel
[Top][All Lists]
Advanced

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

Re: [AUCTeX-devel] Wrap dollars around active region


From: Mosè Giordano
Subject: Re: [AUCTeX-devel] Wrap dollars around active region
Date: Tue, 4 Jun 2013 23:35:59 +0200

Hi Tassilo,

2013/6/4 Tassilo Horn <address@hidden>:
> Mosè Giordano <address@hidden> writes:
>
>>> BTW, I don't see why we need 2 variables.  Shouldn't
>>> `TeX-electric-dollar' with no active region make the behavior you get
>>> with `TeX-math-close-single-dollar' and the same customization.
>> Good question.  I've supposed someone can want to use
>> `TeX-electric-dollar' but not `TeX-math-close-single-dollar' or vice
>> versa.  I use both, but I don't know what other people prefer.
>
> Well, I think most users either like electricity or they don't.  I'd
> prefer just one variable `TeX-electric-math' or so that supersedes
> `TeX-electric-dollar', `TeX-math-close-single-dollar', and
> `TeX-math-close-double-dollar'.
>
> The value '("$" . "$") with no active region, inserting the opening $
> would insert the closing dollar and place point in between.  With an
> active region, it would place the opening and closing dollars around the
> region, and keep the region active.  Then, you could transform a + b = c
> to $$a + b = c$$ by selecting the region and hitting $ twice.
>
> When configured to '("\\(" . "\\)") it would be cool if with the active
> region above, typing $ once would transform it to \(a + b = c\) and
> typing $ again would make it to \[a + b = c\].
>
> Does that make sense?
>
> (As a bonus, I think it would be fancy if a third $ would remove the
> math again, so that you can cycle though the states "no math" -> "inline
> math" -> "displaymath".)
Ok, that's fine with me.  The attached patch does all you suggested.
There are a couple of problems
- the cycling through "inline math" → "display math" → "no math" works
only if marked region stays in a single line because, in regexps, `.'
doesn't match newline.  Suggestions?
- as far as I can see, keeping region active doesn't work with Xemacs.
 In Emacs it suffices to bind `deactivate-mark' to nil, but this
variable isn't present in Xemacs (at least in 21.4.22).  Looking at
code of f90-mode I've found this solution
(http://bzr.savannah.gnu.org/lh/emacs/trunk/annotate/head:/lisp/progmodes/f90.el#L1828)
--8<---------------cut here---------------start------------->8---
    (if (featurep 'xemacs)
        (zmacs-activate-region)
      (setq mark-active t
            deactivate-mark nil))
--8<---------------cut here---------------end--------------->8---
Can `zmacs-activate-region' work?

I still have to adapt doc strings of `TeX-electric-math' and
`TeX-insert-dollar'.

Bye,
Mosè

Attachment: tex-insert-dollar.patch
Description: Binary data


reply via email to

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