Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module: Modern code folding #240

Open
jorgenschaefer opened this issue Jun 1, 2014 · 9 comments
Open

Module: Modern code folding #240

jorgenschaefer opened this issue Jun 1, 2014 · 9 comments
Milestone

Comments

@jorgenschaefer
Copy link
Owner

Elpy should support code folding like current IDEs provide. That is, simple code folding commands for sensible blocks of Python code (indentation blocks?), with markers and interactable icons in the fringe.

  • hs-toggle-hiding should do most of that for us
  • Needs a good key shortcut
    • C-TAB maybe. Doesn't work in console. backtab there?
    • Or just TAB at the beginning of a line? Shouldn't be ambiguous.
    • Atom and Sublime Text use C-M-[ / C-M-], with shift for "everything". And people say Emacs has crazy key bindings.
      • With region, folds that region
      • Anywhere in a block of code, folds that block
  • Prefix argument should hide leaf nodes (or lines with "def" in them)
  • Visualization in the fringe is provided by http://www.emacswiki.org/emacs/hideshowvis.el but that's very limited, won't even auto-update
@jorgenschaefer jorgenschaefer added this to the v1.6 milestone Jun 1, 2014
@jorgenschaefer
Copy link
Owner Author

Some example of code folding: http://ace.c9.io/build/kitchen-sink.html

Note especially the options to mark begin only / begin end / etc. in the options. Not sure we need that, but at least the begin one would be nice.

@flub
Copy link

flub commented Jun 16, 2014

Docstring folding would be nice IMHO, something which is often overlooked as folding happens only on blocks usually.

@jorgenschaefer
Copy link
Owner Author

Great idea! One of my pet peeves with docstrings is indeed that they separate function heads from bodies, which is why I would prefer comments over docstrings. Folding would help a lot with that.

@jorgenschaefer jorgenschaefer modified the milestones: v1.6, Backlog Aug 23, 2014
@offby1
Copy link
Contributor

offby1 commented Oct 30, 2014

I'd probably use this feature, and yet ... I do pretty well with plain old C-u C-x $.

@jpcirrus
Copy link

For reference, Sublime Text has a nice docstring folding package: Fold Python Docstrings

@jorgenschaefer jorgenschaefer changed the title Modern code folding Module: Modern code folding Apr 24, 2015
@cpitclaudel
Copy link
Contributor

Indeed, folding docstrings would be very nice :)

@humitos
Copy link

humitos commented Sep 20, 2016

Right now I'm using origami (https://github.com/gregsexton/origami.el) with these settings

(require 'origami)

(define-key origami-mode-map (kbd "C-c f a") 'origami-toggle-all-nodes)
;; http://stackoverflow.com/questions/916797/emacs-global-set-key-to-c-tab
(define-key origami-mode-map (kbd "<C-tab>") 'origami-recursively-toggle-node)

(global-origami-mode 1)

Yeah, it's not the best and I would prefer something better than that but it's something that could be considered in the research.

@aparkerlue
Copy link

I find that the following is an acceptable stopgap:

(add-hook 'python-mode-hook 'hs-minor-mode)
(with-eval-after-load "python"
  (define-key python-mode-map (kbd "C-c TAB") 'hs-toggle-hiding)
  )

@clawdelle
Copy link

@aparkerlue thx, that is coll,enough for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants