Question: Does Emacs have a canonical equivalent of Vim's Folding with Foldmethod=indent?
问题:Emacs是否具有规范等效于Vim的Folding with Foldmethod = indent?
I am particularly interested in something that can work alongside any Emacs major mode and any file. The Emacs searches have not turned up a definitive answer.
我对能够与任何Emacs主模式和任何文件一起工作的东西特别感兴趣。 Emacs搜索没有找到确定的答案。
3 个解决方案
#1
Seems like it can, though I don't use folding myself, so I've not tried it. Not surprisingly, the Python folks are all about this feature. See the following:
似乎它可以,虽然我不使用折叠自己,所以我没有尝试过。毫不奇怪,Python人员都是关于这个功能的。请参阅以下内容:
#2
maybe selective-display? I have the following function bound to [f2]
也许选择性显示?我有以下函数绑定到[f2]
;; http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
(defun jao-toggle-selective-display (column)
(interactive "P")
(set-selective-display
(if selective-display nil (or column 1))))
That's pretty bare-bones, though, and you'd really want it to be Pythony-indentation sensitive....
不过,这是非常简单的,你真的希望它是Pythony-indentation敏感的....
UPDATE: I was staring at this last night, and realized that I was tired of C-u entering the column I was on (plus 1).... so I coded it up:
更新:我昨晚盯着这个,并意识到我已经厌倦了C-u进入我所在的列(加1)....所以我把它编码了:
(defun toggle-selective-display-column ()
"set selective display fold everything greater than the current column, or toggle off if active"
(interactive)
(set-selective-display
(if selective-display nil (or (+ (current-column) 1) 1))))
Further elaboration should combine the two functions.
进一步的阐述应该结合这两个功能。
See also: How to achieve code folding effects in emacs
另请参阅:如何在emacs中实现代码折叠效果
#3
I tried all of the suggestions by Joe Casadonte and Michael Paulukonis, but none works as nicely as the vim's one. So it seems that the more accurate answer to the OP's question may be NO at the moment.
我尝试了Joe Casadonte和Michael Paulukonis的所有建议,但没有一个像vim那样好。因此,似乎对OP问题的更准确答案目前可能是否定的。
#1
Seems like it can, though I don't use folding myself, so I've not tried it. Not surprisingly, the Python folks are all about this feature. See the following:
似乎它可以,虽然我不使用折叠自己,所以我没有尝试过。毫不奇怪,Python人员都是关于这个功能的。请参阅以下内容:
#2
maybe selective-display? I have the following function bound to [f2]
也许选择性显示?我有以下函数绑定到[f2]
;; http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
(defun jao-toggle-selective-display (column)
(interactive "P")
(set-selective-display
(if selective-display nil (or column 1))))
That's pretty bare-bones, though, and you'd really want it to be Pythony-indentation sensitive....
不过,这是非常简单的,你真的希望它是Pythony-indentation敏感的....
UPDATE: I was staring at this last night, and realized that I was tired of C-u entering the column I was on (plus 1).... so I coded it up:
更新:我昨晚盯着这个,并意识到我已经厌倦了C-u进入我所在的列(加1)....所以我把它编码了:
(defun toggle-selective-display-column ()
"set selective display fold everything greater than the current column, or toggle off if active"
(interactive)
(set-selective-display
(if selective-display nil (or (+ (current-column) 1) 1))))
Further elaboration should combine the two functions.
进一步的阐述应该结合这两个功能。
See also: How to achieve code folding effects in emacs
另请参阅:如何在emacs中实现代码折叠效果
#3
I tried all of the suggestions by Joe Casadonte and Michael Paulukonis, but none works as nicely as the vim's one. So it seems that the more accurate answer to the OP's question may be NO at the moment.
我尝试了Joe Casadonte和Michael Paulukonis的所有建议,但没有一个像vim那样好。因此,似乎对OP问题的更准确答案目前可能是否定的。