There is this well-known package hide-region Link to the package (hide-region.el) I want to apply hide-region-hide from a certain "point a" to "point b" [a region] in my file. How can I do this? What I need to define? It works when I highlight manually some text, but I need to do it in my code and give it the beg. of a region and end of region and apply it to the resulted region.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The package is somewhat poorly written, and does not allow you to pass it a region as arguments to the function. You can probably work around this by something like
(save-excursion
(let (deactivate-mark) ; see save-excursion docs for why
(set-mark point-a) ; beginning of region you want to hide
(goto-char point-b) ; end of region you want to hide
(hide-region-hide) ) )
It would be better if hide-region-hide
took the region as arguments when called noninteractively, though. Perhaps the maintainer would be happy to accept a patch for this. See also the documentation for set-mark
which specifically advises against using it like I have done above. Furthermore, perhaps you also want to look at the documentation for save-excursion
.