Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs "Find File:" default path

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/".

like image 459
Shishir Pandey Avatar asked Jun 24 '11 05:06

Shishir Pandey


People also ask

How do I change the default directory in Emacs?

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.

How do I open a file in Emacs Find-File?

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!

What is findfileatpoint in Emacs?

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>.

How do I open diredmode in Emacs?

‘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’.


1 Answers

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)

like image 185
loudandclear Avatar answered Sep 30 '22 22:09

loudandclear