[ANN] Emacs rails.el

Hi Dima,

“Symbol’s value as variable is void: html-mode-abbrev-table” the first
time. The second time I hit ctrl-t it works.

try add in you .emacs this line, if not exists
(setq auto-mode-alist (cons '("\.rhtml$" . html-mode) auto-mode-alist))

Doesn’t help w/ 21.3 or 21.4

Upgrading to CVS HEAD does fix it.

Also, I’ve included ‘snippet.el’ but can’t trigger abbreviation
expansion with TAB. Ideas?

rec - not work?

No. (But I sure want it to! :wink:

Hmm… no ideas
I’m using emacs from cvs 22.0.50.1 (2005/11/26), do not see this
problem

I just upgraded to 22.0.50.1, still no luck with TAB

I’m also running ECB (Emacs Code Browser). Perhaps there’s a conflict?

I tried (kbd “<f8”>) instead of (kbd “”) and that works. Though it
gets me the crappy minibuffer prompt instead of the cool snippet.el
inline mode.

Thoughts?

(Wishing he was more of an elisp hack)
-San

I tried (kbd “<f8”>) instead of (kbd “”) and that works. Though it
gets me the crappy minibuffer prompt instead of the cool snippet.el
inline mode.

Thoughts?

Try to update rails.el

I rewrited code working with snippets.
There are a lot of changes in this part, of the code.

This must help.

Ok, some minor troubles:

I added find-recursive.el ok. Then ran into the following:

I commented out the following:

;(find-recursive-directory-relative-files “Z:/WWW/cms3/ftp/ror/app/”
“” “\.rb$”)

Tried ctrl-T. It gives:

File /sites/foo.com/TAGS is not a valid tags table

But will work the second time.

TAB still doesn’t work. Nor does CTRL-. Rebount to and that
doesn’t work now either.

If I add ruby-electric.el via ‘add-hook’:

(add-hook 'ruby-mode-hook
(lambda()
(ruby-electric-mode t)
))

It no longer works when I (require 'rails)

Syntax coloring for ruby-mode is disabled.

Let me know if I can be of more help.

Hello, San!
on 08.02.2006 21:23

Ok, some minor troubles:

I added find-recursive.el ok. Then ran into the following:

I commented out the following:

;(find-recursive-directory-relative-files “Z:/WWW/cms3/ftp/ror/app/”
“” “\.rb$”)

Corrected

Tried ctrl-T. It gives:

File /sites/foo.com/TAGS is not a valid tags table

But will work the second time.

Corrected

It no longer works when I (require 'rails)

Syntax coloring for ruby-mode is disabled.

Let me know if I can be of more help.

Yet I do not know, from for what it can not work

Hi Dima! Big improvements, we’re super close.

re: syntax highlighting

If I comment out the following line in rails-minor-mode:

;******** uncomment and this breaks highlighting
; (visit-tags-table tags-file-name t)

Then syntax coloring starts to work again. Now I don’t have a TAGS
file setup, so perhaps the function is failing and causing the rest of
the hooks not to run? I’m groking elisp a little now, but not enough.

re: TAB key

I’ve removed ECB and just about everything else in my .emacs file.
binding to still doesn’t work, but I can bind to and that
does work.

Here’s what’s left of my .emacs:

;;----------------------------------------------------------------------------
;; Set up syntax highlighting (font-lock)
;;----------------------------------------------------------------------------

(cond ((fboundp 'global-font-lock-mode)
;; Turn on font-lock in all modes that support it
(global-font-lock-mode t)
;; Maximum colors
(setq font-lock-maximum-decoration t)))

(setq ruby-program-name “/usr/local/bin/ruby”)
(autoload 'ruby-mode “ruby-mode” “Mode for editing ruby source files”)
(add-to-list 'auto-mode-alist '(".rb$" . ruby-mode))
(add-to-list 'auto-mode-alist '(".rjs$" . ruby-mode))
(add-to-list 'interpreter-mode-alist '(“ruby” . ruby-mode))

(require 'ruby-electric)

(defun try-complete-abbrev (old)
(if (expand-abbrev) t nil))

(setq hippie-expand-try-functions-list
'(try-complete-abbrev
try-complete-file-name
try-expand-dabbrev))

(require 'rails)

(add-hook 'ruby-mode-hook
(lambda()
(ruby-electric-mode t)
))

That’s it… nothing else (removed ECB, etc)

Note: ruby-mode.el and ruby-electric.el are the latest from CVS
CVS HEAD emacs running in text mode under ssh/putty & screen.

Summary:

Broken Stuff:

  • No TAB key
  • (visit-tags-table) seems to be breaking font-lock

thoughts?

Good stuff:

  • abbrevs, snippet replace mode, Ctrl-T and everything else seem to work
    great.

rails.el rocks! This completely demotivates me from buying a MacBook :wink:

Thanks,

-San

Hi Dima,

Here’s a fix to make TAB work:

         (local-set-key (kbd "TAB") 'ruby-indent-or-complete)

Just replace ‘’ with ‘TAB’ and all is good. Does that work on your
end too?

I can’t find any docs on the (kbd) function in elisp. (Where does one
find this stuff?)

Best,

-San

C-h f kbd RET

(local-set-key [tab] 'ruby-indent-or-complete)

-Rob

Sweet, thanks Rob.

Dima, these fix the keyboard for me:

         (local-set-key (kbd "TAB") 'ruby-indent-or-complete)
         (local-set-key (kbd "RET") 'ruby-newline-and-indent)
         (local-set-key (kbd "DEL") 'backward-delete-char-untabify)

‘’ and ‘RET’ are supposed to be synonomous, but RET works for me
doesn’t.

Emacs + rails.el now bring joy to coding.

-San

dima wrote:

If you find out how to make emacs interpret the ANSI codes as 

[1] EmacsWiki: ansi-color.el
Thanks for assistance.
rails.el now display color logs:)
Cool.

– stefan


For rails performance tuning, see: http://railsexpress.de/blog
Subscription: railsexpress.de

With the most recent change I’m getting a ‘Symbol’s function
definition is void: posn-at-point’ when I try to Ctr-t in a
controller method. I’m running a clean build of GnuEmacs 21.4.1 with
ECB installed. I could also use a few pointers for getting my .rhtml
files to behave properly with expansion/tabbing. Here’s my .emacs:


(add-to-list 'load-path
“/opt/emacs”)

(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
(setq x-select-enable-clipboard t)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)

(load-file “/opt/emacs/common/cedet.el”)

;; Enabling various SEMANTIC minor modes. See semantic/INSTALL for more
ideas.
;; Select one of the following
(semantic-load-enable-code-helpers)
;; (semantic-load-enable-guady-code-helpers)
;; (semantic-load-enable-excessive-code-helpers)

;; Enable this if you develop in semantic, or develop grammars
;; (semantic-load-enable-semantic-debugging-helpers)

(require 'ecb-autoloads)
(custom-set-variables
;; custom-set-variables was added by Custom – don’t edit or cut/paste
it!
;; Your init file should contain only one such instance.
'(case-fold-search t)
'(current-language-environment “Latin-1”)
'(default-input-method “latin-1-prefix”)
'(ecb-kill-buffer-clears-history (quote auto))
'(ecb-layout-name “left5”)
'(ecb-layout-window-sizes (quote ((“left5” (0.15355805243445692 .
0.2823529411764706) (0.15355805243445692 . 0.32941176470588235)
(0.15355805243445692 . 0.3411764705882353)) (“left8”
(0.1647940074906367 . 0.25882352941176473) (0.1647940074906367 .
0.23529411764705882) (0.1647940074906367 . 0.2) (0.1647940074906367 .
0.25882352941176473)))))
'(ecb-maximize-ecb-window-after-selection t)
'(ecb-options-version “2.32”)
'(ecb-primary-secondary-mouse-buttons (quote mouse-1–mouse-2))
'(ecb-redraw-layout-quickly t)
'(ecb-source-path (quote (("/" “/”) ("/var/www/ceivecms" “CeiveCMS”)
("/var/www/allenmortuary" “AllenMortuary”))))
'(ecb-tip-of-the-day nil)
'(ecb-tree-buffer-style (quote image))
'(ecb-tree-expand-symbol-before nil)
'(ecb-windows-height 0.5)
'(global-font-lock-mode t nil (font-lock))
'(mouse-wheel-mode t nil (mwheel)))
(custom-set-faces
;; custom-set-faces was added by Custom – don’t edit or cut/paste it!
;; Your init file should contain only one such instance.
)
(global-set-key “\M-g” 'goto-line)

(defun try-complete-abbrev (old)
(if (expand-abbrev) t nil))

(setq hippie-expand-try-functions-list
'(try-complete-abbrev
try-complete-file-name
try-expand-dabbrev))

(setq interpreter-mode-alist
(cons '(“ruby” . ruby-mode) interpreter-mode-alist))
(setq auto-mode-alist
(cons '("\.rb$" . ruby-mode) auto-mode-alist))
(autoload 'ruby-mode “ruby-mode” nil t)
(require 'rails)

When you’ve got a few minutes, look at the value of global-map
C-h v global-map RET

In general, the argument is described best under define-key
C-h f define-key RET

But the “vector” is symbols or key values

These should be equivalent:
(local-set-key [tab] 'ruby-indent-or-complete)
(local-set-key “\C-i” 'ruby-indent-or-complete)
(local-set-key [9] 'ruby-indent-or-complete)

         (local-set-key [return] 'ruby-newline-and-indent)
         (local-set-key "\C-m" 'ruby-newline-and-indent)
         (local-set-key [13] 'ruby-newline-and-indent)

These are tricky…
(local-set-key [backspace] 'backward-delete-char-untabify)

     ;; the [delete] is likely on the number pad
         (local-set-key [delete] 'delete-char)

     ;; take your chances...
         (local-set-key "\C-?" 'backward-delete-char-untabify)

You can probably guess what these mean: [f8] [C-f11] [S-f3]

Here’s a good way to figure out was a key IS rather than what it does:

C-h c KEYHERE C-h l

That’s “describe-key-briefly” the key you want (which might be more
than one!) “view-lossage”

I use “view-lossage” when my fingers remember a command, but I can’t
:wink: (that stuff happens when you’ve used emacs on numerous platforms
over 20 years and your ~/.emacs file is approaching 1000 lines)

-Rob