Skip to content
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

Structural regular expression support #219

Closed
TieDyedDevil opened this issue Apr 4, 2016 · 4 comments
Closed

Structural regular expression support #219

TieDyedDevil opened this issue Apr 4, 2016 · 4 comments

Comments

@TieDyedDevil
Copy link
Contributor

The sam command:

:2,3

should select lines 2 and 3.

Instead, only line 2 is selected.

@martanne
Copy link
Owner

martanne commented Apr 4, 2016

Thanks for giving it a try! This particular bug should be fixed. I will leave the issue open for other structural regular expression related bugs (the x and y commands seem to not always work correctly).

More bug reports welcome ...

@martanne martanne changed the title sam - line range selection is off-by-one Structural regular expression support Apr 4, 2016
@martanne
Copy link
Owner

Ok some more comments / issues related to the sam integration:

  • commands do generally not set the new dot, instead the editor returns to normal mode thus clearing any selections
  • I/O related commands do not integrate properly with the undo/redo mechanism
  • s (substitute) command should probably be implemented as an internal command instead of with sed(1). It should support a count as in s2/abc/def/ the following should also work: s/(argA), (argB)/\2, \1/
  • multiple file support i.e. X and Y commands are currently broken?
  • arbitrary text should be executable like in acme
  • there should be a way to easily enter multi line commands (currently <Ctrl-v><Enter> in the command window followed by selecting the lines with V visual line mode must be used)
  • there should be a way to keep the command window open

@martanne
Copy link
Owner

The last few commits should have improved structural regex support:

  • sam's grouping semantic is now implemented, hence it is for example possible to swap words with:
,x/[a-zA-Z]+/{
      g/Emacs/ v/....../ c/vi/
      g/vi/ v/.../ c/Emacs/
}
  • The x and y looping commands now set the registers "& and "1-"9 with (sub-)expression matches which can be referred to in texts using & and \1-\9 respectively. As a consequence the substitute command was dropped, it can almost completely be replaced by: x/pattern/ c/replacement.

    The count specifier supported by sam was never implemented in vis. Eventually I would like to generalize the concept and apply it to all looping constructs either by modifying the syntax of x/y or g/v commands.

  • If commands are issued from within visual mode new selections are created for every modification (akin to the dot setting in sam).

  • It should be easier to enter multi line commands in the prompt. Suggestions to improve this further are welcome.

Multiple file support is still largely untested:

  • The X and Y commands currently operate on windows, not files. Meaning that if a file is being displayed in multiple windows a given command will be executed once for every window. This is desired in certain cases (e.g. :X q to close all windows without unsaved changes) and unwanted in others (e.g. :X 0i,/* ISC licensed */\n to add a license template to the top of every file).
  • The whole undo concept is file specific, the above insertion command can not easily be undone. Implementing an u command would at least give the possibility to :X u undo all changes.
  • vis does currently not allow to switch windows while in visual mode. Should there be per-window modes?
  • How should this all work with an eventual client/server architecture Integrate with external window manager #130?

It would be nice to get some feedback about the current state of affairs from users familiar with sam/acme or more generally structural regexp.

I'm tagging a few people who reported issues in the past and/or engaged in related discussion on IRC @Screwtapello, @halfwit, @mbucc.

@martanne
Copy link
Owner

martanne commented Feb 4, 2020

I'm closing this because the basic functionality (including the issue initially reported here) seems to work fine. The limitations regarding multiple file support mentioned in my last comment are still true. The wiki lists some differences in syntax and behavior compared to sam.

I'm still very much interested in feedback, ideas and individual bug reports regarding the structural regex support. A somewhat recent example of that was #774.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants