Emacs, how to show only lines on or before the cursor in a file

I am a computer science teacher in high school and would like to use emacs to introduce programs to my students. I would like to be able to represent programs, even short ones, one line at a time, and from the very beginning not to show the entire program in the emacs buffer.

Thus, I would like emacs to hide all lines below the current line and expand each line when I move the cursor down to that line.

+4
source share
2 answers

Inspired by your question, I added a library reveal-next.elto the EmacsWiki . I think he does what you want.

+2
source

:

(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)

. . http://www.gnu.org/software/emacs/manual/html_node/emacs/Narrowing.html

+5

Source: https://habr.com/ru/post/1540696/


All Articles