2022 Developer Survey is open! Take survey.

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
23 views

Writing elements of directory to file

I am trying to set up my own system for a personal wiki using my org-mode files. I currently have my notes organized into directories for different classes/topics that are all contained in a single ...
user avatar
  • 1
1 vote
0 answers
46 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 ...
user avatar
3 votes
1 answer
103 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 ...
user avatar
  • 131
0 votes
0 answers
23 views

How can I query local rdf/turtle files using `sparql-mode`?

I am currently reading Bob DuCharmes "Learning SPARQL" and would like to set up a simple SPARQL playground with sparql-mode. The preferred approach would be to query local rdf/turtle files ...
user avatar
  • 121
0 votes
0 answers
24 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 ...
user avatar
  • 159
0 votes
1 answer
21 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]...
user avatar
1 vote
1 answer
63 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 ...
user avatar
  • 111
1 vote
1 answer
31 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 ...
user avatar
  • 7,069
2 votes
0 answers
40 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 ...
user avatar
0 votes
0 answers
40 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 ...
user avatar
0 votes
0 answers
33 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' ...
user avatar
  • 181
0 votes
0 answers
37 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 ...
user avatar
  • 3,395
1 vote
2 answers
39 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-...
user avatar
  • 11
2 votes
1 answer
211 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 ...
user avatar
  • 203
1 vote
0 answers
49 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 ...
user avatar
  • 989
2 votes
0 answers
50 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, ...
user avatar
  • 173
0 votes
1 answer
31 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 ...
user avatar
  • 581
2 votes
0 answers
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, ...
user avatar
  • 581
1 vote
1 answer
50 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 ...
user avatar
  • 725
3 votes
2 answers
182 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 ...
user avatar
  • 43
0 votes
1 answer
61 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 ...
user avatar
  • 63
1 vote
1 answer
34 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 ...
user avatar
  • 989
2 votes
0 answers
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 ...
user avatar
0 votes
1 answer
34 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?
user avatar
  • 785
5 votes
1 answer
71 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 ...
user avatar
  • 602
2 votes
2 answers
175 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) ...
user avatar
0 votes
1 answer
64 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 "...
user avatar
1 vote
1 answer
257 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 ...
user avatar
  • 235
0 votes
1 answer
130 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 ...
user avatar
  • 3
0 votes
0 answers
98 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 (...
user avatar
2 votes
1 answer
396 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 ...
user avatar
  • 8,536
0 votes
1 answer
151 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 ...
user avatar
1 vote
1 answer
145 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 &...
user avatar
1 vote
1 answer
775 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?
user avatar
  • 201
1 vote
1 answer
51 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. ...
user avatar
6 votes
1 answer
1k 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 ...
user avatar
  • 3,395
2 votes
2 answers
1k 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-...
user avatar
4 votes
1 answer
634 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 ...
user avatar
  • 3,835
1 vote
1 answer
120 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-...
user avatar
1 vote
1 answer
85 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 ...
user avatar
0 votes
2 answers
79 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") ;; ...
user avatar
0 votes
2 answers
134 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 ...
user avatar
0 votes
2 answers
58 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 ...
user avatar
2 votes
2 answers
118 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 ...
user avatar
0 votes
0 answers
43 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+...
user avatar
  • 989
1 vote
1 answer
50 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. ...
user avatar
  • 149
1 vote
1 answer
108 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\...
user avatar
  • 3,395
1 vote
1 answer
185 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" | ...
user avatar
0 votes
0 answers
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-...
user avatar
4 votes
2 answers
975 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 ...
user avatar

1
2 3 4 5 6