On Jan 8, 2004, at 8:33 PM, Pete Yadlowsky wrote: > I like Ruby very much except for one thing: all those "end" tokens > scattered > everywhere. For my style of coding, they are superfluous and, in my > opinion, > only serve to clutter the code. I very much like Python's indent > blocking > style and would like to use it with Ruby. Indenting does everything I > need it > to do in terms of establishing structure and enhancing readability. > Once you > get used to this style (I've been using it for just about all > languages and > for longer than Python has existed), delimiter tokens become > unnecessary and > unwanted. > > I'm sure the topic of Python-style blocking in Ruby has been brought up > before. Is there a general consensus on this in the community? Before I > totter off to write my own Ruby preprocessor, does such a thing already > exist? Thanks. As a simple workaround, I wrote this little code to hide ends in a row and collapse their lines in Emacs. Useful for reading but not for writing: -- fxn (defvar ruby-ends-hide-regexp-overlays nil "") (make-variable-buffer-local 'ruby-ends-hide-regexp-overlays) (defun hide-ruby-ends () "Hide Ruby end keywords." (interactive) (let ((regexp "^\\(?:[ \t]*\\(?:end\\|}\\)\n\\)+")) (save-excursion (goto-char (point-min)) (while (and (< (point) (point-max)) (re-search-forward regexp nil t)) (let ((overlay (make-overlay (match-beginning 0) (match-end 0)))) (overlay-put overlay 'invisible 't) (overlay-put overlay 'intangible 't) (overlay-put overlay 'before-string "") (overlay-put overlay 'after-string "") (setq ruby-ends-hide-regexp-overlays (cons overlay ruby-ends-hide-regexp-overlays))))))) (defun unhide-ruby-ends () "Unhide Ruby end keywords." (interactive) ;; remove all overlays in the buffer (while (not (null ruby-ends-hide-regexp-overlays)) (delete-overlay (car ruby-ends-hide-regexp-overlays)) (setq ruby-ends-hide-regexp-overlays (cdr ruby-ends-hide-regexp-overlays)))) (defvar ruby-ends-are-hidden nil "") (make-variable-buffer-local 'ruby-ends-are-hidden) (defun toggle-ruby-ends () "Hide/unhide Ruby end keywords." (interactive) (cond (ruby-ends-are-hidden (unhide-ruby-ends) (setq ruby-ends-are-hidden nil)) (t (hide-ruby-ends) (setq ruby-ends-are-hidden t))))