aviary

Computers July 26, 2005. 19:33:18

Finally wanted to get ruby-mode functioning in mmm-mode.

This link was the most helpful (and so are the links on the page): http://blog.invisible.ch/archives/000417.html

Finally, I settled for this:

;;; mmm-mode
(require 'mmm-auto)
(setq mmm-global-mode 'maybe)
(setq mmm-submode-decoration-level 0)
	
;;; ruby-electric (omg this is going to spoil me)
(require 'ruby-electric)
	
(defun ruby-indent ()
  (local-set-key \"\C-m\" 'ruby-reindent-then-newline-and-indent))
	
(add-hook 'ruby-mode-hook
          '(lambda ()
             (ruby-indent)
             (ruby-electric-mode)
             ))
	
;;; eRuby (ruby/html mmm)
(mmm-add-classes
 '((erb-code
    :submode ruby-mode
    :front \"< %[#=]?\"
    :back \"%>”
    )))
	
(add-hook ‘html-mode-hook
          (lambda ()
            (setq mmm-classes ‘(erb-code))
            (mmm-mode-on)))
(add-to-list ‘auto-mode-alist ‘(”\\.rhtml$” . html-mode))

Now, I spent 2 hours trying to figure out how the HECK to get indentation working within the HTML. When I first saw it wasn’t working, I thought it was just me, but someone has noted this before. My last attempt almost ran me out of ideas. Since ruby-mode looks for indentational keywords, I would add “< %" to the list, as it is always precedes in embedded ruby anyway. Unfortunately, that doesn't work, but I think the reason why is because mmm-mode suppresses the initial start string from the encapsulated mode, so ruby-mode never sees it.

Instead, I went straight to the functions that used ruby-indent-beg-re. ruby-beginning-of-indent finds where ruby-mode should start indenting, so I decided to include the "(" in ruby-indent-beg-re. Of course, with all the other stuff that ruby-beginning-of-indent puts in, this fix might not work at all, so I modified the function to use this instead:


- concat "^\\(" ruby-indent-beg-re "\\)\\b"
+ concat "^\\(" ruby-indent-beg-re "\\)\\b\\|\("

Before, then I thought I had it working, I needed a starting paren to get ruby to see where I wanted it to start indenting, so it wouldn't hurt if I added a open paren to when I wanted multi-line indented embedded ruby.

And that, with making the byte-compiled file using byte-compile-file in emacs, fixed it. It's too early to say whether or not I've broken something, but I don't think I have.

Technology, Articles July 26, 2005. 17:34:53

IBM DeveloperWorks has an article about setting up a wireless ISP on Linux.

Technology, Articles July 26, 2005. 17:34:11

IBM DeveloperWorks has an article that answers the question: “Why FreeBSD?”

Worth a read. Which reminds me - I hope I did post the research I did in May or June about BSD, as I’ve already forgotten which distro fits me best. If I did, this place is definitely useful, because I honestly don’t remember how I went about researching BSD.

Daily Readings July 26, 2005. 17:32:02

Also with readings from yesterday for previous days too.

Slashdot

Flexbeta

Daily Readings July 23, 2005. 10:02:19

Slashdot

Flexbeta

Daily Readings July 22, 2005. 14:35:13

Gave up setting a “periods” standard.

Slashdot

Daily Readings July 21, 2005. 15:18:35

Slashdot

Flexbeta

Daily Readings July 20, 2005. 22:22:43

Slashdot

Neowin

Daily Readings July 18, 2005. 12:57:59

Slashdot

Flexbeta

Neowin

Uncategorized, Daily Readings July 17, 2005. 10:26:31

Found The Unofficial Apple Weblog a few days ago… forgot how. It’s a very interesting site.