Make isearch reveal folds

This commit is contained in:
Greg Sexton 2014-11-22 10:26:26 +00:00
parent 7e878a2251
commit 1cc58ab689

View File

@ -41,20 +41,34 @@
(defun origami-create-overlay (beg end offset buffer) (defun origami-create-overlay (beg end offset buffer)
(when (> (- end beg) 0) (when (> (- end beg) 0)
(make-overlay (+ beg offset) end buffer))) (let ((ov (make-overlay (+ beg offset) end buffer)))
(overlay-put ov 'isearch-open-invisible 'origami-isearch-show)
(overlay-put ov 'isearch-open-invisible-temporary
(lambda (ov hide-p) (if hide-p (origami-hide-overlay ov)
(origami-show-overlay ov))))
ov)))
(defun origami-hide-node-overlay (node) (defun origami-hide-overlay (ov)
(-when-let (ov (origami-fold-data node))
;; TODO: make all of this customizable ;; TODO: make all of this customizable
(overlay-put ov 'invisible 'origami) (overlay-put ov 'invisible 'origami)
(overlay-put ov 'display "...") (overlay-put ov 'display "...")
(overlay-put ov 'face 'font-lock-comment-delimiter-face))) (overlay-put ov 'face 'font-lock-comment-delimiter-face))
(defun origami-show-overlay (ov)
(overlay-put ov 'invisible nil)
(overlay-put ov 'display nil)
(overlay-put ov 'face nil))
(defun origami-hide-node-overlay (node)
(-when-let (ov (origami-fold-data node))
(origami-hide-overlay ov)))
(defun origami-show-node-overlay (node) (defun origami-show-node-overlay (node)
(-when-let (ov (origami-fold-data node)) (-when-let (ov (origami-fold-data node))
(overlay-put ov 'invisible nil) (origami-show-overlay ov)))
(overlay-put ov 'display nil)
(overlay-put ov 'face nil))) (defun origami-isearch-show (ov)
(origami-show-node (current-buffer) (point)))
(defun origami-hide-overlay-from-fold-tree-fn (node) (defun origami-hide-overlay-from-fold-tree-fn (node)
(origami-fold-postorder-each node 'origami-hide-node-overlay)) (origami-fold-postorder-each node 'origami-hide-node-overlay))