Comments (2)
If I understand you, you've made it so that find arbitrary_string
in a macro doesn't update cur_buffer->find_string
like it would if you did the same command on the command line.
I can see how it may seem useful. It would avoid the situation where a macro has the unintended side effect of changing cur_buffer->find_string
.
However, it also changes the RepeatLast
command's behavior, breaking it entirely when playing back a recorded macro containing a Find
command and a subsequent RepeatLast
command.
We already have a mechanism to avoid side effects from macros. See PushPrefs
and PopPrefs
. I think it's reasonable to consider whether to extend the function of PushPrefs
and PopPrefs
to include saving and restoring the current buffer's find_string
, last_was_replace
, and last_was_regexp
. Then you could craft your macros to avoid the issue while preserving the ability to use — and without breaking the semantics of — RepeatLast
.
This is an interesting idea. Thanks for the suggestion.
from ne.
Sorry I didn't share the diff earlier:
diff --git a/src/command.c b/src/command.c
index a00d87b..7eed69b 100644
--- a/src/command.c
+++ b/src/command.c
@@ -503,6 +503,8 @@ void optimize_macro(char_stream *cs, bool verbose) {
int play_macro(char_stream *cs, int64_t c) {
if (!cs) return ERROR;
+ char *find_string = str_dup(cur_buffer->find_string);
+
/* If len is 0 or 1, the character stream does not contain anything. */
const int64_t len = cs->len;
if (len < 2 || c < 1) return OK;
@@ -547,6 +549,8 @@ int play_macro(char_stream *cs, int64_t c) {
free(stream);
if (--call_depth == 0) executing_macro = false;
+ cur_buffer->find_string = str_dup(find_string);
+
return stop ? STOPPED : error;
}
I had not checked what would happen if a macro contains a call to RepeatLast
, but I've just tried it and it seems to work fine. I agree that it would be more elegant to extend PushPrefs
and PopPrefs
. Also, even if you guessed my intentions correctly, I didn't share my motivation: I have some macros that use Find
/FindRegExp
and I did not like to lose the value of find_string
after running them.
from ne.
Related Issues (20)
- Feature Request: Bracketed Paste Mode HOT 13
- [Question] Contribution Guidelines
- [Bug Report] Configured Coding Languages are not Highlighted HOT 2
- [Feature Request] copy current line HOT 3
- Avoid FTBFS when using binutils-gold HOT 1
- build fails in archlinux HOT 8
- copy-paste doesn't work well HOT 1
- yaml syntax highlighting of single-quoted strings incorrect HOT 2
- curses.h HOT 2
- compile ne for RiskV64 HOT 3
- Memory leak after opening file from file browser HOT 4
- [Feature Request] Soft wrapping Flag. HOT 1
- Single ESC breaks ne HOT 10
- Table of contents at the end? HOT 5
- [Feature Request] a way to move cursor to end of paste HOT 6
- "0x" prefix "tolerated" in ~/.ne/.keys file HOT 5
- autocomplete (or tab complete) macro names?
- truncation warning HOT 1
- Empty initializer list HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ne.