1
votes

I am trying to add ruby-mode to my emacs so i created .emacs file and copy the following code into it:

; directory where ruby-emacs.el is located
(add-to-list 'load-path "/Users/.rvm/src/ruby-2.2.0/misc/")

; loads ruby mode when a .rb file is opened.
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby scripts." t)

(setq auto-mode-alist (cons '(".rb$" . ruby-mode) auto-mode-alist))

then when i open .rb file, it looks pretty good with color code and everything, except when i try to save the file, it gives me:

Symbol's value as variable is void: ruby-insert-encoding-magic-comment

how can I solve this. i don't know Lisp (took course, but totally forgot:)

my emacs version is: 22.1.1 machine is macbook os x 10.10

thanks.

1
In modern Emacs versions, Ruby mode is preinstalled. You can download one from "www.emacsforosx.com".Lindydancer
Yes, 22.1.1 is very old (2007). Upgrading is recommended.phils
Aside from upgrading, i.e., if you stay with Emacs 22, find out where variable ruby-insert-encoding-magic-comment is defined (e.g. grep for it). And then make sure that file gets loaded also, whenever the code that uses that variable is loaded. (This is a general thing.)Drew

1 Answers

1
votes

I have the same problem in my Mac and I do not have any idea about lisp either. However I have found a "workaround" by editing the ruby-mode.el file and changed

THIS:

((looking-at "\\s *#.*coding\\s *[:=]"))
(t (when ruby-insert-encoding-magic-comment
     (insert "# -*- coding: " coding-system " -*-\n"))))))))

INTO THIS:

((looking-at "\\s *#.*coding\\s *[:=]"))
   ;(t (when ruby-insert-encoding-magic-comment (insert "# -*- coding: " coding-system " -*-\n")))                              
)))))

...and it worked.

I know this does not solve the problem itself, but it's a workaround to avoid the error and keep using emacs :-)