The URL parsing could probably be included, so take this just as an example, but the general idea is like this:
(defun my/minify-urls (beg end)
(list (region-beginning) (region-end))
(list (point-min) (point-max))))
(while (re-search-forward "<\\w+:\\/\\/\\(:?[^&...
I agree with comments that suggest using flush-lines. I would likely use that in this case, especially since your use case is line-oriented.
But if you want to make text that matches a regexp invisible, so that search, query-replace, etc. ignore it but it is still present, then you can do that with libraries Zones
For example, you can use C-...
hideshow uses overlays to hide text. Because of this you can make the semi-maybe-safe assumption that if the number of overlays in the current buffer doesn't increase after running hs-hide-all, then all top level blocks must have been already hidden.
(defun my-hs-toggle-all ()
"If anything isn't hidden, run `hs-hide-all', else run `hs-show-all'."
You did not implement alamo-forward-sexp correctly. If point is at begin_data almo-forward-sexp does not go to the block end, i.e., to the end of end_data but to the end of alamo-forward-sexp.
A fairly complete alamo-forward-sexp must treat nested sexps correctly. Something like that is most often done via a stack. Below I give a simple version of a stack ...
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).
I already filled a feature request for recognizing derived modes through hideshow.
Until this feature request is handled you can use the following workaround in your init file:
(defun my-sage-initialize-hs ()
"Initialize `hs-special-mode-alist' for `sage-shell:sage-mode'.
Note: Function `python-mode' must be run at least once to make this work."
In the text-mode buffer where your log is, set comment-start.
hideshow checks this and comment-end at the beginning of hs-grok-mode-type(). hs-grok-mode-type() says:
Set up hideshow variables for new buffers.
If `hs-special-modes-alist' has information associated with the
current buffer's major mode, use that.
Otherwise, guess start, end and `comment-...
This does not directly answer your question, but it might be an alternative to consider.
Library hide-comnt.el is designed to let you hide or ignore comments.
There are commands to hide, show, and toggle showing comments.
There is a macro, with-comments-hidden, that you can use to wrap code that you want to ignore text in comments.
You can set or bind ...
You can just set hs-hide-all-non-comment-function to #'ignore.
If you want to do that globally put the following in your init file:
(setq hs-hide-all-non-comment-function #'ignore)
If you want to do that only for certain major modes replace my-major-mode with the major mode of your choice and put the modified line in your init file:
The #[...] is byte code, which comes from byte-compiling the Lisp source code.
You need to use C-h f for the Python forward-sexp command, and then visit its Lisp definition (by clicking the file link) to see what it does.
If you don't know what the Python forward-sexp function is called, use C-h k C-M-f in Python mode. (That will also give you a link to ...