随时随地折叠你的代码吧。。。

这是应kenneth要求写的一个折叠代码emacs小工具:

 

(defun fold-this-sexp () "把当前位置的括号内容折叠起来,展开的话...wait" (interactive) (save-excursion (let ((ov (make-overlay (point) (progn (forward-list) (point))))) (overlay-put ov 'display "<....>") (overlay-put ov 'name "jrfold")))) (defun unfold-this-sexp () "括号内容折叠展开" (interactive) (save-excursion (remove-overlays (point) (progn (forward-list) (point))))) ; 'display "<....>") (defun sexp-code-folding-dwim () "在括号处交替折叠" (interactive) (save-excursion (let* ((ovs-1 (save-excursion (overlays-in (point) (progn (forward-list) (point))))) (ovs (remove-if-not #'(lambda (x) (equal (overlay-get x 'name) "jrfold")) ovs-1))) (if (null ovs) (fold-this-sexp) (unfold-this-sexp))))) (global-set-key "/C-c/C-f" 'sexp-code-folding-dwim)

你可能感兴趣的:(null,lambda,工具,emacs)