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
0answers
17 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' ...
0
votes
0answers
20 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 ...
1
vote
2answers
26 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-...
11
votes
5answers
3k views

How do I search and replace over a set of files?

I'd like to define a set of files within which I can search and replace text. To clarify: I would like to be able to search, e.g., in all files xk*.tex in a given directory (and excluding backup ...
2
votes
1answer
176 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 ...
1
vote
2answers
708 views

Open file in orgmode with external application. Check if file exists and create file from template if necessary

I want to create a file with org-open-at-point from a template if that file does not exist. If it exists, I want to open it in an external app. In org-mode, file-links are created by [[file:path-to-...
1
vote
1answer
113 views

Manage freedesktop trashcan with dired mode

Trashed files are stored in the FreeDesktop standard location: ~/.local/share/Trash/files. How do I restore or permanently delete files in that folder using dired?
1
vote
0answers
46 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 ...
8
votes
2answers
1k views

How to split a long org file into separate org files?

I've an huge org file HUGE.org with this structure: * ID-HEAD-1 Title1 :TAG: bla bla bla * ID-HEAD-2 Title2 :TAG: bla bla bla ... * ID-HEAD-N TitleN :TAG: bla bla bla and I want to split HUGE.org ...
0
votes
1answer
711 views

Test file permissions in Windows

The file-writable-p docstring says: Return t if file FILENAME can be written or created by you. In Windows you cannot usually write on files when they are used by a different app. In these ...
14
votes
2answers
811 views

Display recursive folder sizes in-line in dired?

I'd like to display the recursive size (the value that would be reported by du) of folder contents in-line in the dired buffer as an additional column or in place of the directory file size. Is this ...
2
votes
0answers
28 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, ...
1
vote
0answers
287 views

How to mount/unmount devices?

I'm interested in mounting/umounting usb and other devices directly from emacs. In many file managers (like nautilus) the devices are automatically discovered and indicated with an icon, it's possible ...
1
vote
1answer
43 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 ...
2
votes
0answers
43 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, ...
5
votes
1answer
528 views

Drag-and-drop file does not work anymore

Using Emacs 24.5 on a Gentoo/Kde workstation. Drag-and-drop of files used to work okay (as far as I remember), to open a new buffer on the dragged file. Same behaviour when using emacs -Q. It does ...
0
votes
1answer
30 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 ...
0
votes
2answers
49 views

How to automatically create another file that matches a regex based on a file created?

Suppose I create a file in dir1/file1.txt. As soon as I write the file for the first time, I want to create another file in dir2/file1_friend.txt. But when I create a file dir1/file2.txt, I want the ...
2
votes
2answers
136 views

Save current file with a slightly different name in Helm

This is the same question as Save current file with a slightly different name, but for Helm. (The top answer given for the original question doesn't work in Helm, sadly: M-n (next-history-element) ...
3
votes
1answer
115 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 ...
1
vote
1answer
32 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:user@example.com:/tmp: total used in directory 549 available 114.7 MiB drwxrwxrwt 3 root ...
0
votes
1answer
34 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
0answers
941 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 ...
0
votes
1answer
27 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?
7
votes
2answers
2k views

Saving open file list and buffer command history in between sessions

I've discovered desktop-save-mode which allows Emacs to be closed and when it reopens, it appears with the same files that were open before. I want to take this a bit further and I was wondering if I ...
4
votes
1answer
54 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 ...
2
votes
2answers
107 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 ...
0
votes
1answer
48 views

How to write a portion of text from current file to the beginning of another file?

I have written a function that extracts a portion of text from current file and writes it in another one: (defun foobar () (interactive) ;; re-search "beg" point ;; re-search "...
2
votes
2answers
2k views

How to toggle neotree in the project directory?

There is a nice example of how to open neotree in the project rootsee: https://www.emacswiki.org/emacs/NeoTree (find-file-in-project and Projectile sections). However, I'd like to toggle neotree, so ...
3
votes
2answers
677 views

How to open multiple files in multiple windows at startup

In earlier versions of emacs one could use emacs -nw file1 file2 file3 and see three files (and no buffer list) at startup. For recent versions this no longer works. Is it possible to add some code to ...
1
vote
1answer
120 views

open multiple files in tabs from command line

Emacs-27.1 ships with a new tab-bar-mode minor mode. This puts a tab bar at the top of each Emacs frame. Each tab in the tab bar can display multiple windows. Is there any way to invoke Emacs from the ...
5
votes
2answers
1k views

Get filename from dired using elisp

Using elisp, I call this function (dired "~"), for example, to get to my Home directory in dired mode. When I press RET on one of the files, I want to capture the file path and store it in a variable ...
3
votes
2answers
305 views

move file associated with open buffer to a specific folder

For a long time I've been using this function (originally made by Steve Yegge) to move files in emacs. This lets the user move the file associated with the currently open buffer to a different folder ...
0
votes
1answer
64 views

Search for file content with swiper-all or similar interface

I've been using swiper-all to search for content in buffers. This works really great as I easily can navigate between the files and select the ones I want to work with. Is there some way I can use a ...
1
vote
2answers
202 views

Save place in files but don't move the cursor to the saved position automatically

I'd like to have a command that moves the cursor to the last position it was in when I left the buffer (either by killing it or by killing Emacs). I know I can use saveplace.el to save the position ...
2
votes
2answers
70 views

Ignore both uppercase and lowercase versions of the extensions listed in completion-ignored-extensions

How can I get Emacs to ignore, say, both .pdf and .PDF files without listing both ".pdf" and ".PDF" in completion-ignored-extensions?
0
votes
0answers
73 views

Setting up Emacs as an external editor on windows 10

Apologies if this has been asked multiple times already, haven't found a useful answer. I am trying to use Emacs as an external editor on two separate applications in windows 10, one is a notes app (...
2
votes
1answer
235 views

How do I save raw bytes into a file?

I'm trying to make a .wav file generator in Emacs Lisp. I have some binary data, as a sequence of bytes: (setq binary-data (list 62 236 60)) I would like to insert that data into a file. I expect ...
14
votes
5answers
5k views

Ivy disable completion for a command in minibuffer

Can I disable ivy completion for a single command while in minibuffer? For example I am in folder ~/code/study/ . If I open find file and autocomplete with Ivy I will see Find file: ~/code/study/ ./...
0
votes
1answer
101 views

reverse buffer order

I open Emacs from the command line to inspect 10+ files, say like this: emacs *.java However, all the files are listed in reverse order. This is getting kind of annoying--I'd like to start with the ...
17
votes
8answers
6k views

Recursively list all files and sub-directories

Is there a way, possibly using a package, to recursively list all the files (with paths) and sub-directories (or at least the empty sub-directories, since the paths to the non-empty ones can be ...
1
vote
1answer
111 views

Function `cd` not working correctly in conjunction with `tramp` and `compile`

For context I am looking at a remote file; for example: /ssh:desktop:/home/user/project/src/file.cpp. I then issue the interactive command compile like so: cd /ssh:desktop:/home/user/project/Release &...
4
votes
2answers
817 views

How restore file from trash?

Windows 10, Emacs 25.1 In my init.el I set: delete-by-moving-to-trash t So as result when I delete file it move to trash. Nice. But how I restore delete file from trash by Emacs?
1
vote
1answer
579 views

Always open new files in the same window

When I open a file externally - through the terminal or the file manager GUI, it opens in a new window. How can I always open a file in a new buffer of an existing emacs session?
1
vote
1answer
40 views

Relationship between frame, buffer, and file

I am trying to check how frame, buffer, and file work. It seems to me that frame commands(C-x 5 ...) create a frame, whether a buffer or file exists or not. Here is what I am thinking: C-x 5 2 1. ...
6
votes
1answer
826 views

How to prevent creating files starting with .# (lock files)?

Emacs 26 I have a file rest.api.rc. When I start editing it, the following lock file is automatically created: .#rest.api.rc After saving file rest.api.rc, the lock file .#rest.api.rc is gone. How ...
4
votes
1answer
425 views

Read first N lines of file into list

The general way this seems to be done using Elisp is to first read the entire file using something like insert-file-contents-literally or find-file-no-select, using split-string on a newline, and then ...
1
vote
1answer
93 views

Reading a list of string from a .txt file

I have a file, myfile.txt, whose content is: (query-replace "foo" "Hello" nil (point-min) (poin-max)) and this function: (defun comment-string-from-file () (interactive) (let ((STRING (with-...
1
vote
1answer
65 views

How to tweak dired-create-empty-file to facilitate the easy creation of files

I currently have bound the command dired-create-empty-file to f7. Emacs then prompts me for a file name. When I press f7 I would like Emacs to automatically create an ORG file and automatically ...
1
vote
1answer
1k views

Disk interaction occasionally extremely slow

I'm using GNU Emacs 24.5.1 (i686-pc-mingw32) of 2015-04-11 on LEG570 on Windows 7. Somedays (yes, weirdly, it seems to be only some days), Emacs takes a very long time (a few seconds) when reading or ...

1
2 3 4 5