Questions tagged [find-file]
is the most frequently used command for opening files in Emacs.
18
questions
5
votes
2
answers
2k
views
Set a global default directory
I want a "default directory" which is constant across all contexts
(buffers, packages, etc). That is, when working on multiple files,
opening a new terminal, doing anything which requires a starting
...
52
votes
7
answers
19k
views
How to use an external program as the default way to open PDFs from Emacs?
When I M-x find-file a PDF, it is opened in Emacs. While this is nice, Emacs' PDF viewer lacks many features that I need and I would prefer to open PDFs in an external program instead. How can I ...
7
votes
2
answers
4k
views
Template for new file
When opening a new file of certain types, I would like some boilerplate to be inserted. That is, when opening a buffer for a file that does not yet exist, insert some predefined text, optionally with ...
4
votes
2
answers
4k
views
Setting default-directory does not change find-file directory
I try to set a default path for opening a file via C-x C-f by adding the following to my .emacs:
(setq default-directory "~/some_dir/")
However, after I launch Emacs in some directory, the find-file ...
3
votes
1
answer
1k
views
auto-insert a skeleton and run a function when creating a new file
auto-insert-alist by default matches files created in .../bin/ directories and enables sh-mode.
There are examples on the wiki showing how to use a skeleton to insert some text, but I want to both ...
13
votes
6
answers
3k
views
Recently opened files in ido-mode
I use ido-mode, but one thing I hate about it is that after C-x C-f I cannot use up/down keys to cycle through recently opened files, as it used to be for example with iswitchb. How can I set ido to ...
7
votes
2
answers
5k
views
How do I open a file in spacemacs?
Say I have spacemacs open and now I want to launch some sort of file browser to open a file. How do I do it?
I have found SPC f f which sort of works but the navigation is quite cumbersome. There is ...
7
votes
1
answer
774
views
How to check, if a file is already visited?
I have the following code, which opens a file, inserts some text, saves the file and closes it.
(defun batch (file)
(find-file file)
(end-of-buffer)
(insert "nix")
(save-buffer)
(kill-...
5
votes
4
answers
5k
views
Find file in directory
I switched to Org Mode and Emacs few weeks ago. I find it incredibly better than my previous (simple but effective) setup based on markdown files and VS Code editor.
I'm learning new features ...
5
votes
3
answers
1k
views
Load all org files into buffers?
I've got a couple dozen org files that I'd like to have loaded at once. They're in a directory structure something like this:
org/dev
org/dev/python.org
org/dev/emacs.org
...
org/dev/ios
org/dev/ios/...
5
votes
3
answers
638
views
Switch buffer to the file path in current cursor position
My .emacs file contains multiple file names as,
(load "~/.emacs.d/others/keymaps.el")
(load "~/.emacs.d/others/py.el")
(load "~/.emacs.d/others/web.el")
Is there a way any library, gives way for me ...
2
votes
2
answers
155
views
Instruct Emacs never to open files of a certain type or size
In Emacs by default there is a large file warning threshold. I would prefer to instruct Emacs never to open files of a certain type or size. These are files I would prefer always to open in an ...
2
votes
1
answer
4k
views
C-x C-f results in the error message: "Wrong type argument: commandp, counsel-find-file"
I opened Emacs, and executed C-x C-f. A beep sounded and the following message appeared in the status line:
Wrong type argument: commandp, counsel-find-file
All I wanted was to open an existing file....
1
vote
1
answer
44
views
Write a function that prompts for a file from within a list
As a starting point, this:
(defvar myfoo "~/org/test-file-1.org" "myfoo") ; C-x C-e
(defun mybar()
(newline-and-indent)
(insert-file-contents myfoo)) ; C-x C-e
(mybar) ; C-x C-e
...
1
vote
2
answers
388
views
grep contents of a set of files from find
I want to grep contents of all CMakeLists.txt files in a project (nested within a directory) so I can jump from each instance, like I would when running emacs grep function. In the examples below I'm ...
1
vote
0
answers
499
views
Emacs 26-1 Problems : find-file and neotree
The Problems:
I just did a full re-install to Fedora 29, which included the dnf install emacs
command. This installed emacs 26-1; formerly I was using emacs 25.2. Formerly,
my emacs initialization ...
1
vote
1
answer
389
views
How to create a file from a template if it does not exist or open existing copy?
Trying to make a function that I can call to create a file from a template or open an existing file. Current attempt is as follows:
(defun journal-entry ()
(interactive)
(let ((daily-name (format-...
0
votes
1
answer
134
views
How to pass the result of yank to find-file?
So I wanted to basically copy the current selection, then yanking it into find-file, as when using:
C-SPC: set-mark-command
M-w: kill-ring-save
C-x C-f: find-file
C-y: yank
While that works great, I ...