-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could commands and environments be made text objects? #244
Comments
Environments are also text objects, so
|
Ah right, sorry about the environments. Your approach to multi-argument commands sounds like the right solution to me. I guess |
Hmm. \includegraphics[width=\textwidth]{my_fig.png} What do we expect if we do \includegraphics We have to have a very clear definition of the text object. It is difficult, because we don't know how many arguments a command takes. I think we have to make an assumption that a command looks like this: \command[optarg]{arg1}{arg2}...{argn} Where the arguments follow directly, with no spaces in between. The |
Just to add a bit of brainstorming... arguments can be quite complex --- especially with the new LaTeX3 syntax; but even without this, there is the case of, for example
(even with unmatched braces) or
... I think it would be difficult just to safely identify which command is applied to the argument the cursor is on... ;-) |
Yes. I think it is very difficult to parse the command. However, I see it might be relatively useful to have such a text object, even if it only works for "simple" commands. That is, I propose to add a simple text object for commands of the form \command[...]{arg}
% --- ic
%------------------ ac For commands with no argument, I propose that This will work for many or perhaps even most cases, although not all. I.e., the text object will not work for:
|
In general, there is no way to determine how many arguments a command has, and it just doesn’t fit TeX’s execution model. But here is an alternative: Maybe a notion of tokens would be useful. So that if if I have
and my cursor is on An |
Hi @nomeata, sorry for taking so long to come back to you on this! I like your idea. I think you are right that the "command text object" does not really fit TeX's execution model. Just to be clear: You mean that in How aboue the command text object, do you guys agree with my proposal for a "simple" version? I think it would work for many/most commands, but obviously not all. It seems to me a pragmatic solution. |
Correct. I would guess, though, the other form ( |
Ok, I've started to think about this again now. I want to implement parsing of commands that work like this:
This will match all of the following examples: \test [ ... ] { a } { b }
\test
[ asd ]
{ asd }
\test {a}
\test{b}
\emph{test} {\small ...} The last example implies that the matching will sometimes be erroneous. However, I think this is relatively rare, and that it can be considered an acceptable fault. With this, I can define the command text object and command mappings accordingly. What do you guys think? |
I think it could be nice. Especially to change command (like a |
I've added text objects Curious: |
I think the updates solves this issue. Feel free to reopen. |
If commands and environments were text objects, we could still have
dsc/dse
andcsc/cse
, but would also be able to dodie/dae/dic/dac
and likewise for changes.Would this conflict with anything?
The text was updated successfully, but these errors were encountered: