Hi Artem, >>>>> Artem Yurchenko <artemyurche...@zoho.com> writes: > Suppose that TeX-electric-math is set to dollar and > TeX-refuse-unmatched-dollar is set to true. I am thinking, when is the > «refuse the dollar» behaviour going to happen? It's not going to > happen in inline math or display math — the user uses dollars for math > and we never «refuse the dollar» when enclosed by dollars. It's /only/ > going to apply in some environments that don't explicitly use dollars, > such as «equation», «align», «cases*» and so on. However, in some of > those environments this behaviour is going to be /incorrect/, as noted > in bug#57626, for example.
> So, the only environment (sorry for the pun) where we «refuse the > dollar» is also the environment where that feature breaks > occasionally. Thanks, now I see what you mean. I naively imagine that users (if exist at all) who like such customization would happily type C-q $ when they encounter such refusal. Anyway, I think this topic isn't much important. >> I think other occurrence of single quotes in >>> you need exactly one $, you can use `C-1 $'. > I think I should use `C-1 \\[TeX-insert-dollar]' according to the help > entry on «Keys in Documentation»? I'm talking about single quotes surrounding the key sequence. ...Hm, I was thinking that elisp reference discourages to surround key sequence by single quotes, but it seems that's my hasty conclusion. Sorry, forget about this. >>> Otherwise, when in a verbatim construct or escaped with `\\', > >should also fixed according to the elisp reference direction. > Oh, yes, missed that. By the same argument, I withdraw this remark as well. > I had an impression that it should blink to the closing paren when > applied to a region in the electric mode, but per docs it's not > required. However, it doesn't respect the behaviour of > blink-matching-paren, which allows the user to choose between jumping > onscreen, jumping offscreen or just blinking. Thanks for clarification. I don't think blinking is needed when there is an active region because the starting position is obvious without blinking. On the other hand, I realize that `TeX-insert-dollar' falls much behind at emulating emacs built-in paren-matching behavior. Well, it seems to me that poor blinking feature isn't a serious issue, so my opinion is to postpone it for now. :-) >> I noticed two incompatibilities with the current behavior. > Okay, I guess it is more difficult than I felt initially :D :-) >> 2. Suppose that TeX-electric-math is a pair of dollars. Then typing $ >> at >> $E = mc^2-!- >> inserts two dollars, not one dollar. > That is indeed a regression, however, I feel that it might be not very > serious. An electric user will almost always have balanced dollars. Unbalanced dollar often occurs during editing drafts and revising existing documents even for an electric user. Thus I think this behavior must be fixed. >> (This is optional) The revised patch increases calls to `texmathp'. It >> doesn't make much difference anyway, it is preferable if you can reduce >> them. > Will consider the best approach to this. My first idea is actually to > «cache» texmathp. That is, when we see that the buffer is unmodified > since the last call, we just don't do anything. I think it's enough to cache in one command execution. When the user types "$", `texmathp' is called once in `TeX-insert-dollar-refuse-p' and again at ---------------------------------------------------------------------- ((and (texmathp) (or (string= (car texmathp-why) "\$") (string= (car texmathp-why) "\$\$"))) ---------------------------------------------------------------------- in the body of `TeX-insert-dollar', in your last patch. I'm not sure whether you plan to keep the basic logic structure of electricity, but if it is kept, the first result of `texmathp' can be used for the second. (There is another call in `delete-selection' property which calls `TeX-insert-dollar-refuse-p', but it seems difficult to me to make use of cache in a simple and robust way.) Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine #Gaza #StopMassiveKilling #CeasefireNOW