Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can we open up a file in emacs with a given mode (e.g. for90-mode) from the command line? I want to start this way from a script (bash) function.

share|improve this question
1  
emacs usually accept the -e option that causes it to evaluate its arguments as elisp expressions. You could use this to evaluate an expression that switches to a specific mode and then opens a file (or the other way around). – Claudius Nov 13 '12 at 17:23

Use the -eval option to run whatever commands you want.

For example, this opens emacs in the terminal, opens a new named buffer, and switches to ruby-mode:

emacs -nw -eval '(progn (switch-to-buffer "new_script") (ruby-mode))"
share|improve this answer

If your filename is named correctly (usually the extension) then auto-mode-alist should handle this for you.

If needed you may need to add to auto-mode-alist in order to make for90-mode be the one that is started for you.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .