Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.