how to use fold(or hideshow) in emacs python-mode

Discussion in 'Python' started by Li Daobing, Oct 12, 2004.

  1. Li Daobing

    Li Daobing Guest

    Hello,
    I want to use fold-mode or hideshow mode under emacs, but it doesn't
    work.
    Cound you tell me how to do this?
    Thank you.

    Li Daobing
    Li Daobing, Oct 12, 2004
    #1
    1. Advertising

  2. "Li Daobing" <> writes:

    > Hello,
    > I want to use fold-mode or hideshow mode under emacs, but it doesn't
    > work.
    > Cound you tell me how to do this?
    > Thank you.


    You can try this. I use something similar and it works quite well.

    --8<--------------------------------------------------------------------

    (add-hook 'python-mode-hook 'my-python-hook)

    (defun py-outline-level ()
    "This is so that `current-column` DTRT in otherwise-hidden text"
    ;; from ada-mode.el
    (let (buffer-invisibility-spec)
    (save-excursion
    (skip-chars-forward "\t ")
    (current-column))))

    ; this fragment originally came from the web somewhere, but the outline-regexp
    ; was horribly broken and is broken in all instances of this code floating
    ; around. Finally fixed by Charl P. Botha <<a href="http://cpbotha.net/">http://cpbotha.net/</a>>
    (defun my-python-hook ()
    (setq outline-regexp "[^ \t\n]\\|[ \t]*\\(def[ \t]+\\|class[ \t]+\\)")
    ; enable our level computation
    (setq outline-level 'py-outline-level)
    ; do not use their \C-c@ prefix, too hard to type. Note this overides
    ;some python mode bindings
    (setq outline-minor-mode-prefix "\C-c")
    ; turn on outline mode
    (outline-minor-mode t)
    ; initially hide all but the headers
    (hide-body)
    (show-paren-mode 1)
    )

    --8<--------------------------------------------------------------------

    This code was found here -> http://tinyurl.com/7yyqv

    Cheers, Sean

    --
    "Hver sin smak", sa vintapperen, han drakk mens de andre sloss.
    Sean Richards, Oct 13, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kj
    Replies:
    7
    Views:
    666
    Teemu Likonen
    Jul 17, 2010
  2. Lars Bungum
    Replies:
    0
    Views:
    251
    Lars Bungum
    Jun 16, 2011
  3. Jeffrey Moss

    eruby mode emacs with mmm-mode

    Jeffrey Moss, Jul 6, 2005, in forum: Ruby
    Replies:
    1
    Views:
    138
    Alan Chen
    Jul 6, 2005
  4. PerlFAQ Server
    Replies:
    1
    Views:
    184
    Marc Girod
    Jan 8, 2011
  5. Van Duijn

    Fold out menu to use with frames

    Van Duijn, Feb 4, 2005, in forum: Javascript
    Replies:
    0
    Views:
    114
    Van Duijn
    Feb 4, 2005
Loading...

Share This Page