How to use “hide-region” package in elisp

雨燕双飞 提交于 2019-12-13 07:39:08

问题


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.



来源:https://stackoverflow.com/questions/12258334/how-to-use-hide-region-package-in-elisp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!