>>>>> "Grant" == Grant Edwards <[EMAIL PROTECTED]> writes:
Grant> Has anybody figured out how to do code folding of Python source
Grant> files in emacs?

I use outline-minor-mode with the following home baked configuration:

;; Python stuff for outline mode.
(defvar py-outline-regexp "^\\([ 
\t]*\\)\\(def\\|class\\|if\\|elif\\|else\\|while\\|for\\|try\\|except\\|with\\)"
  "This variable defines what constitutes a 'headline' to outline mode.")

(defun py-outline-level ()
  "Report outline level for Python outlining."
  (save-excursion
    (end-of-line)
    (let ((indentation (progn
                         (re-search-backward py-outline-regexp)
                         (match-string-no-properties 1))))
      (if (and (> (length indentation) 0)
               (string= "\t" (substring indentation 0 1)))
          (length indentation)
        (/ (length indentation) py-indent-offset)))))
(add-hook 'python-mode-hook
          '(lambda ()
             (outline-minor-mode 1)
             (setq
              outline-regexp py-outline-regexp
              outline-level 'py-outline-level)))


Martin
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to