How can I have emacs start and be in the middle of a command input? Particularly, I want emacs to start in the middle of a command input find-file
with a message in the small buffer saying:
Find file: ~/
and the cursor at the last character of it so that I can continue typing the remaining path to open the file I want.
I have to admit that my lisp is a bit rusty, but this works for me. Drop it in your ~/.emacs
file (or whatever init file you are using):
(add-hook 'emacs-startup-hook
(lambda ()
(if (= (length command-line-args) 1)
(call-interactively 'find-file))))
If you call emacs
with no arguments, like this:
sawa@localhost:~$ emacs
It will invoke find-file
for you. If, on the other hand, you invoke emacs
with an argument, such as a filename, like this:
sawa@localhost:~$ emacs somefile.txt
It will default to just visiting somefile.txt