hideshow mode for ruby-mode.el 
Author Message
 hideshow mode for ruby-mode.el

The `hideshow' Emacs minor mode lets you hide the content of a block
of code and only see the first line.  This is what I put in my
~/.emacs file to have it work with Ruby:

(defun ruby-custom-setup ()
; [other stuff omitted...]
  (add-to-list 'hs-special-modes-alist
               '(ruby-mode
                 "\\(def\\|do\\)"
                 "end"
                 "#"
                 (lambda (arg) (ruby-end-of-block))
                 nil
                 ))
  (hs-minor-mode t)
)

(add-hook 'ruby-mode-hook 'ruby-custom-setup)

Then with M-x hs-hide-all...

def hello
  puts "hello world"
end

..becomes:

def hello...

Beware, it'll {*filter*}on def's and end's appearing in strings.  I didn't
care of that, my eyes still ache in front of regexps defined in
elisp. %-)

Massimiliano



Thu, 23 Dec 2004 05:13:24 GMT  
 hideshow mode for ruby-mode.el

Quote:

> The `hideshow' Emacs minor mode lets you hide the content of a block
> of code and only see the first line

just out of curiosity; does Emacs feature folding, in general, or for Ruby?

Tobi

--
http://www.pinkjuice.com/



Thu, 23 Dec 2004 05:13:25 GMT  
 hideshow mode for ruby-mode.el
Quote:
Massimiliano Mirra writes:

 >
 > The `hideshow' Emacs minor mode lets you hide the content of a block
 > of code and only see the first line.  This is what I put in my
 > ~/.emacs file to have it work with Ruby:

Thanks very much! That takes care of one of the two things I think
ruby-mode has been missing. Now, if someone could only implement
def/begin/do->end matching that works like paren-matching does....

Oh well. Gives me a reason to sit down and learn elisp someday.

Dan
--

www.nodewarrior.org
ignorami: n:
The art of folding problem users into representational shapes.



Thu, 23 Dec 2004 06:26:16 GMT  
 hideshow mode for ruby-mode.el


Quote:

> > The `hideshow' Emacs minor mode lets you hide the content of a
> block
> > of code and only see the first line

> just out of curiosity; does Emacs feature folding, in general, or
> for Ruby?

At least general.  You could add ruby w/o much issue, IIRC.  I
haven't used folding mode in a long while, but remember it being a
more general solution.

=====
--
Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

Yahoo IM: michael_s_campbell

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com



Thu, 23 Dec 2004 12:51:28 GMT  
 hideshow mode for ruby-mode.el

Quote:

>>>The `hideshow' Emacs minor mode lets you hide the content of a

>>block

>>>of code and only see the first line

There is also emacs' selective-display facility, which shows or hides
based on the existing indentation. So it basically borrows the logic of
ruby-mode or whatever.  --Mark

;; ~/.emacs excerpt
;;  Use function keys f9 through f12 as a 'zoom' control.
(defun zoom-way-out() (interactive)
  (set-selective-display 0))
(defun zoom-way-in() (interactive)
  (set-selective-display 2))
(defun zoom-out() (interactive)
 (set-selective-display
  (if selective-display
      (if (or (= selective-display 0) (= selective-display 10))
      0
    (+ selective-display 2))
    0)))
(defun zoom-in() (interactive)
 (set-selective-display
  (if selective-display
      (if (= selective-display 0)
      10
    (if (= selective-display 2)
        2
      (- selective-display 2)))
    10)))

(global-set-key [f9] 'zoom-way-out)
(global-set-key [f10] 'zoom-out)
(global-set-key [f11] 'zoom-in)
(global-set-key [f12] 'zoom-way-in)



Thu, 23 Dec 2004 21:57:51 GMT  
 hideshow mode for ruby-mode.el

Quote:

> >The `hideshow' Emacs minor mode lets you hide the content of a block
> >of code and only see the first line

> just out of curiosity; does Emacs feature folding, in general, or for Ruby?

With the few lines I posted it supports the `hideshow' style folding
for Ruby.  You can find about other general and less general folding
modes at http://www.emacswiki.org/cgi-bin/wiki.pl?CategoryOutline.

Massimiliano



Fri, 24 Dec 2004 03:31:22 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. latest ruby-mode.el messing up c++ mode fontification

2. ruby-mode.el was: ruby indenter

3. ruby-mode.el was: ruby indenter

4. verilog-mode.el indent unlike c-mode ...

5. Emacs VHDL editing mode (vhdl-mode.el version 2.74)

6. Emacs VHDL editing mode (vhdl-mode.el version 2.71)

7. Emacs VHDL editing mode (vhdl-mode.el version 2.56.1.1)

8. Emacs VHDL editing mode (vhdl-mode.el version 2.56.1.1)

9. VHDL mode for Emacs (vhdl-mode.el version 2.50)

10. ruby-mode.el again; imenu this time

11. ruby-mode.el dies when breaking ternary exp.

12. ruby-mode.el and xemacs

 

 
Powered by phpBB® Forum Software