eschulte / rinari

Rinari Is Not A Rails IDE (it is an Emacs minor mode for Rails)
http://rinari.rubyforge.org
GNU General Public License v3.0
412 stars 68 forks source link

open any c++ file, rinari willl always be launch #53

Closed redguardtoo closed 11 years ago

redguardtoo commented 11 years ago

It's because the find-file-hook. Here is your code.

;;;###autoload
(defvar rinari-major-modes
  (if (boundp 'rinari-major-modes)
      rinari-major-modes
    (list 'find-file-hook 'mumamo-after-change-major-mode-hook 'dired-mode-hook))
  "Major Modes from which to launch Rinari.")
purcell commented 11 years ago

Is your c++ file inside a rails project, or a directory which has a config/environment.rb?

redguardtoo commented 11 years ago

It's a pure C++ project. nothing else. Try to add (debug) and check the backtrace, for example

(eval-after-load 'ruby-mode
   '(progn
      (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
      (define-key ruby-mode-map (kbd "TAB") 'indent-for-tab-command)
      (debug)
      ))

This is the backstrace

  rinari-launch()
  run-hooks(find-file-hook)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer main_frame.cpp> "~/projs/dumbway/src/desktop/frontend/main_frame.cpp" nil nil "~/projs/dumbway/src/desktop/frontend/main_frame.cpp" (4255934 234881026))
  find-file-noselect("/Users/cb/projs/dumbway/src/desktop/frontend/main_frame.cpp" nil nil nil)
  find-file("/Users/cb/projs/dumbway/src/desktop/frontend/main_frame.cpp")
  command-line-1(("/Users/cb/projs/dumbway/src/desktop/frontend/main_frame.cpp"))
  command-line()
  normal-top-level()
purcell commented 11 years ago

Okay, I see what you mean. From what I know of rinari, this is intentional. Rinari works like a global mode; every file may potentially be inside a Rails project, so rinari-launch is placed in find-file-hook.

Is there an actual problem you're experiencing?

redguardtoo commented 11 years ago

As a C++ programmer, I usually use make or other build tool (cmake, bjam, just name a few) to compile. Set compile-program to rake is annoying because programming it becomes difficult (I've already tried). I just need an option that I could STOP the find-file-hook.

purcell commented 11 years ago

Right... but rinari doesn't override your compile-program...

redguardtoo commented 11 years ago

It does override. as you can see from the back trace. I set my compile-program in my cc-mode-hook which happens before find-file-hook. find-file-hook will rinari-launch which in turn loads ruby-mode. In eval-after-load ruby-mode I (setq compile-program "rake").

I suggest keeping hook find-file-hook for all the ruby developers by default. But give C++ programmer some flag to manually turn off that flag. This is actually not for C++ programmers. When I use Emacs do java, SQL, C#, javascript programming, same issue.

purcell commented 11 years ago

Erm, no - this is not the fault of rinari, and find-file-hook is an appropriate mechanism.

The eval-after-load block is the problem, and that block must be in your own code. I had a similar block in my .emacs.d, and I removed it. Perhaps you just need to merge my latest changes back into your emacs config?

redguardtoo commented 11 years ago

Yes, I will see your code this weekend.

On Tue, Nov 27, 2012 at 11:41 PM, Steve Purcell notifications@github.comwrote:

Erm, no - this is not the fault of rinari, and find-file-hook is an appropriate mechanism.

The eval-after-load block is the problem, and that block must be in your own code. I had a similar block in my .emacs.d, and I removed it. Perhaps you just need to merge my latest changes back into your emacs config?

— Reply to this email directly or view it on GitHubhttps://github.com/eschulte/rinari/issues/53#issuecomment-10756294.

help me, help you.

purcell commented 11 years ago

The commit you need to ensure you have merged is: https://github.com/purcell/emacs.d/commit/14b9d48a7f6fd3165714350070d85ffe325e2572

redguardtoo commented 11 years ago

Got. Thanks.