6
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)
(interactive
(if (region-active-p)
(list (region-beginning) (region-end))
(list (point-min) (point-max))))
(save-excursion
(goto-char beg)
(while (re-search-forward "<\\w+:\\/\\/\\(:?[^&...
5
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
and Isearch+.
For example, you can use C-...
4
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'."
(...
2
M-x what-line gives both the relative line number and the narrow buffer number in the mini buffer echo area, for example:
M-x what-line
line 189 (narrowed line 1)
2
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 ...
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).
1
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."
(...
1
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-...
1
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 ...
comment hideshow
1
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:
(add-hook 'mine-...
1
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 ...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
hideshow × 21code-folding × 5
org-mode × 2
python × 1
fonts × 1
major-mode × 1
html × 1
highlighting × 1
comment × 1
performance × 1
line-numbers × 1
linum-mode × 1
clojure × 1
perl × 1
sexp × 1
outline × 1
notmuch × 1
interactive-development × 1