0

I'm using emacs for my every day tasks, I started more or less 4 years ago, and now I'm very happy with emacs. maybe I have a lot of plugins working together.

This is my-ruby configuration file I load this while loading the init.el file:

╰─ cat .emacs.d/my-ruby.el                                                                                                          ✓  ⚙  4068  17:42:40
;;; Package --- ruby configuration

;;; Commentary:
;;; This file has my ruby configuration file

;;; Code:

(require 'ruby-mode)
(require 'inf-ruby)

(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.haml\\'" . ruby-mode))

(setq inf-ruby-default-implementation "pry")

(add-hook 'inf-ruby-mode-hook
  (function
    (lambda ()
      (setq show-trailing-whitespace nil)
      (linum-mode 0))))
;; When folding, take these delimiters into consideration
(add-to-list 'hs-special-modes-alist
             '(ruby-mode
               "\\(class\\|def\\|do\\|if\\)" "\\(end\\)" "#"
               (lambda (arg) (ruby-end-of-block)) nil))

;; RVM support
(require 'rvm)
(rvm-use-default)

;; Cucumber
(require 'feature-mode)
(setq feature-use-rvm t) ;; Tell cucumber to use RVM
(setq feature-cucumber-command "cucumber {options} {feature}")
;; .feature files should open in feature-mode
(add-to-list 'auto-mode-alist '("\\.feature\\'" . feature-mode))

;; Rspec
(require 'rspec-mode)
;; I want rspec instead of rake spec
(setq rspec-use-rake-when-possible nil)
;; Scroll to the first test failure
(setq compilation-scroll-output 'first-error)

;; haml
(require 'haml-mode)
(add-to-list 'auto-mode-alist '("\\.haml\\'" . haml-mode))

;; Prevent emacs from adding the encoding line at the top of the file
(setq ruby-insert-encoding-magic-comment nil)

;; Functions to help with refactoring
(require 'ruby-refactor)
(add-hook 'ruby-mode-hook 'ruby-refactor-mode-launch)
;; Easily toggle ruby's hash syntax
(require 'ruby-hash-syntax)
;; Ruby rdoc helpers mostly
(require 'ruby-additional)
;; Helpers to deal with strings and symbols
(require 'ruby-tools)
;; Support for YARD
(require 'yard-mode)
(add-hook 'ruby-mode-hook 'yard-mode)
;; Support for running rspec tests
(require 'rspec-mode)

;; Turn on eldoc in ruby files to display info about the
;; method or variable at point
(add-hook 'ruby-mode-hook 'eldoc-mode)
;; Switch the compilation buffer mode with C-x C-q (useful
;; when interacting with a debugger)
(add-hook 'after-init-hook 'inf-ruby-switch-setup)

(add-hook 'ruby-mode-hook
          (lambda ()
            (hs-minor-mode 1) ;; Enables folding
            (modify-syntax-entry ?: "."))) ;; Adds ":" to the word definition

;; robe autocompletion
(add-hook 'ruby-mode-hook 'robe-mode)
(push 'company-robe company-backends)
(eval-after-load 'company
  '(progn
     (push 'company-robe company-backends)
     (push 'company-inf-ruby company-backends)))

  ;;Set local key defs for inf-ruby in ruby-mode
  (define-key ruby-mode-map "\M-\C-x" 'ruby-send-definition)
  ;;(define-key ruby-mode-map "\C-x\C-e" 'ruby-send-last-sexp)
  (define-key ruby-mode-map "\C-c\C-b" 'ruby-send-block)
  (define-key ruby-mode-map "\C-c\M-b" 'ruby-send-block-and-go)
  (define-key ruby-mode-map "\C-c\C-x" 'ruby-send-definition)
  (define-key ruby-mode-map "\C-c\M-x" 'ruby-send-definition-and-go)
  (define-key ruby-mode-map "\C-c\C-r" 'ruby-send-region)
  (define-key ruby-mode-map "\C-c\M-r" 'ruby-send-region-and-go)
  (define-key ruby-mode-map "\C-c\C-z" 'switch-to-ruby)
  (define-key ruby-mode-map "\C-c\C-l" 'ruby-load-file)
  (define-key ruby-mode-map "\C-c\C-s" 'run-ruby)

(defadvice inf-ruby-console-auto (before activate-rvm-for-robe activate)
  (rvm-activate-corresponding-ruby))

(add-hook 'robe-mode-on-hook
          (lambda ()
            (remove-hook 'completion-at-point-functions
                         'robe-complete-at-point t)))

Finally I only have one problematic issue I'm working with a rails project, all works well, rspec, rails console, autocomplete with company ...,

But when I open routes.rb, in 30 seconds Emacs is frozen. I do this:

M-x rvm-activate-correspondenging-ruby

M-x i-rai

then I open the routes.rb file:

enter image description here

and then emacs is broken, I open the debugger, cat .emacs.d/server/afs
127.0.0.1:50736 6615 Q*"Lj4V[a[X6>KRda1%}K$#JRAR(t`($%8ttyW"g"9L)nob.U8_.XAj@R"tk0oMm% kill -SIGUSR2 6615

and seems that the problem if a loop that becomes from ruby mode, but I really not know how to follow with it:

enter image description here

sml/-this-buffer-changed(1 5 0)
  #[nil "`\304`[!\210\305 V\203�\306 \203�\307\310w\210\311\202\351�n\203-�o\204-�\312`\313\"b\210\311\202\351�`V\203A�n\204A�\314!\203A�\315\202\351�\316 \317     \203O�\320\nP\n\321\235\203b�\322 \203^�\n\202\350�\323\202\350�\n\324\232\203~�\325 \203q�\326\202\350�\327 \203z�\330\202\350�\n\202\350�\331\n\310\332\333#)\266\203\203\230�\334u\210\n\334\310O\202\350�\n\335\232\203\264�`Sf\336=\203\264�\337\340!\203\264�\313u\210\341 \202\350�\n\342\232\203\335�\343 \204\303�\n\202\350�\212\344\334!\210\304d!\210`)\305 V\203\331�\341 \202\350�\311\202\350�\n\345\232\203\347�\320\202\350�\n*)\207" [pos dot tok inhibit-changing-match-data forward-comment line-end-position ruby-smie--implicit-semi-p "  " nil ";" scan-sexps -1 ruby-smie--args-separator-p " @ " smie-default-backward-token ruby-smie--before-method-name "." ("unless" "if" "while" "until") ruby-smie--bosp "iuwu-mod" "|" ruby-smie--opening-pipe-p "opening-|" ruby-smie--closing-pipe-p "closing-|" "\\`|[*&]\\'" t string-match 1 "" 92 looking-at "\n" ruby-smie--backward-token "do" ruby-smie--redundant-do-p forward-word-strictly "&."] 7]()
  smie-next-sexp(#[nil "`\304`[!\210\305 V\203�\306 \203�\307\310w\210\311\202\351�n\203-�o\204-�\312`\313\"b\210\311\202\351�`V\203A�n\204A�\314!\203A�\315\202\351�\316 \317  \203O�\320\nP\n\321\235\203b�\322 \203^�\n\202\350�\323\202\350�\n\324\232\203~�\325 \203q�\326\202\350�\327 \203z�\330\202\350�\n\202\350�\331\n\310\332\333#)\266\203\203\230�\334u\210\n\334\310O\202\350�\n\335\232\203\264�`Sf\336=\203\264�\337\340!\203\264�\313u\210\341 \202\350�\n\342\232\203\335�\343 \204\303�\n\202\350�\212\344\334!\210\304d!\210`)\305 V\203\331�\341 \202\350�\311\202\350�\n\345\232\203\347�\320\202\350�\n*)\207" [pos dot tok inhibit-changing-match-data forward-comment line-end-position ruby-smie--implicit-semi-p "  " nil ";" scan-sexps -1 ruby-smie--args-separator-p " @ " smie-default-backward-token ruby-smie--before-method-name "." ("unless" "if" "while" "until") ruby-smie--bosp "iuwu-mod" "|" ruby-smie--opening-pipe-p "opening-|" ruby-smie--closing-pipe-p "closing-|" "\\`|[*&]\\'" t string-match 1 "" 92 looking-at "\n" ruby-smie--backward-token "do" ruby-smie--redundant-do-p forward-word-strictly "&."] 7] #[257 "o\203\f�\300\301\302``E\"\207\303!\207" [signal scan-error "Beginning of buffer" backward-sexp] 6 "\n\n(fn N)"] #<subr car> #[257 "\211A@\207" [] 2 2455217] ";")
  smie-backward-sexp(";")
  ruby-smie--redundant-do-p()
  ruby-smie--backward-token()
  ruby-smie--implicit-semi-p()

since the last three functions are from:

/usr/local/Cellar/emacs/25.2/share/emacs/25.2/lisp/progmodes

ruby-mode.el.gz

I do not know how to proceed from here. any advice will be appreciated. this only happens with routes.rb file. for example if now I close the buffer with routes.rb it will work again well

  • I recommend M-x report-emacs-bug. – Stefan Jun 17 '17 at 17:08
  • ok, I will try it – anquegi Jun 17 '17 at 17:19
  • sml/-this-buffer-changed looks out of place, but maybe it's a typo. – Dmitry Jun 17 '17 at 21:06
  • @anquegi Anyway, yes, please file a bug report, and attach an example file than exhibits this problem. – Dmitry Jun 17 '17 at 21:07
  • @anquegi And please leave a comment here when you file that report. – Dmitry Jun 18 '17 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.