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
35 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 ...
0
votes
0answers
22 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
24 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
31 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-...
2
votes
1answer
188 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
0answers
48 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 ...
2
votes
0answers
30 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, ...
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 ...
2
votes
0answers
44 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, ...
1
vote
1answer
44 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 ...
3
votes
1answer
121 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 ...
0
votes
1answer
41 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 ...
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 ...
2
votes
0answers
1k 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?
4
votes
1answer
57 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
140 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) ...
0
votes
1answer
49 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 "...
1
vote
1answer
132 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 ...
0
votes
1answer
75 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 ...
0
votes
0answers
78 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
263 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 ...
0
votes
1answer
113 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 ...
1
vote
1answer
118 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 &...
1
vote
1answer
630 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
42 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
892 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 ...
1
vote
2answers
762 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-...
4
votes
1answer
456 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
98 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
69 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 ...
0
votes
2answers
70 views

Load a list from a file (in a script)

I have a script containing this code: (let ((JOURNALS '( ("abhandlungen aus dem mathematischen seminar der hamburgischen universitet" . "Abh. Math. Sem. Univ. Hamburg") ;; ...
0
votes
2answers
116 views

How to insert boilerplate code in a file based on the directory in which it is created?

Suppose I have a file dir1/this_file.txt and dir2/this_file.txt, and I want to insert different boilerplate code not based on the file name or extension, but based on the directory in which the file ...
0
votes
2answers
55 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
109 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
0answers
36 views

Can image-dired track renamed files?

I would like to view images using image-dired, then rename them. What I do at the moment: Open image-dired with my directory of choice. Mark an image that I want to rename. In the corresponding dired+...
1
vote
1answer
35 views

How to prompt user for a proper writable file in Emacs Lisp?

I need to prompt the user for a file which is 1) not a directory 2) if already exists, is writable. I know I can use read-file-name, but I'm not sure how to filter out the improper files. ...
0
votes
1answer
90 views

How delete folder named "build" in all subfolders?

Emacs 26.1, Dired+, Windows 10 Suppose I has the next dir tree: myproject myproject\app\ myproject\app\build myproject\app\src myproject\lib\build myproject\lib\src myproject\lib2\build myproject\...
1
vote
1answer
145 views

get the full path (path + filename) of the currently editing file in to the OS clipboard

when editing a file (for example a .pl file) Whats the quickest way to get the full path (path + filename) of the currently editing file in to the OS clipboard. I'm on macOS, where echo "hello" | ...
0
votes
0answers
46 views

How to get a list of all folder names under a folder?

I have a folder structure like this,i want get a list that all folder names in pack folder. Then traverse the list and load them ├── pack │   ├── completion │   │   ├── company │   │   │   └── pack-...
4
votes
2answers
839 views

How to open all the opened files from a previous session?

Whenever I open my spacemacs I see the recentf buffer which lists 5 files I had open in my previous session. There is only an option to open them one by one, and only five of them, because others are ...
0
votes
1answer
58 views

Using the :match attribute for custom matching for a Helm source

I'm trying to create a Helm source which matches the basename of files. I created a source which splits the basename of files in recentf list and puts the path behind it in parens (it uses the (...
1
vote
0answers
77 views

Sharing .org file between two users

My secretory creates a daily agenda for me by capturing task to shared org file mytodo.org. When I open the agenda or mark the task done, her ability to capture new task gets limited as the mytodo.org ...
0
votes
2answers
521 views

read epub with nov

Upon reading epub on emacs, I tried https://github.com/wasamasa/nov.el. Installed and configured step by step as its instructions. When C-x C-f to open an epub, it is displayed as M Filemode ...
-1
votes
2answers
91 views

What tool can I use to compare files by content in dired mode? [closed]

windows 10 (64 bit) Emacs 26.1, Dired+ I need tool that can compare files by content with highlight different symbols. Example: As you can see I mark two files. Is it possible to compare this ...
2
votes
0answers
75 views

Simple Atom-style jump-to-file

I'm upgrading Emacs and moving from macOS to Windows after quite a few years getting by with a very old setup (eg, custom scripts for Anything). I've installed Helm. I'm interested in a simple way to: ...
3
votes
0answers
190 views

How to make find-file-other-window reuse existing window

Is it possible to make find-file-other-window open the file in a pre-existing window instead of creating a new one? Currently: |A---|B---| |A-|C-|B---| |----|----| -> ...
5
votes
1answer
540 views

how to ignore current selection from ivy when my typed text matches one

I run into this issue from time to time when I want to create a new file but the new name matches a pattern already so my Ivy auto-complete setup will pick the matched option when I press Enter ...
1
vote
2answers
208 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 ...
1
vote
1answer
52 views

Why does a certain file always gets opened on startup?

I'm using desktop-save-mode to automatically open the files that I had opened in the last session. This mode should also remember the files that I closed so that it no longer opens them in the next ...

1
2 3 4 5