[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Python docstring folding
From: |
Tomas Nordin |
Subject: |
Re: Python docstring folding |
Date: |
Mon, 26 Nov 2018 18:04:08 +0100 |
Rock Storm <rockstorm@gmx.com> writes:
> On Tue, Nov 20, 2018 at 10:12:03AM -0800, Drew Adams wrote:
>> > I'm struggling with code folding. I installed
>> > 'outline-magic'. Which works great but it doesn't
>> > fold docstrings... Is there an easy way to achieve
>> > docstring folding?
>>
>> What do you mean by folding doc strings? What do you
>> want that it doesn't do?
>
> The behaviour I was expecting would be something similar to what this
> plugin does [1].
>
> [1]: https://github.com/alecthomas/SublimeFoldPythonDocstrings
>
>> If you just want to toggle whether doc strings (only)
>> are hidden, see this:
>>
>> http://lists.gnu.org/archive/html/help-gnu-emacs/2018-11/msg00115.html
>
> Thanks a lot for the hint. I'll try that. However, isn't there a less
> complicated way of doing it? Is it so uncommon? How did Python
> developers live before you provided them with this? :P
If it is OK to "simply" split windows maybe this is less complicated to
install:
(defun tn-split-window-signature-on-top (&optional numlines)
"Split window at point leaving minimum 2 lines of defun beginning on top"
(interactive "p")
(let ((start-pos (point))
(start-line (line-number-at-pos))
(toplines (if (> numlines 1) numlines 2)))
(beginning-of-defun)
(split-window-below (1+ toplines))
(window-resize nil (- toplines (window-body-height)))
(recenter 0)
(other-window 1)
(goto-char start-pos)
(recenter 0)))
Should work with any function understood as a defun. You can control how
much of the beginning of the defun to show with a numeric prefix
argument (like C-u). I find it comfortable that point will remain on its
current position in the lower window (at the moment you forgot about
arguments).
Best regards
--
Tomas