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
1 answer
13 views

How to print and read a list to(from) a file?

I'd like to save a (extremely minimal) database made of a lisp list and then read it back. The list will look like something as follows: (:foo "bar" :baz "foobar" :foobaz "baz&...
1 vote
1 answer
987 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 ...
0 votes
1 answer
39 views

Visual Glitch whenever loading emacs

I am running emacs on WSL, and whenever I load emacs I get the following screen: It goes away for a half second whenever I click on it, but then it comes back. Very new to this so am unsure what is ...
0 votes
1 answer
17 views

Setting `auto-save-file-name-transforms` has the wrong effect: Auto-save files are stored in Emacs config directory

Assume I have the file ~/Documents/bla.org. Now I open a buffer that visits the file ~/Documents/bla.org. I check the value of the (buffer-local) variable buffer-auto-save-file-name, and it reads /...
0 votes
1 answer
24 views

Emacs macro variables

Does Emacs have 'macro variables'? Midnight Commander allows the use of macro substitution expressions like %f %D %t which can be use when running commands. eg %f is the name of the current file in a ...
0 votes
1 answer
77 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 ...
2 votes
2 answers
385 views

Highlighting automatically on file open

I would like to highlight lines with a certain pattern whenever the file is opened. Specifically when Journal.org is opened I want to run commands like M-s h l to highlight a set of patterns and ...
1 vote
1 answer
22 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, ...
2 votes
2 answers
2k 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-...
2 votes
1 answer
178 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
2 answers
94 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.)
1 vote
2 answers
99 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 ...
1 vote
0 answers
46 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 ...
1 vote
1 answer
102 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) ...
1 vote
2 answers
153 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 ...
2 votes
1 answer
66 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 ...
0 votes
0 answers
53 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-...
1 vote
0 answers
187 views

Problem saving (C-x C-s) files on a NFS drive with emacs 24/25

Starting with Emacs 24 (using various different versions of Ubuntu and Linux Mint), if I open a file on an NFS drive, modify it and attempt to save it C-x C-s, I get the message of: Saving <...
1 vote
2 answers
2k 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 ...
0 votes
3 answers
75 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 ...
0 votes
2 answers
79 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 ...
2 votes
2 answers
59 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 ...
1 vote
2 answers
509 views

change default action of opening multiple files in dired

Having marked a bunch of files in dired-mode, if I wanted to open all them at once, I press F. But, the problem is, all the selected files opens in their own separate window and now i've at least as ...
0 votes
2 answers
61 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. ...
0 votes
1 answer
31 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 ...
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 ...
2 votes
1 answer
160 views

What are the '.#' links for? [duplicate]

When an Emacs buffer is modified, a broken link is created. The link's name is a concatenation of '.#' followed by the file's name. For example: $ ls .#spacemacs_ref.org -l lrwxrwxrwx. 1 wolfv wolfv ...
2 votes
1 answer
48 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’...
2 votes
2 answers
675 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
0 answers
33 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 ...
2 votes
1 answer
387 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. ...
0 votes
2 answers
83 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 ...
0 votes
1 answer
111 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 ...
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 ...
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 ...
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 ...
2 votes
1 answer
34 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")) (...
16 votes
6 answers
7k 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/ ./...
1 vote
1 answer
52 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 ...
3 votes
1 answer
185 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 ...
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 ...
170 votes
10 answers
112k views

How do I reload a file in a buffer?

I usually work on files which are updated in the file system via version control. What's a quick way to reload a file without having to C-x C-f the file again and getting asked if I want to reload it?
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 ...
3 votes
1 answer
2k views

Ignoring specific files in recentf-mode [duplicate]

I use company-statistics to sort completion candidates by previous completion choices. It works perfectly, except there is only tiny problem. The file ~/.emacs.d/company-statistics-cache.el pops up in ...
1 vote
0 answers
55 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 ...
3 votes
1 answer
363 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 ...
13 votes
5 answers
8k views

What is the easiest way to open the folder containing the current file by the default explorer of the OS?

What is the easiest way to open the folder containing the current file by the default explorer of the OS (e.g. explorer.exe in the case of Windows OS)?
97 votes
5 answers
33k views

Edit file with super-user rights

When you have to edit system files, it's an usual situation that you launched Emacs with a normal user before, so the file will be write-protected. What can I do to gain root privileges? I mean ...
4 votes
2 answers
589 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
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 ...

1
2 3 4 5 6