Emacs如何仅显示文件中光标上或之前的行

rai*_*rpm 4 emacs code-folding

我是一名高中计算机科学老师,我想用emacs向我的学生介绍课程.我希望能够一次一行地呈现程序,甚至是短程序,而不是从一开始就在emacs缓冲区中显示整个程序.

因此,我希望emacs隐藏当前行下面的所有行,并在我将光标向下移动到该行时显示每一行.

art*_*can 5

试试这个:

(defun narrow-next-line ()
  (interactive)
  (widen)
  (call-interactively 'move-end-of-line)
  (forward-char)
  (call-interactively 'move-end-of-line)
  (narrow-to-region 1 (point)))

(global-set-key (kbd "C-x n i") 'narrow-next-line)
Run Code Online (Sandbox Code Playgroud)

为此命令选择您自己的热键.另见http://www.gnu.org/software/emacs/manual/html_node/emacs/Narrowing.html


Dre*_*rew 3

受到你的问题的启发,我reveal-next.elEmacsWiki添加了库。我认为它可以满足你的要求。