Skip to content

Instantly share code, notes, and snippets.

@vv111y
Last active February 21, 2020 14:47
Show Gist options
  • Save vv111y/db91372b34b99d317228a78082d49625 to your computer and use it in GitHub Desktop.
Save vv111y/db91372b34b99d317228a78082d49625 to your computer and use it in GitHub Desktop.
;; outline-minor-mode needs to be enabled for this to work.
(setq py-docstring-regexp "\"\"\"")
(defvar py-docstrings-folded nil)
(defun py-toggle-docstrings ()
(interactive)
(if py-docstrings-folded
(setq py-docstrings-folded nil)
(setq py-docstrings-folded t))
(save-excursion
(goto-char (point-min))
(let ((start) (end))
(while (and
(setq start (re-search-forward py-docstring-regexp nil t))
(setq end (re-search-forward py-docstring-regexp nil t)))
(outline-flag-region start end py-docstrings-folded)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment