Questions tagged [find-file]

is the most frequently used command for opening files in Emacs.

Filter by
Sorted by
Tagged with
0 votes
1 answer
20 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-...
Saddle Point's user avatar
1 vote
1 answer
26 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 ...
Jason Hunter's user avatar
0 votes
0 answers
16 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 ...
Public Image Ltd.'s user avatar
0 votes
0 answers
32 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-...
user129393192's user avatar
0 votes
2 answers
87 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 ...
a_subscriber's user avatar
  • 3,874
0 votes
2 answers
94 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), ...
alper's user avatar
  • 1,238
1 vote
1 answer
40 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 ...
user avatar
0 votes
0 answers
17 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 ...
Thomas Koch's user avatar
1 vote
1 answer
28 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 ...
user5728491's user avatar
1 vote
0 answers
24 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 ...
StackExchanger's user avatar
0 votes
1 answer
46 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 ...
Ojd2000's user avatar
0 votes
0 answers
10 views

helm-find-files wants to send email when C-x C-f on word containing @

When the point is on a word containing the @ character, helm-find-files thinks I want to compose an email. For example, if the word under the point is foo@bar then it prompts me to go into message ...
Tom Ellis's user avatar
  • 101
1 vote
1 answer
70 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")) ...
CD86's user avatar
  • 543
0 votes
0 answers
48 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 ...
pedz's user avatar
  • 365
2 votes
0 answers
41 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 ...
Troy Daniels's user avatar
1 vote
1 answer
697 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 ...
Johannes Nauta's user avatar
3 votes
1 answer
308 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). ...
Massimo2013's user avatar
1 vote
1 answer
28 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 ...
MassimoLauria's user avatar
0 votes
1 answer
58 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 ...
Name's user avatar
  • 7,709
0 votes
0 answers
86 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. ...
Joseph Garvin's user avatar
1 vote
2 answers
89 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 ...
Pedro Delfino's user avatar
0 votes
2 answers
50 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 ...
Daniel's user avatar
  • 3,563
0 votes
1 answer
103 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 ...
phoxd's user avatar
  • 231
0 votes
1 answer
31 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 ...
alper's user avatar
  • 1,238
2 votes
2 answers
170 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 ...
thinksinbinary's user avatar
0 votes
0 answers
28 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: ....
andreoss's user avatar
  • 149
0 votes
2 answers
415 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.
EasterEgg's user avatar
0 votes
0 answers
173 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 ...
ivan golotin's user avatar
0 votes
1 answer
147 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 ...
EasterEgg's user avatar
1 vote
1 answer
173 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 ...
buhtz's user avatar
  • 689
1 vote
1 answer
2k 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 ...
Kim Stacks's user avatar
1 vote
2 answers
241 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 ...
Spacemoose's user avatar
0 votes
0 answers
418 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 ...
rileymat's user avatar
  • 101
0 votes
0 answers
153 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 ...
Éamonn Olive's user avatar
0 votes
1 answer
88 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 ...
nate's user avatar
  • 63
2 votes
1 answer
143 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 ...
Keks Dose's user avatar
  • 508
0 votes
1 answer
354 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 ...
Edman's user avatar
  • 1,167
2 votes
1 answer
823 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....
oleg harput's user avatar
1 vote
2 answers
106 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 ...
SparedWhisle's user avatar
1 vote
0 answers
122 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 ...
Tianxiang Xiong's user avatar
1 vote
2 answers
143 views

How can I make sure that Emacs opens files with extension `*.rec` as normal text files?

How can I make sure that Emacs opens files with extension *.rec as normal text files? When I try to open a file with the extnsion *.rec, I get the error message Running someFile.rec...done without the ...
Glory to Russia's user avatar
2 votes
1 answer
68 views

Multi-directory tab completion for find-file?

I am frequently diving through many layers of directory hierarchies (thanks, Java) to find files named like this… java/test/com/company/thing/test/testy/testier/testier/Tester.java The main issue ...
Dan Lenski's user avatar
0 votes
1 answer
1k views

dired by name - change directory and create new file

I want to open a new file in a different directory than the current one. Pressing C-x C-f -> I could enter a file name. But I don't. Pressing RET The directory listing (mode (dired by name)) comes ...
buhtz's user avatar
  • 689
2 votes
2 answers
136 views

completion-ignored-filenames?

Is there a way to do ignore whole file names the same way as 'completion-ignored-extensions' ignores filename extensions? For example, I would like to blacklist __pycache__/, so that if the default ...
toomas's user avatar
  • 183
0 votes
0 answers
475 views

Windows File open SLOW

Windows 10 Emacs 27.1 From C-x C-f File Till seeing the file actually open can take almost a minute! Tried emacs instead of runemacs. Also Menu-file-visit All the same I think there's some Mcafee ...
Rusi's user avatar
  • 329
1 vote
1 answer
106 views

Global `C-x C-f` binding is overridden

I don't like ido-find-file, which seems to be the default response to C-x C-f in my Emacs 23.1.1 installation on Centos. I tried to change it in my .emacs file: (global-set-key (kbd "C-x C-f"...
Steve's user avatar
  • 11
1 vote
1 answer
366 views

C-x C-f, Cannot complete file name for desktop folders

I am new to Emacs. I am trying to access a file in the "Emacs" folder on my desktop. I run the C-x C-f command, then type ~/Desktop/Em. I then hit TAB, but there's no completion. Emacs says [...
finite_diffidence's user avatar
4 votes
1 answer
414 views

Don't show "." and ".." in counsel-find-file

I have a thing where I just don't like editing directories in emacs, and I never want to enter dired mode. Any time anything might want to put me into dired mode, I would prefer it not do that and ...
MadScientist's user avatar
0 votes
2 answers
231 views

Unable to find files with ssh and environment variables

I have installed exec-path-from-shell as well as included the following in my init.el (when (memq window-system '(mac ns x)) (exec-path-from-shell-initialize)) within my ~/.bash_profile I have ...
Tian's user avatar
  • 288
0 votes
1 answer
40 views

Open folder in emacs and type name to match file

I have this line in my init.el: (global-set-key (kbd "C-c g") (lambda() (interactive) (find-file "~/Dropbox/myorgfiles"))) So when I type C-c g I get the directory contents of the ...
Emmanuel Goldstein's user avatar