Hello,
I have had a hard time using ruby-mode.el, but that was my first
exposure to XEmacs, so…
1- xemacs: I’ve tried to install ruby-mode.el, and I have searched
Internet to find a solution, but I’m unable to make it work… and it’s
a little bit of a pain not having it!
If your problem is that font-lock isn’t working, then you need to add
(load “font-lock”)
at the start of your .emacs.
Thank you fo rthe answer.
I tried and it does not seem to work.
Actually, my problem is that I’m not able to use neither the indentation
neither the color of the source code (Yes, I have set the
“Options->Syntax Highlighting->In this buffer” option).
I tried to put the ruby-mode.el in the path of xemacs, and I have added
(require 'ruby-mode) both in my .emacs and .xemacs-custom but it seems
not to work. Have I missed a point in the ruby-mode.el installation? I
searched the web for a general way of installing the *.el files, but I
did not find any result…
Thanks!
Guille
I put some *.el file in my .xemacs directory, and then I set the
load path:
(setq load-path (cons (expand-file-name “~/.xemacs/”) load-path))
; This one may or may not be necessary (it is not for me)
;(load “font-lock”)
Then I autoload the ruby mode:
(autoload 'ruby-mode “ruby-mode”
“Mode for editing ruby source files”)
(setq auto-mode-alist
(append '((“\.rb$” . ruby-mode)) auto-mode-alist))
(setq interpreter-mode-alist (append '((“ruby” . ruby-mode))
interpreter-mode-alist))
Then I added this… but I am not sure about what it does, maybe
it set the font mode automatically when in ruby mode:
(add-hook 'ruby-mode-hook 'font-lock-fontify-buffer)
And also this… so that I can manually force a syntax highlighting:
;Brian Marick, marick@testing.com
(global-set-key “^z” 'font-lock-fontify-buffer)
Overall, I end up trying to disable the automatic fontifying and
activate it manually only, when I need it. I did that because it
is slow on large file (1000 lines or so).
Unfortunately I still have some intrusive “rescanning…” occurring
from time to time. For large files, this is inconvenient because the
UI is freezed during that rescanning.
Hope this helps. If you manage to setup a better solution, please
tell about it.
Yours,
Jean-Hugues
P.S. Here is my full .xemacs/custom.el, some stuff work, some
don’t.
(custom-set-variables
'(mwheel-scroll-amount (quote (10 . 1)))
'(toolbar-info-use-separate-frame nil)
'(require-final-newline (quote ask))
'(font-lock-auto-fontify nil)
'(modeline-click-swaps-buffers t)
'(lazy-shot-verbose nil)
'(mwheel-follow-mouse t)
'(paren-mode (quote paren) nil (paren))
'(font-lock-maximum-decoration t)
'(lazy-lock-stealth-time 5)
'(buffers-tab-sort-function (quote jhr-sort-buffer-alpha))
'(comint-scroll-to-bottom-on-output (quote all))
'(comment-start “#”)
'(buffers-menu-submenus-for-groups-p nil)
'(buffers-menu-max-size nil)
'(font-lock-use-colors t)
'(default-toolbar-position (quote left))
'(lazy-lock-mode nil nil (lazy-lock))
'(fast-lock-mode nil nil (fast-lock))
'(font-lock-use-fonts nil)
'(grep-command "fgrep -n ")
'(lazy-shot-stealth-verbose nil)
'(bar-cursor 2)
'(comment-start-skip “#.*”)
'(buffers-tab-max-size nil)
'(lazy-shot-stealth-time 5)
'(fold-allow-overlays t)
'(paren-delay 1.0)
'(menu-accelerator-enabled nil t)
'(truncate-lines t)
'(comint-scroll-to-bottom-on-input (quote all))
'(default-gutter-position (quote top))
'(fume-rescanning-message “Re-Scanning buffer…”)
'(dabbrev-check-all-buffers nil)
'(stack-trace-on-error nil)
'(hs-hide-comments-when-hiding-all nil)
'(mouse-yank-at-point t)
'(gnuserv-frame t)
'(complex-buffers-menu-p nil)
'(user-mail-address “jean_hugues_robert@yahoo.com”)
'(speedbar-track-mouse-flag t)
'(query-user-mail-address nil)
'(indent-tabs-mode nil)
'(comint-buffer-maximum-size 4000)
'(hs-isearch-open t)
'(modeline-scrolling-method (quote scrollbar)))
(custom-set-faces
'(font-lock-string-face ((((class color) (background light)) (:foreground
“DarkYellow”))))
'(font-lock-reference-face ((((class color) (background light))
(:foreground “DarkBlue”))))
'(font-lock-variable-name-face ((((class color) (background light))
(:foreground “brown”))))
'(font-lock-keyword-face ((((class color) (background light) (type
mswindows)) (:foreground “gray25” :bold t))))
'(font-lock-function-name-face ((((class color) (background light) (type
mswindows)) (:foreground “red” :bold t :underline t)))))
;;; JHR Stuff
(setq load-path (cons (expand-file-name “~/.xemacs/”) load-path))
(defun jhr-sort-buffer-alpha ( a_list )
“Sort a list of buffers”
(sort a_list
(function (lambda (buffer-1 buffer-2)
(string-lessp (buffer-name buffer-1) (buffer-name buffer-2))
))
)
)
; This one may not be necessary at all
;(load “font-lock”)
(autoload 'ruby-mode “ruby-mode”
“Mode for editing ruby source files”)
(setq auto-mode-alist
(append '((“\.rb$” . ruby-mode)) auto-mode-alist))
(setq interpreter-mode-alist (append '((“ruby” . ruby-mode))
interpreter-mode-alist))
(add-hook 'ruby-mode-hook 'font-lock-fontify-buffer)
(autoload 'run-ruby “inf-ruby”
“Run an inferior Ruby process”)
(autoload 'inf-ruby-keys “inf-ruby”
“Set local key defs for inf-ruby in ruby-mode”)
(add-hook 'ruby-mode-hook
'(lambda ()
(inf-ruby-keys)
(define-key ruby-mode-map “\C-c\C-l” 'ruby-load-current-buffer)
))
;; From Nobu Nakata:
;;(setq font-lock-mode-enable-list
;; (append '(ruby-mode) font-lock-mode-enable-list))
;; Need to look at
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/37476
;; From http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/16897
(defun ruby-visit-source ()
“If the current line contains text like ‘…/src/program.rb:34’, visit
that file in the other window and position point on that line.”
(interactive)
(let* ((start-boundary (save-excursion (beginning-of-line) (point)))
(regexp (concat “\([ \t\n\r"'([<{]\|^\)” ; non file chars or
; effective
; beginning of file
“\(.+\.rb\):\([0-9]+\)”)) ; file.rb:NNN
(matchp (save-excursion
(end-of-line)
;; if two matches on line, the second is most likely
;; to be useful, so search backward.
(re-search-backward regexp start-boundary t))))
(cond (matchp
(let ((file (buffer-substring (match-beginning 2)
(match-end 2)))
(line (buffer-substring (match-beginning 3)
(match-end 3))))
; Windows: Find-file doesn’t seem to work with Cygwin
; /// format or the odd /cygdrive// format
(if (or (string-match “//\(.\)\(.\)" file)
(string-match "/cygdrive/\(.\)\(.\)” file))
(setq file
(concat (substring file
(match-beginning 1)
(match-end 1))
“:”
(substring file
(match-beginning 2)
(match-end 2)))))
(find-file-other-window file)
(goto-line (string-to-int line))))
(t
(error "No ruby location on line.")))))
;; I bind the above to ^h^h, an odd choice, because that’s easy to
;; type after reaching the line with ^p or ^n.
(global-set-key “\C-e” 'ruby-visit-source)
; ToDo: About Folding: Investigatge hs-special-modes-alist
;(pushnew '(ruby-mode “module” “end”)
; hs-special-modes-alist :test 'equal)
;(pushnew '(ruby-mode “class” “end”)
; hs-special-modes-alist :test 'equal)
;(pushnew '(ruby-mode “def” “end” function-name)
; hs-special-modes-alist :test 'equal)
;(pushnew '(ruby-mode “if” “end”)
; hs-special-modes-alist :test 'equal)
;(pushnew '(ruby-mode “begin” “end”)
; hs-special-modes-alist :test 'equal)
;(pushnew '(ruby-mode “do” “end”)
; hs-special-modes-alist :test 'equal)
; This works with ID: hideshow.el,v 5.31 2001/08/27 22:18:17 ttn Rel
(require 'hideshow)
(let ((ruby-mode-hs-info '(
ruby-mode
“class\|module\|def\|if\|unless\|case\|while\|until\|for\|begin\|do”
“end”
“#”
ruby-move-to-block
nil
)
))
(if (not (member ruby-mode-hs-info hs-special-modes-alist))
(setq hs-special-modes-alist
(cons ruby-mode-hs-info hs-special-modes-alist)))
)
;(add-hook 'ruby-mode-hook
; '(lambda () (hs-minor-mode 1)))
;(add-hook 'ruby-mode-hook 'hs-minor-mode)
; (defun ttn-hs-hide-level-1 ()
; (hs-hide-level 1)
; (forward-sexp 1))
; (setq hs-hide-all-non-comment-function 'ttn-hs-hide-level-1)
;(setq hs-hide-all-non-comment-function nil)
; Ruby friendly outline
(setq outline-regexp “mo\|cl\|…d\|…d”)
(defun ruby-load-current-buffer ()
“Load current buffer’s Ruby file into the inferior Ruby process.
Saving it first if needed.”
(interactive)
(let (
(buffer (current-buffer))
(proc (ruby-proc))
)
(or (eq major-mode ‘ruby-mode)
(error “Not ruby mode”))
(save-buffer buffer)
(switch-to-ruby t)
(comint-send-string
proc
(concat “(load '” (buffer-file-name buffer) "’)\n")
)
)
)
(add-hook 'inf-ruby-load-hook
(function (lambda ()
(define-key ruby-mode-map “\C-c\C-l” 'ruby-load-current-buffer)
))
)
; Get a more Windows like Look&Feel
(load-library “cua-mode.elc”)
(CUA-mode t)
;(transient-mark-mode t)
(delete-selection-mode t)
;Brian Marick, marick@testing.com
(global-set-key “^z” 'font-lock-fontify-buffer)
;; Speedbar
(require 'speedbar)
(add-menu-button '(“Tools”)
[“Speedbar” speedbar-frame-mode
:style toggle
:selected (and (boundp 'speedbar-frame)
(frame-live-p speedbar-frame)
(frame-visible-p speedbar-frame))]
“–”)
; Save open files and restore them when restarted
(load “desktop.el”)
(desktop-load-default)
(desktop-read)
; init it with: (desktop-save “.”)
···
At 10:05 03/07/2002 +0900, you wrote:
Web: http://hdl.handle.net/1030.37/1.1
Phone: +33 (0) 4 92 27 74 17