I am using emacs on windows. I would like to know how to change the default "Find File:" path in emacs i.e. When we press "C-x C-f" I want the default file path to point to my Documents directory and not to "c:\emacs-**\bin/".
Variable 'default-directory' is the "current" directory (for the current buffer). Command 'cd' changes directories, and visiting any file or directory (e.g. with Dired) changed the 'default-directory' for that buffer. You can start Emacs in a given directory, by passing that directory on the command line.
C-x C-f, find-file, the most basic of ways to open a file in Emacs (see find-file ), has many hidden features. Emacs shows the default directory (variable ‘default-directory’ ), like this: Now type /bin, that is, don’t bother to first erase /usr/local/info/: Voila!
FindFileAtPoint. Find File at Point ( ffap .el) is a builtin Emacs library, created by MichaelangeloGrigni, for opening a filename or URL at point. The basic features are described in the Emacs manual ( ffap ). There’s various mode-specific features hiding in ffap, CcMode and FortranMode header filenames like <stdio.h>.
‘C-x d’ opens DiredMode, giving you access to all of the files in the current directory. But you can also open Dired using ‘C-x C-f’. Just hit ‘RET’ to accept the default directory that appears after the prompt, or type another directory. In Emacs versions prior to 22, you need to delete the last slash from a directory name before hitting ‘RET’.
This shall do it:
(global-set-key (kbd "C-x C-f") (lambda () (interactive)
(cd "somePathHere")
(call-interactively 'find-file)))
(replace somePathHere with the path to your documents directory)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With