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

Need a way to toggle through buffers #16

Open
blakemcbride opened this issue Jun 21, 2023 · 3 comments
Open

Need a way to toggle through buffers #16

blakemcbride opened this issue Jun 21, 2023 · 3 comments
Assignees

Comments

@blakemcbride
Copy link

Getting a list of buffers and being able to go to a specific buffer is good.
However, being able to do the following would be good too:

  1. go to next buffer in buffer ring
  2. go to previous buffer in buffer ring
  3. go to previus buffer I visited (and bufer that, etc.)
  4. go to following buffer I was at (works only if you used go to previous buffer I was at)

Thanks!

@blakemcbride blakemcbride changed the title Need a way to toggle throu buffers Need a way to toggle through buffers Jun 21, 2023
@rhaberkorn
Copy link
Owner

rhaberkorn commented Jun 21, 2023

  1. Try %*$. Q-Register * symbolizes the current buffer. The numeric part is the id and the string part is the name of the current buffer.
  2. Try -%*$.
  3. This is not supported out of the box, but could totally be done in a macro in combination with ED hooks. The ED hook in its "add" and "edit" clauses would call into a special macro that stores the current buffer (* register) into an array (the Q-Register namespace can be abused for that). You could call a macro like M< or perhaps -M[buffer.history] or whatever to go to the previous buffer, changing a pointer into the buffer history array.
  4. See above.

Actually, it probably makes sense to have this coded in TECO itself rather than a feature of the core language. If done so, it could ship by default in the "standard library" of SciTECO macros.

@rhaberkorn rhaberkorn self-assigned this Jun 21, 2023
@rhaberkorn
Copy link
Owner

In case, you just want to take a look into some file and go back to your previous buffer, it's also sufficient to just rubout the entire EB using Ctrl+W. But often, you do want to make some change and go back. In this case, I currently usually just type the file name again (with the help of autocompletion). This is usually very fast as I keep the working directory pointed to the main source directory.

@rhaberkorn
Copy link
Owner

rhaberkorn commented Jun 28, 2023

There is also the idiom [*EBsome_file$ and ]* to go the previous buffer. But

  1. you don't want to remember pushing the * register before EB.
  2. ]* restores the buffer by Id. So if the order of buffers changes or a buffer is closed, this may not do what you expect.
  3. There is no way to go "forward" again.

The idiom is mainly useful in scripts where you know that the order of buffers does not get mixed up. Especially, when using EQq$ ([* EQq$ !...! ]* - to edit Q-Reg q temporarily before switching back to the last regular buffer).

@blakemcbride Could you elaborate on how a buffer history feature should behave? What to do for instance when a buffer is closed? Supposing that M< goes to the previous buffer.
What should be the state after EBbar$ EBfoo$ EF M<? Do you expect foo to be removed from the history, so M< opens bar (at least if that is not the current buffer after EF); or should M< re-open foo?
Are there any editors that implemented this feature?

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

No branches or pull requests

2 participants