Questions tagged [files]

Use this tag for questions about moving, deleting, or opening files. Or for questions about the difference between a buffer and its file. For topics such as "Saving Files", use "buffers" instead.

Filter by
Sorted by
Tagged with
0 votes
0 answers
8 views

Combined search: notmuch mail, org-mode docs, and filesystem locate?

I often look for information that could be either in some org-mode document, in an old email, or somewhere in the file system (and probably other places). Now I can use org-search, notmuch-search, ...
Ketil Malde's user avatar
1 vote
0 answers
37 views

What causes "file changed on disk; really edit the buffer?" for files on a network share?

What causes "file changed on disk; really edit the buffer?" for files on a network share? I edit files on an SMB share and I get constantly this question: "changed on disk; really edit ...
Jason Hunter's user avatar
1 vote
2 answers
140 views

How to make buffer recognize file moved?

Here's a simple use case: I open bar/foo/file in a buffer and I'm working. In eshell, I do mv bar/foo/file bar/baz/foo/file. Now emacs can no longer recognize where to save and doesn't save it ...
user129393192's user avatar
2 votes
1 answer
40 views

Function load raises error on loading an existing file

I started getting an error on loading theme files and tracked it down to the (load) function being called by (load-theme). I tried to isolate the problem with the following test function and am still ...
Daniel Doherty'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
3 answers
60 views

How to delete all the files matching regular expression in elisp?

I want to make some clean-up with auto-generated files. How can I delete all the files matching some regexp mask from within elisp? As an example of desired functionality... Something like the line ...
martinoidar's user avatar
0 votes
2 answers
77 views

How can I interactively replace text in all files in all subfolders?

Emacs 27.1 Linux Mint 21 I have text modifyNetwork in 50 files in differents folders. I need to replace them by text performCommand. What is the easiest way to replace text in all files in all ...
a_subscriber's user avatar
  • 3,874
2 votes
2 answers
50 views

Creating scratch R files

Often I want to create a temporary R file and don't want to save the file or name the file. Is there a way to achieve this outside of using C-x C-f and naming a file? For example, in VSCode or Rstudio ...
cdd's user avatar
  • 195
0 votes
1 answer
30 views

Recent Files on Removable Media (There's no such thing)

Whenever I edit files on removable media, these files disappear from the recent files list, when I remove the media. When I reinsert the media, I have no recent files for that medium and I have to ...
Jason Hunter's user avatar
0 votes
2 answers
60 views

Edit File on USB :: umount Target is busy

If I insert a USB drive and edit a file on it, then kill the buffer, I have to wait atleast five minutes before I'm able to umount the drive $ sudo umount /dev/sdl1 umount: /mnt/sdl1: target is busy. ...
Jason Hunter's user avatar
0 votes
1 answer
40 views

Close File, Still in Use

I have a problem, where after I edit a file on a USB stick and close the file with C-x k, Emacs still has a grip on the file until this message appears a few minutes later: Debugger entered--Lisp ...
Jason Hunter's user avatar
1 vote
2 answers
81 views

How to indicate in the mode-line that current-buffer's file has changed on disk?

How can I show if a file has changed on disk, in the mode-line? (I'm trying to troubleshoot why auto-revert doesn't work for me, and such an indication would help.)
Jason Hunter's user avatar
2 votes
1 answer
47 views

FILE(s) Passed by Shell to Emacs to Visit

The FILE mentioned in the title, is what in $ emacs FILE or $ emacs -file FILE or something else similar. How do I know whether there’s a FILE / FILEs set for Emacs to visit at startup? If there’...
shynur's user avatar
  • 4,247
0 votes
0 answers
32 views

Visit New File doesn't create new directories

Maybe I am completely misremembering but I am sure that Emacs used to create missing directories when using Visit New File command. Let say that ~/Documents exists. And I want to create a new file in ...
mislyde_alfabetisk's user avatar
2 votes
1 answer
283 views

How do I hide the welcome screen if and only if one or more files are opened by emacs upon startup?

Right now, if I do "emacs foo1 foo2" emacs will open with foo1 and the welcome screen showing in two windows splitting the frame vertically. Instead, I want to be shown foo1 and foo2. ...
Thomas's user avatar
  • 21
0 votes
2 answers
19 views

`rename-file` into a different filesystem which does not support permissions

I'm running emacs under WSL 2, in which Windows drives are mounted below /mnt/<Drive Letter> with 9p as the filesystem. That filesystem does not support (setting) permissions on files. I want to ...
Lukas Barth's user avatar
0 votes
1 answer
81 views

How to comment out multiple or all files in a directory?

I frequently use commands like paredit-comment-dwim, comment-dwim, and comment-region. I am also aware these commands can have a compound effect with the mark command. But, I would like to comment ...
Pedro Delfino's user avatar
0 votes
1 answer
28 views

In Magit, is it possible to know when an unstaged change happened? How to find that information?

I have a repository under version control and I am using Magit as an interface to git. I can see one unstaged change in a file after executing magit-status (C-x g). This means the file was changed and ...
Pedro Delfino's user avatar
1 vote
1 answer
20 views

Is it necessary to save buffers as files in order to use command highlight-compare-buffer?

Based on a nice comment from @Drew on this previous question, I tried to use the command highlight-compare-buffers (although he did not mention exactly this comment). My first attempt was actually ...
Pedro Delfino's user avatar
2 votes
1 answer
32 views

How can I ignore non-existing files in a fixed custom tags-search?

I want to search through a fixed set of files and I use the tags-search command for it: (defvar my-files-form '(list "/path/to/one/file" "/path/to/another/file")) (...
halloleo's user avatar
  • 1,291
1 vote
1 answer
50 views

How to comment or uncomment the same lines of code in multiple files at once?

Suppose you have multiple files which has common lines of code or common matches of a regexp pattern. Is there an "emacs way" to comment/uncomment such specific common lines at once in all ...
Julia's user avatar
  • 141
3 votes
1 answer
162 views

Organizing images in emacs

There is image-mode and image-dired, but if you want to do anything except sequential viewing, they become clunky quickly. And they are slow for good quality photographs. I would like to be able to go ...
xeruf's user avatar
  • 324
0 votes
0 answers
29 views

Turn directory to file in dired

I often make the mistake of creating a directory instead of a file in Dired (by hitting +). I then have to delete it and recreate the file, with the same name. Sometimes, I tried to edit the d file ...
smonff's user avatar
  • 1,575
0 votes
1 answer
18 views

read-file-name: input an non-existing file with a default name in ido

I'd like to ask to the user where to save a .png file, where I provide some defaults, like: (read-file-name "Picture name:" "/tmp" "mydefaultname.png") (ideally in a ...
tobiasBora's user avatar
1 vote
1 answer
95 views

Function that determines and returns the programming language of a given file

I'm working on some compiler shortcuts: I want to write a function (cmp FILE-NAME &optional args) that will use FILE-NAME and args to construct the appropriate COMMAND to call (compile COMMAND) ...
andy_programs's user avatar
0 votes
1 answer
61 views

Option similar to `vc-directory-exclusion-list` but for files create by build tools

I'm missing an option variable similar to vc-directory-exclusion-list that holds of a list of auto-generated directory names that contain temporary files that are typically but not exlusively created ...
Nordlöw's user avatar
  • 487
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
1 vote
0 answers
54 views

How to open file with it being editable but not writeable?

I teach, and I like to use real files as examples in class. I want to be able to edit the buffer to show student things, but I don't want to risk accidentally writing the changes on the file. What I ...
elPolloDiablo's user avatar
3 votes
1 answer
340 views

Tramp mode - Copying files

when copying files in tramp mode via ssh with Dired I am not able to do anything else in Emacs. Emacs is just not usable till this process has finished. Is there any way to use Emacs while it copies ...
cptflint's user avatar
  • 131
0 votes
0 answers
27 views

Introducing functionality stored in a file into another file defining a minor-mode

I am debugging a minor-mode and have split the file into two files. How would one introduce the functionality in the second file into the minor-mode file? I have my minor-mode called rk-bracemarks ...
Dilna's user avatar
  • 1,183
0 votes
1 answer
33 views

Being in *shell* buffer, is it possible to open a file with the current Emacs application from a shell command?

After executing the shell command, I have a shell buffer inside Emacs. After executing classic ls -l, there is a file listed that I want to open in Emacs: [pedro@system:~/projects/career-opportunities]...
Pedro Delfino's user avatar
1 vote
1 answer
191 views

How do I get org-todo-list to see changes I made outside of local emacs?

I sync my org files between multiple devices with a Dropbox-like service. When a change is synced to a computer1 that already has Emacs running, org-todo-list subsequently shows stale headings. I am ...
billkw's user avatar
  • 111
1 vote
1 answer
37 views

How to set the file-permissions of a buffer before it's written?

Is it possible to set the permissions on a buffer before it's written to a file? Or is it necessary to change the permissions after writing it? (technically this would allow some small time-frame for ...
ideasman42's user avatar
  • 8,405
2 votes
0 answers
64 views

How to save a Slime Debugger buffer into a file, preserving all its data?

I am using Common Lisp, SBCL, Emacs, and Slime. Often, an error will happen while programming. When an error occurs, Slime opens a Debugger buffer. Sometimes, I would like to save this debugger buffer ...
Pedro Delfino's user avatar
0 votes
0 answers
45 views

Are there any low-level functions for reading files in elisp?

I am looking for something equivalent to this in Python f = open('2021-11-10.org') print(f.readline()) I know you can insert the file-contents into a buffer and do something like this, but that is ...
John Kitchin's user avatar
  • 11.6k
0 votes
0 answers
95 views

Detect whether a file is "binary" from elisp

I am wondering whether current versions of Emacs have any built in mechanism for guessing whether a file (that my elisp code is about to load, or perhaps has just loaded, into a buffer) is 'binary' ...
zwol's user avatar
  • 272
0 votes
0 answers
115 views

Show progress bar for long operation?

Linux Mint 20.2 Emacs 27.2 When I do some long operation not show progress bar. Is it possible to show progress bar in this situation? Examples of long operations: Copy many files Copy big files ...
a_subscriber's user avatar
  • 3,874
1 vote
2 answers
53 views

How can I write holiday list to a file?

In Emacs I can evaluate the following to get a list of holidays: (list-holidays 2020 2021) But I need to have the list written to a file. I have tried this: (progn (list-holidays 2020 2021) (write-...
Sofia's user avatar
  • 11
2 votes
1 answer
282 views

Import thousands of text files into org-mode

I have a folder with 3000+ txt files (made in nvALT originally) that I would like to import into an org-mode file. Preferrably I would like each file name to become a header in the org-file. The order ...
trmdttr's user avatar
  • 233
1 vote
0 answers
53 views

How to rename files to numbers in Eshell?

List of files: $ ls -1 *.jpg IMG_20210909_0003.jpg IMG_20210909_0004.jpg IMG_20210909_0005.jpg IMG_20210909_0006.jpg IMG_20210909_0007.jpg … I want to rename these files to 1.jpg, 2.jpg, …, and I ...
feklee's user avatar
  • 1,039
2 votes
0 answers
145 views

global-auto-revert-mode with confirmation first?

I know I can use (global-auto-revert-mode 1) to automatically revert a buffer if the buffer has been changed in another editor. However, when Emacs detects (automatically) that the buffer has changed, ...
user90726's user avatar
  • 173
0 votes
1 answer
41 views

How to prevent copy-directory from choking on Unix socket files?

I need to copy a directory tree that holds Unix socket files somewhere inside. As Unix sockets cannot be copied, when I use copy-directory, the copy-file function used by copy-directory throws an ...
PRouleau's user avatar
  • 754
2 votes
0 answers
60 views

Is there a predefined way to detect if a file is a Unix socket?

Are there predefined Emacs functions to check if a file is a Unix socket? The best I could come up with is the following code. (defun socket-p (fname) "Return non-nil if FNAME is a Unix Socket, ...
PRouleau's user avatar
  • 754
1 vote
1 answer
244 views

Open the directory of currently opened file using the OS's file explorer

This is essentially the same question as this one. But the accepted answer there opens Dired for me in Emacs 28 while previously it opened Caja. Could someone offer a fix? I tried commenting there but ...
scribe's user avatar
  • 950
3 votes
2 answers
426 views

How can I open an org file at a specific header postion via a command line?

I wan't to be able to programmatically open a file in org mode and scroll to a specific header. the file is quite big, so opening the file at a certain place is qhat I am looking for. Any idea how to ...
kipkipe's user avatar
  • 43
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
1 vote
1 answer
42 views

Tramp with Dired produces unwanted //DIRED// line

Connected via Tramp to an old remote system, when I list a directory using Dired, I get: /plink:[email protected]:/tmp: total used in directory 549 available 114.7 MiB drwxrwxrwt 3 root ...
feklee's user avatar
  • 1,039
4 votes
0 answers
2k views

Emacs won’t access Documents directory on MacOS Big Sur

I am running Emacs 26.3 on MacOS 11.2.1 “Big Sur”. When I try to open the directory ~/Documents, it fails with the message “Listing directory failed but ‘access-file’ worked.” Emacs.app is given ...
Mikelis Bickis's user avatar
0 votes
1 answer
58 views

Filtering list of files to those recently edited

Suppose I have a list of files: (setq files '("/path/to/file1" ...)) Is there a way to reduce this list to only those files which were edited within the past, say, 10 days?
George's user avatar
  • 879
5 votes
1 answer
129 views

Deleting a file with name that already exists in Trash

I use delete-by-moving-to-trash to move deleted files and folders into trash instead of deleting them. However, if the file or folder with the same name is already in Trash I get an error file already ...
Navidot's user avatar
  • 732

1
2 3 4 5 6