Questions tagged [find-file]
is the most frequently used command for opening files in Emacs.
171 questions
0
votes
1
answer
43
views
How can I prevent Helm from switching to root directory after typing forward slash?
I quite like the feature in helm-find-files where typing ~ takes me to my home directory.
What I don't like, however, is that typing / takes me to the root directory. I sometimes type this forward ...
1
vote
0
answers
33
views
How to place point at end of current filename when using find-alternate-file
Billions of years ago (maybe in emacs18) the behavior of C-x C-v (find-alternate-file) changed. The current behavior is described in the manual thus: "When C-x C-v reads the file name to visit, ...
1
vote
0
answers
45
views
"dual-mode" helper which opens _both_ .tar.gz _and_ .zip archives confusedly saved under the same file extension (say, `.yuppie`)?
So someone at my company years ago decided it was a good idea to create a company internal package format, say "yuppie" for yunified package. And that can randomly be tgz or zip archives. ...
0
votes
0
answers
19
views
counsel-find-file-ignore-regexp not ignoring files in search
I have the following in my config:
(setq counsel-find-file-ignore-regexp "\`[#.]\|[#~]\'")
which was taken straight from the documentation for counsel-find-file-ignore-regexp. However, they ...
0
votes
1
answer
85
views
Opening a .tex file under Emacs fails with a wrong-type-argument
I encountered a post (link follows) that led me to turn on the debugger:
What does it mean when emacs tells me "File mode specification error"?
I am attempting to open a LaTeX file called ...
0
votes
1
answer
35
views
find-file backslash causes searching
Using emacs on Windows. When I use find-file, when I have ido-mode set to t, if I type in a new path, e.g. w:\, then I get a message that says searching for 'w:\'... and a long pause followed by no ...
0
votes
1
answer
76
views
How to have 'emacs' behave like 'find-file' within vterm?
I know that such a thing is possible within eshell; however, I am now using vterm, and I'd like for when I type emacs for it to be as if I typed find-file.
For example, for eshell, you could do
alias ...
1
vote
1
answer
64
views
Run functions/hooks automatically when a specific FILE is opened
I'd like to run a function/set of functions when I open a specific file.
Just like file type hooks, but for a specific file.
For instance, when I open foo.bar, I'd like some functions to run.
Maybe ...
0
votes
1
answer
105
views
Opening file in emacs using a shortcut
So, I was wondering if I can somehow(with a keyboard shortcut) open a file using the default system dialog, the same way that the big open button does at the top of the window. I didn't find a way to ...
0
votes
1
answer
93
views
Faster way to go from directory bookmark to file heading?
I currently have a dired bookmark set to a directory. So in order to access a particular heading, the sequence is as follows:
Bookmarks keybind, type initial letters of directory bookmark.
(Dired ...
0
votes
2
answers
81
views
how to specify multiple file extensions and open it in separate buffer
To find files by multiple file extensions I use in Linux smt like this (in terminal):
find ./ -type f \( -iname \*.txt -o -iname \*.json \)
And here result:
./test.txt
./project_1_1/test.json
./...
0
votes
1
answer
26
views
Weird `(point-max)` in testing function in `magic-mode-alist`
Why does the below function always print 4001 when opening a large file?
(require 'cl-lib)
(defun custom-test-p ()
(with-current-buffer (current-buffer)
(print (point-max))) ; 4001
nil)
(cl-...
1
vote
1
answer
29
views
With icicle-locate-file, how can I find all *.txt files in the directory?
I need to find all *.txt files in the directory, like
find ./ -iname "*txt"
I wanted an Emacs solution, so I found the multi-command icicle-locate-file-other-window.
Its documentation tells ...
0
votes
0
answers
30
views
How can I find out that an Org Agenda file had been opened with 'inhibited startup'?
My Emacs is opening the Agenda file in the background with org-agenda-inhibit-startup locally bound to t. When I switch to such a file, all trees are therefore displayed open (no folding).
I would ...
0
votes
0
answers
134
views
"touch file" in dired mode
I found this answer:
(eval-after-load 'dired
'(progn
(define-key dired-mode-map (kbd "c") 'my-dired-create-file)
(defun create-new-file (file-list)
(defun exsitp-untitled-...
0
votes
2
answers
325
views
How preview find file without close minibuffer
Emacs 27.1
packages:
consult
embark
I want to find test.txt file in folder temp.
I do this.
Now I want to preview selected file without close minibuffer. In embark I'm not operation for this.
How I ...
0
votes
2
answers
201
views
How can I bind vertico-insert to toggle in the list?
I am using find-file with vertico. After running find-file and typing filename and when I press <TAB> it selects the current line.
TAB runs the command vertico-insert (found in vertico-map), ...
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
...
0
votes
0
answers
33
views
How to fallback to $HOME if Tramp failed to connect to default-directory
If I call find-file from a buffer with default-directory pointing to a remote server via TRAMP and the remote server is not reachable, then TRAMP complains:
tramp-signal-hook-function: Tramp failed ...
1
vote
1
answer
66
views
How can I make a window always show the same file buffer?
How can I force Emacs to keep a certain file in a particular window? For example, if I am editing a LaTeX file and there is a compile error, I want to inspect the error in another window. I ...
1
vote
0
answers
38
views
Configure Emacs to Respect Windows File Attributes?
Is it possible to configure Emacs under Windows to respect the 'hidden' and 'system' NTFS file attributes for example by filtering out these files during selection of filename completion candidates in ...
0
votes
1
answer
87
views
Disable environment variable substitution with $ in find-file
When using find-file, list-directory and other commands, if one types a $ a minibuffer completion appears with a list of currently set environment variables.
I have no idea where this is coded, the ...
1
vote
1
answer
177
views
ff-find-other-file
works well, particularly after custom defining additional file type pairs with
(defvar my-cpp-other-file-alist '(("\\.cpp\\'" (".hpp" ".cuh"))
...
0
votes
0
answers
98
views
How to automatically convert between remote and local file names?
I have /local/laptop/dir mounted in my Docker container at /container/path. In Emacs tramp terms, it is /docker:container-id:/container/path. This also comes up when the user ssh to a remote system ...
2
votes
0
answers
120
views
Ignore a directory most of the time with find file in project
I have a directory structure like this:
a
src
target
b
src
target
c
src
target
generated_source_files
x
y
z
When I run ffip, I usually want to ignore looking for files in ...
1
vote
1
answer
2k
views
Opening file in emacs buffer when using vterm
My current workflow is often to do things in a terminal and open/change relevant files in a text editor.
Transitioning from VSCode to Emacs I am looking for a similar workflow that I got used to when ...
3
votes
1
answer
644
views
Open file at startup from init file
I like that at start emacs visits a file with my todo list. For long time, this has been accomplished by adding (find-file "~/my-file.org") at the end of my configuration file (.emacs).
...
1
vote
1
answer
37
views
How to toggle `helm-ff-skip-boring-files` during file navigation with `helm-find-file`?
I'd like to be able, with a keystroke, to hide/show boring files during the file navigation in helm-find-files.
I defined a function
(defun mxl/toggle-helm-ff-skip-boring ()
(interactive)
(setq ...
0
votes
1
answer
76
views
How to force `find-file` to visit the existing frame of an opened file
The below function creates a new instance of the file myfile.txt (regardless of if myfile.txt is already opened or not).
How to force emacs to use the existing frame of that file (if any)?
(defun ...
0
votes
0
answers
196
views
Rewriting paths for bazel
The Bazel build tool has some features that interact poorly with emacs. When you build a C/C++ project for sandboxing purposes it makes a crazy hierarchy of symlinks, and uses them when invoking GCC. ...
1
vote
2
answers
128
views
Is there some Emacs command that behaves as readlink -f to print the full path of a especific file?
In the terminal, I can do:
$ readlink -f docker-compose.yml
Which outputs:
/home/pedro/projects/docker-stuff/docker-compose.yml
I would like to have something like that in Emacs so that I can find ...
0
votes
2
answers
87
views
Find-file, but instead of showing file-names to select, show file content (html tag)
I'm attending a conference, and I have downloaded all abstracts so I can read them offline. They are all html files with the same structure.
The files are numbered according to abstract submission ...
0
votes
1
answer
166
views
Open shell from find-file interactively
Currently, I can use C-x C-f to find-file (or ido-find-file) then open a dired directory and launch M-x shell.
Is it possible to interactively navigate a path be it a local ~/Documents or tramp shell ...
0
votes
1
answer
56
views
If `counsel-git` returns `Not in a Git repository`, can we run `find-file`?
I am using counsel-git to find files in my git repo. I have overwrite into default find-file's keybinding.
(global-set-key (kbd "C-x C-f") 'counsel-git)
If I am not in a git-repo, such as ...
2
votes
2
answers
234
views
Why does emacs recognize my wildcard with finding file but not with searching buffer?
In the linux terminal, i often use wildcards (*) as a shorter alternative to type in the whole file name: if the file is named foo-and-cats I just type in something like fo* in order to pull up the ...
0
votes
0
answers
45
views
Follow a file with row and column
How to make g f and/or find-file-at-point resolve file correctly in this format (gcc output)
main.c:123:31: ....
0
votes
2
answers
635
views
How to map keybindings to find-file?
How I can map keybindings to find-file since there is no
find-file-mode-map or something like that?
I am using the vertico minimalistic vertical completion UI.
0
votes
0
answers
223
views
open file specified via environment variable
Environment variables that points to specific location are of common occurrence. $HOME, $XDG_CACHE_HOME, %LOCALAPPDATA% and many more. It is pretty convenient to open files (and directories) just by ...
0
votes
1
answer
306
views
How to delete inserted directory names for `find-file` input?
I've been trying to figure out how to erase directories faster when I use find-file
in vanilla Emacs.
An example is Doom Emacs, you press backspace once, and erase the entire directory, but when I try ...
2
votes
1
answer
266
views
How to multi-word search
When I use swiper to search inside a buffer I can use multiple search words separated by a blank space. This works.
But I also want that behaviour when search for a file (C-x f), a variable or ...
2
votes
1
answer
3k
views
What's an easy way to do find file then fuzzy search by filename?
I am trying to learn emacs in order to use orgmode.
I came from vscode universe.
There's a Cmd+P in vscode that allows search by filename easily. Looks like this.
Then i can use cursor keys to go up ...
1
vote
2
answers
409
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 ...
0
votes
0
answers
563
views
How to open a file in the current window
This question feels almost too basic, but I can't seem to find it.
If you have two or more windows open in a frame, how do you open the file in the window that has your cursor?
ctrl-x ctrl-f opens it ...
0
votes
0
answers
355
views
How do I prevent find-file from filling in a file name?
Using spacemacs I usually open new files for editing with C-s C-f (for find-file), since that is recommended by this answer.
However I have an issue when the file I wish to open is both new (doesn't ...
0
votes
1
answer
116
views
Restore privileged folder access for previously working Emacs.app on Catalina (NOT system upgrade)
This is similar to How to Restore File System Access in macOS Catalina but the problem is different. I did not upgrade my operating system, only the app, and none of the solutions there are valid ...
2
votes
1
answer
228
views
C-x C-f TAB TAB: Find file completion list: how to highlight subdirectories?
Often I'd like to open a file in a subdirectory. But poor me, I can't remember the name. So when typing C-x C-f and then TAB TAB for the completion list, the list of all files in this directory is ...
0
votes
1
answer
500
views
Disable `icomplete` with Emacs `find-file`
I have been experimenting with various completion frameworks in Emacs. I am currently using consult together with icomplete. I like the way things are working for me but I would like to disable ...
2
votes
1
answer
1k
views
C-x C-f Problem:
When i want to create a new file with C-x C-f (ido-find-file), and type main.lua, Emacs does not create a new file in the current directory (default-directory). Instead, it visits an existing main....
1
vote
2
answers
123
views
How to open a file in other window in the middle of function run?
I use notmuch to read emails.
I've configured notmuch to call offlineimap via pre-new hook.
When I press G to refresh my notmuch buffer, I want emacs to open my offlineimap log file in another window ...
1
vote
0
answers
194
views
find-file-hook when visiting file literally
I'm trying to hook into find-file-literally to turn off some global minor modes when visiting a file literally (which I usually do for large files).
However, it does not appear that find-file-hook is ...