osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scala considering significant indentation like Python


On Wednesday, May 24, 2017 at 2:14:15 AM UTC+5:30, Ben Finney wrote:
> Grant Edwards grant.b.edwards writes:
> 
> > On 2017-05-23, Michael Torrie  wrote:
> > > Sometimes things get longer than a page (like a class definition).
> >
> > A nice folding mode works nicely for that sort of thing. I normally
> > use emacs, but it doesn't seem to have a folding mode built-in, and
> > the add-on one's I've tried didn't seem to work in a very useful way.
> 
> The ?set-selective-display? command will collapse the current buffer's
> text to lines indented to the specified number of columns; the same
> command with no argument will expand the buffer to normal again. The
> command is bound to ?C-x $? in default Emacs.

I would have thought hideshow minor mode is what is desired??

(info "(emacs)Hideshow")

Which however happens to have rather ridiculous keybindings
If you like org-mode style TAB and Shift-TAB here's a hack  ? barely tried out!!

------------------
;; Add to your init
;; To get Tab and Shift-Tab to behave as in org-mode

(defvar rusi/hs-hide nil "Current state of hideshow for toggling all.")
;;;###autoload
(defun rusi/hs-toggle-all () "Toggle hideshow all."
  (interactive)
  (setq rusi/hs-hide (not rusi/hs-hide))
  (if rusi/hs-hide
      (hs-hide-all)
    (hs-show-all)))

(add-hook 'hs-minor-mode-hook
	  (lambda ()
	    (define-key hs-minor-mode-map (kbd "<backtab>") 'rusi/hs-toggle-all)
	    (define-key hs-minor-mode-map (kbd "<tab>") 'hs-toggle-hiding)))

(add-hook 'python-mode-hook 'hs-minor-mode)
(add-hook 'c-mode-hook      'hs-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
;; etc

------------------