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: Tassilo Horn
Subject: Re: [AUCTeX-devel] Wrap dollars around active region
Date: Thu, 06 Jun 2013 08:33:25 +0200
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux)

Mosè Giordano <address@hidden> writes:

>> Ups, and in the meantime I've "git reset --hard origin/master".  But
>> it was easy to reproduce, but keep in mind that the attached version
>> is even less tested (not at all!) than the version I've meant to send
>> you before.
> Thank you, that works.  David's "[^z-a]" works as well (it's really
> smart!) and is shorter, I prefer this if there are no
> contraindications, e.g., if "[^z-a]" is treated as an invalid regex in
> some Emacs versions.

Yes, use that.  If that doesn't work in some (X)Emacs version, I guess
we'll hear about that.

> I'd like to match the regex exactly from point to mark position, much
> like  \`...\'  in `string-match'.  `re-search-forward' treats `\'' as
> "end of the buffer" also when the `bound' argument is used.  `\='
> matches the empty string at point, but I found no ways to match the
> empty string at `bound' position.  Anyway, this isn't essential, `\='
> does at least half of the job.

Reading the regex docs again, I can't find anything better than \= at
point, and nothing special at (mark) as you did.

> After some testing I'm not persuaded it's a good idea to remove
> `TeX-math-close-double-dollar'.  E.g., a plain TeX user probably want
> to set `TeX-electric-inline-math' to '("$" . "$"), but if point is
> after the third dollar in the following line
>   $$ a+b=c $
> pressing another time `$' will insert a couple of dollars because
> there (texmathp) returns nil.  This isn't the expected behavior and
> `TeX-math-close-double-dollar' does a better job.

If he uses `TeX-electric-inline-math', how could he reach that 3-dollars
state except with `C-q $'?

> I'm sending the full patch for `tex.el'.  I'll update
> `doc/auctex.texi' as well.

The patch contains the old + the new diff.  Probably a ">> instead of >"
redirection error. ;-)

> In my .emacs I define the following function
> (defun TeX-toggle-electric-inline-math ()
>   "Toggle the value of `TeX-electric-inline-math'."
>   (interactive)
>   (cond
>    ;; "\(...\)" to "$...$"
>    ((equal TeX-electric-inline-math '("\\(" . "\\)"))
>     (setq TeX-electric-inline-math '("$" . "$"))
>     (message "`TeX-insert-dollar' now inserts \"$...$\"."))
>    ;; "$...$" to "$"
>    ((equal TeX-electric-inline-math '("$" . "$"))
>     (setq TeX-electric-inline-math nil)
>     (message "`TeX-insert-dollar' now inserts \"$\"."))
>    ;; Anything else to "\(...\)"
>    (t
>     (setq TeX-electric-inline-math '("\\(" . "\\)"))
>     (message "`TeX-insert-dollar' now inserts \"\\(...\\)\"."))))
> I don't know if it's worth adding it to AUCTeX, I hope it will be
> useful to someone reading this message.

Not sure, but we could setup `TeX-electric-inline-math' depending on
mode, i.e., plain-tex or latex using another defcustom
`TeX-use-electric-math' with boolean value.  But I think it's not worth
it, if it's properly documented in the manual.  You might want to
document it using the relevant hooks (LaTeX/plain-TeX) and (set
(make-local-variable 'TeX-electric-inline-math) ...).

BTW: Isn't `TeX-electric-math' a better name, since it's not restricted
to inline math?

> Completely unrelated, can I reference gmane threads in ChangeLog?

Yes, sure.  If there was a discussion leading to a commit, it's a good
thing to do.

Bye,
Tassilo



reply via email to

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