Hide lines by regex












1















I am reading detailed line oriented log file (100MB).



I want to skip some parts by using regex.



Usually I M-x flush-lines but this is destructive operation.



I want to hide many lines by regex and expect it would be efficient when I navigate across file. Extra plus if interactive search skips hidden parts.



From the comments on yue's answer:




  • I want incremental exclusion (first regex, then next regex).


  • I search for anomalies in log and know what to exclude but I don't know what I will have found.











share|improve this question




















  • 1





    Why don't you like flush-lines? With a tiny trick you can clone the file buffer into one that does not visit any file and flush lines there. (1) Do you want a list of flushes you have performed to roll back? (2) Do you want to edit the log file (maybe inserting some kind of markers) and keep these edits in hidden regions? Please, expand your question in that regard.

    – Tobias
    29 mins ago













  • @Tobias It is exploration of log for some issues and it can be possible that I applied flush-lines too aggressively and losing problem. Probably should work on file copy...

    – gavenkoa
    24 mins ago











  • I.e. you want to be able to roll-back flush-lines commands in an undo-tree fashion maybe including the undo-tree-visualizer-toggle-diff feature. It would be even nicer to see the flushed regexps aside the undo tree nodes. Something like that? You can use all that on a buffer clone as I stated in my first comment.

    – Tobias
    14 mins ago













  • The mentioned strategy is even reasonably fast with large text files (just tried it with 40MB).

    – Tobias
    8 mins ago
















1















I am reading detailed line oriented log file (100MB).



I want to skip some parts by using regex.



Usually I M-x flush-lines but this is destructive operation.



I want to hide many lines by regex and expect it would be efficient when I navigate across file. Extra plus if interactive search skips hidden parts.



From the comments on yue's answer:




  • I want incremental exclusion (first regex, then next regex).


  • I search for anomalies in log and know what to exclude but I don't know what I will have found.











share|improve this question




















  • 1





    Why don't you like flush-lines? With a tiny trick you can clone the file buffer into one that does not visit any file and flush lines there. (1) Do you want a list of flushes you have performed to roll back? (2) Do you want to edit the log file (maybe inserting some kind of markers) and keep these edits in hidden regions? Please, expand your question in that regard.

    – Tobias
    29 mins ago













  • @Tobias It is exploration of log for some issues and it can be possible that I applied flush-lines too aggressively and losing problem. Probably should work on file copy...

    – gavenkoa
    24 mins ago











  • I.e. you want to be able to roll-back flush-lines commands in an undo-tree fashion maybe including the undo-tree-visualizer-toggle-diff feature. It would be even nicer to see the flushed regexps aside the undo tree nodes. Something like that? You can use all that on a buffer clone as I stated in my first comment.

    – Tobias
    14 mins ago













  • The mentioned strategy is even reasonably fast with large text files (just tried it with 40MB).

    – Tobias
    8 mins ago














1












1








1








I am reading detailed line oriented log file (100MB).



I want to skip some parts by using regex.



Usually I M-x flush-lines but this is destructive operation.



I want to hide many lines by regex and expect it would be efficient when I navigate across file. Extra plus if interactive search skips hidden parts.



From the comments on yue's answer:




  • I want incremental exclusion (first regex, then next regex).


  • I search for anomalies in log and know what to exclude but I don't know what I will have found.











share|improve this question
















I am reading detailed line oriented log file (100MB).



I want to skip some parts by using regex.



Usually I M-x flush-lines but this is destructive operation.



I want to hide many lines by regex and expect it would be efficient when I navigate across file. Extra plus if interactive search skips hidden parts.



From the comments on yue's answer:




  • I want incremental exclusion (first regex, then next regex).


  • I search for anomalies in log and know what to exclude but I don't know what I will have found.








hideshow






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 37 mins ago







gavenkoa

















asked 2 hours ago









gavenkoagavenkoa

1,320819




1,320819








  • 1





    Why don't you like flush-lines? With a tiny trick you can clone the file buffer into one that does not visit any file and flush lines there. (1) Do you want a list of flushes you have performed to roll back? (2) Do you want to edit the log file (maybe inserting some kind of markers) and keep these edits in hidden regions? Please, expand your question in that regard.

    – Tobias
    29 mins ago













  • @Tobias It is exploration of log for some issues and it can be possible that I applied flush-lines too aggressively and losing problem. Probably should work on file copy...

    – gavenkoa
    24 mins ago











  • I.e. you want to be able to roll-back flush-lines commands in an undo-tree fashion maybe including the undo-tree-visualizer-toggle-diff feature. It would be even nicer to see the flushed regexps aside the undo tree nodes. Something like that? You can use all that on a buffer clone as I stated in my first comment.

    – Tobias
    14 mins ago













  • The mentioned strategy is even reasonably fast with large text files (just tried it with 40MB).

    – Tobias
    8 mins ago














  • 1





    Why don't you like flush-lines? With a tiny trick you can clone the file buffer into one that does not visit any file and flush lines there. (1) Do you want a list of flushes you have performed to roll back? (2) Do you want to edit the log file (maybe inserting some kind of markers) and keep these edits in hidden regions? Please, expand your question in that regard.

    – Tobias
    29 mins ago













  • @Tobias It is exploration of log for some issues and it can be possible that I applied flush-lines too aggressively and losing problem. Probably should work on file copy...

    – gavenkoa
    24 mins ago











  • I.e. you want to be able to roll-back flush-lines commands in an undo-tree fashion maybe including the undo-tree-visualizer-toggle-diff feature. It would be even nicer to see the flushed regexps aside the undo tree nodes. Something like that? You can use all that on a buffer clone as I stated in my first comment.

    – Tobias
    14 mins ago













  • The mentioned strategy is even reasonably fast with large text files (just tried it with 40MB).

    – Tobias
    8 mins ago








1




1





Why don't you like flush-lines? With a tiny trick you can clone the file buffer into one that does not visit any file and flush lines there. (1) Do you want a list of flushes you have performed to roll back? (2) Do you want to edit the log file (maybe inserting some kind of markers) and keep these edits in hidden regions? Please, expand your question in that regard.

– Tobias
29 mins ago







Why don't you like flush-lines? With a tiny trick you can clone the file buffer into one that does not visit any file and flush lines there. (1) Do you want a list of flushes you have performed to roll back? (2) Do you want to edit the log file (maybe inserting some kind of markers) and keep these edits in hidden regions? Please, expand your question in that regard.

– Tobias
29 mins ago















@Tobias It is exploration of log for some issues and it can be possible that I applied flush-lines too aggressively and losing problem. Probably should work on file copy...

– gavenkoa
24 mins ago





@Tobias It is exploration of log for some issues and it can be possible that I applied flush-lines too aggressively and losing problem. Probably should work on file copy...

– gavenkoa
24 mins ago













I.e. you want to be able to roll-back flush-lines commands in an undo-tree fashion maybe including the undo-tree-visualizer-toggle-diff feature. It would be even nicer to see the flushed regexps aside the undo tree nodes. Something like that? You can use all that on a buffer clone as I stated in my first comment.

– Tobias
14 mins ago







I.e. you want to be able to roll-back flush-lines commands in an undo-tree fashion maybe including the undo-tree-visualizer-toggle-diff feature. It would be even nicer to see the flushed regexps aside the undo tree nodes. Something like that? You can use all that on a buffer clone as I stated in my first comment.

– Tobias
14 mins ago















The mentioned strategy is even reasonably fast with large text files (just tried it with 40MB).

– Tobias
8 mins ago





The mentioned strategy is even reasonably fast with large text files (just tried it with 40MB).

– Tobias
8 mins ago










1 Answer
1






active

oldest

votes


















2














You want to use occur. This feature is built-in and it does exactly what you want.



There is also a package called loccur, which does the same, but does not create a new window (it just hides all non matching lines).






share|improve this answer
























  • I want incremental exclusion (first regex, then next regex). occur has positive logic instead of negative and I can't apply exclusion sequentially...

    – gavenkoa
    1 hour ago











  • I search for anomalies in log and know what to exclude.

    – gavenkoa
    1 hour ago












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "583"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f50233%2fhide-lines-by-regex%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














You want to use occur. This feature is built-in and it does exactly what you want.



There is also a package called loccur, which does the same, but does not create a new window (it just hides all non matching lines).






share|improve this answer
























  • I want incremental exclusion (first regex, then next regex). occur has positive logic instead of negative and I can't apply exclusion sequentially...

    – gavenkoa
    1 hour ago











  • I search for anomalies in log and know what to exclude.

    – gavenkoa
    1 hour ago
















2














You want to use occur. This feature is built-in and it does exactly what you want.



There is also a package called loccur, which does the same, but does not create a new window (it just hides all non matching lines).






share|improve this answer
























  • I want incremental exclusion (first regex, then next regex). occur has positive logic instead of negative and I can't apply exclusion sequentially...

    – gavenkoa
    1 hour ago











  • I search for anomalies in log and know what to exclude.

    – gavenkoa
    1 hour ago














2












2








2







You want to use occur. This feature is built-in and it does exactly what you want.



There is also a package called loccur, which does the same, but does not create a new window (it just hides all non matching lines).






share|improve this answer













You want to use occur. This feature is built-in and it does exactly what you want.



There is also a package called loccur, which does the same, but does not create a new window (it just hides all non matching lines).







share|improve this answer












share|improve this answer



share|improve this answer










answered 1 hour ago









juejue

1,703112




1,703112













  • I want incremental exclusion (first regex, then next regex). occur has positive logic instead of negative and I can't apply exclusion sequentially...

    – gavenkoa
    1 hour ago











  • I search for anomalies in log and know what to exclude.

    – gavenkoa
    1 hour ago



















  • I want incremental exclusion (first regex, then next regex). occur has positive logic instead of negative and I can't apply exclusion sequentially...

    – gavenkoa
    1 hour ago











  • I search for anomalies in log and know what to exclude.

    – gavenkoa
    1 hour ago

















I want incremental exclusion (first regex, then next regex). occur has positive logic instead of negative and I can't apply exclusion sequentially...

– gavenkoa
1 hour ago





I want incremental exclusion (first regex, then next regex). occur has positive logic instead of negative and I can't apply exclusion sequentially...

– gavenkoa
1 hour ago













I search for anomalies in log and know what to exclude.

– gavenkoa
1 hour ago





I search for anomalies in log and know what to exclude.

– gavenkoa
1 hour ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Emacs Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f50233%2fhide-lines-by-regex%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

GameSpot

connect to host localhost port 22: Connection refused

Getting a Wifi WPA2 wifi connection