Skip to content

Instantly share code, notes, and snippets.

@gongzhitaao
Last active November 30, 2022 07:59
Show Gist options
  • Save gongzhitaao/8030400 to your computer and use it in GitHub Desktop.
Save gongzhitaao/8030400 to your computer and use it in GitHub Desktop.
hideshow config for emacs
(defface collapsed-face '((t (:background "#e0cf9f" :foreground "#5f5f5f"))) "Collapsed Overlay")
(defvar collapsed-face 'collapsed-face)
(define-fringe-bitmap 'hs-marker [0 24 24 126 126 24 24 0])
(defun display-code-line-counts (ov)
(when (eq 'code (overlay-get ov 'hs))
(let* ((marker-string "*fringe-dummy*")
(marker-length (length marker-string))
(display-string
(format " (%d)... "
(count-lines (overlay-start ov) (overlay-end ov)))))
(overlay-put ov 'help-echo "C-` to toggle")
(put-text-property 0 marker-length 'display
(list 'left-fringe 'hs-marker 'fringe-face)
marker-string)
(overlay-put ov 'before-string marker-string)
(put-text-property 1 (1- (length display-string))
'face 'collapsed-face display-string)
(overlay-put ov 'display display-string))))
(setq hs-set-up-overlay 'display-code-line-counts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment