help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Code folding in Emacs.


From: Hongyi Zhao
Subject: Code folding in Emacs.
Date: Sun, 10 Oct 2021 16:16:21 +0800

I just found the following code snippet from here [1] for code folding in Emacs:


(global-set-key (kbd "<C-f5>") 'set-selective-display-dlw)

(defun set-selective-display-dlw (&optional level)
  "Fold text indented same of more than the cursor.
If level is set, set the indent level to LEVEL.
If 'selective-display' is already set to LEVEL, clicking
F5 again will unset 'selective-display' by setting it to 0."
  (interactive "P")
  (if (eq selective-display (1+ (current-column)))
      (set-selective-display 0)
    (set-selective-display (or level (1+ (current-column))))))

The above code trick seems very simple, but it works for many
languages. So I recommend it here.

[1] https://discourse.julialang.org/t/code-folding-for-emacs/41421/3

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



reply via email to

[Prev in Thread] Current Thread [Next in Thread]