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
2
votes
1answer
164 views

Guess the mime type of a file in elisp?

Is there a builtin function to guess the MIME type of a file in Emacs Lisp? I would like to display the MIME type for files in Dired buffers.
1
vote
1answer
211 views

Make helm-recentf open files with external program?

tl;dr Which keymap is active in helm-recentf? Or is there a better way to accomplish my goal? I want to use emacs as my file browser. When I select a file with helm-find-files or helm-recentf, I want ...
3
votes
1answer
87 views

Function to allow select a directory and run a command on its files, descending recursively?

I sometimes work on legacy code, and they have mixture of tabs and spaces. I use whitespace-cleanup function in whitespace.el to clean them up. But I have many files, so i want to run the command on ...
2
votes
1answer
60 views

Writing bytes to a file using library f.el [duplicate]

I'm trying to do something very simple, write bytes to a file using the f library: (require 'f) And I create a list of bytes: (setq random-data (loop for i from 0 to 40 collect (random 150))) So ...
1
vote
1answer
962 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
1answer
124 views

Loading addition org files along with default scratch buffer

I do a lot of my programming in Haskell and Python. I've started maintaining a personal cheat-sheet for each of these languages for common constructs and tasks I often come across. Hence whenever I ...
3
votes
2answers
201 views

Detect changed files by content

When working with files changed on disk, there are two warnings ... changed on disk; really edit the buffer? ... has changed since visited or saved. Save anyway? They're useful, but get very ...
1
vote
0answers
53 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?
4
votes
2answers
775 views

Human readable directory tree with org-attach

By default, org-attach.el names project folders, using a UUID scheme, which is paired with headlines in org-mode, via the :PROPERTIES: drawer. I would love to find a way to make this directory ...
4
votes
2answers
651 views

How to make emacs automatically kill buffer after invoking delete-file command?

Whenever I delete a file that I no longer need in emacs using delete-file command, the buffer associated with the file is still open in emacs. Is there a way I can change this behaviour so that ...
2
votes
2answers
121 views

Looking for an existing function for find-file-not-found-functions to do form style creation

I have the habit when creating larger projects to make files called skeleton.typ with all the standard boilerplate for a file of that type (e.g. copyright notices, licenses, the standard html/head/...
9
votes
2answers
169 views

How to write a major mode that does not open the file but provides a view on it

I would like to write a major mode for inspecting netCDF files. These are binary files which can be multiple GB in size. So I don't want to open them in emacs. The interaction that I have in mind is ...
3
votes
1answer
466 views

Open recent files buffer (recentf-mode) filled with autoload.el files

I've a problem with recentf-mode buffer in emacs. Apart from the files I opened before, its also showing all the autoload files for various packages I've installed which is cluttering the Open recent ...
1
vote
2answers
67 views

Changing the file association of todoo or alternatively completely disable it

I am using emacs on a debian system and have installed emacs-goodies-el. One of the many things in there is todoo which registers itself in auto-mode-alist for all files ending in TODO. This ...
1
vote
1answer
612 views

Emac to open a large file error: Memory exhausted--use C-x s then exit and restart Emacs

I want to open a large file in the server environment with emacs, but there is error: Memory exhausted--use C-x s then exit and restart Emacs as shown in the following figure. Please know that I ...
1
vote
2answers
1k views

Emacs can't write to its own init file on Windows 10

I have been using Emacs on Windows for decades now and it essentially always worked fine except for minor annoyances. However, I recently had to buy a new machine with Windows 10 (the last Windows I ...
3
votes
1answer
168 views

Can I print output to stderr in batch mode WITHOUT a trailing newline?

In emacs --batch (also, emacs --script), (message "My Message") will print "My Message" to standard error (file descriptor 2) along with a trailing newline. What if I don't want the newline? I ...
2
votes
1answer
2k views

How to customise Org-mode per file (and sync with Orgzly)

I am using Org-mode in conjunction with an Android tablet. I have customized Org-mode and keep files in Dropbox. After sync the Android side is not implementing any customization. Copied this code ...
8
votes
2answers
777 views

Can I view within Emacs the properties of a file which I already opened?

I've opened a file in Emacs. I'd like to view information about that file such as creation date, size, etc. within Emacs. Is there a key shortcut or any Emacs command for that? Thanks.
1
vote
2answers
48 views

Reload single file in every window

I have this function that reload a file but it don't work when I have same buffer opened in 2 different windows: (defun reload () "Reload a file it will kill buffer, open file again and jump to ...
1
vote
2answers
164 views

Count number of files with specific extension on a folder?

Let's say I'd like to know how many .png images I have in a folder. In shell I'd run: ls -1 | grep .png | wc -l Is there a way to achieve this in emacs (preferably not just reading in from a shell ...
1
vote
2answers
310 views

Mass conversion of text files in a folder to one .org file

Assume a structure like this: 2014 ... 2015 CustomerfolderA ConfigfileDeviceA_2015_01_01_0800.txt ConfigfileDeviceA_2015_01_02_0800.txt ... ConfigfileDeviceB_2015_01_01_0800.txt ... ...
6
votes
1answer
770 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 ...
1
vote
2answers
39 views

Rewrite paths of opened files

How can I tell Emacs than whenever it tries to open file /a/b/c/foo.txt, it should instead open /d/e/f/foo.txt? I have a few projects and libraries which are accessible via multiple paths on the ...
2
votes
2answers
1k views

How to edit multiple files at once?

Is there a way to open multiple buffers that are open at the same time? The idea is to be able to refactor code and variable names in multiple files at once. I know that dired-do-find-regexp-and-...
2
votes
0answers
1k views

Emacs hitting “too many files open”

I am using Ubuntu 14.04LTS 64bit. I encounter this problem when I opened too many files by a emacs function. Error is signaled as a message and prevent me from opening more files. I checked my ...
1
vote
1answer
412 views

View for version control (git) status with full file names

Tools > Version control > Git > Status produces nice interactive output to browse the repository. Is there any way however to have full path names of the modified files, which can be textually copy-...
0
votes
2answers
89 views

Emacs beginner. Need basic script for copying files

if anyone can help me that would be much appreciated. I may be in the wrong place for this but it's a major roadblock for my research. I have a folder with about 1700 folders. I have a list of ...
1
vote
3answers
867 views

How to delete all instances of a character in a bunch of files?

I was given a directory of files in which I was asked to make some systematic changes. Because it was a one-off task, and because there were only a few hundred files I thought I'd use an Emacs ...
12
votes
1answer
481 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 ...
3
votes
1answer
120 views

Save a buffer to multiple files

I have 2 files /home/user/myproject/myfile.el /ssh:user@myserver.org:/home/user/myproject/myfile.el Content of both of them are same. I want to make same change in both of them. I can do it like: ...
3
votes
1answer
710 views

Open buffer in external application using xdg-open

I want to open the currently viewed buffer in an external application using "xdg-open". What I tried is: (start-process "" nil "xdg-open" (buffer-file-name)) But that only returns #<process >. ...
2
votes
1answer
141 views

How to make desktop-save store relative paths?

Perhaps I'm kind of misusing that feature – but I find desktop files rather handy to be kept with projects. Clearly, it doesn't make much sense then to store absolute paths for the files to be ...
2
votes
1answer
1k views

Why do some files generated by emacs have a tilde after their name?

I think they have smaller file sizes meaning they are zipped. Is this right?
3
votes
0answers
3k views

Spacemacs - opening and creating files [closed]

Lets say I'm already in emacs and I need to open some obscure file (long complicated path) that I rarely ever edit (so its not in my recent files list) - what is the correct way to do this using ...
0
votes
4answers
322 views

elisp pattern for handling region || buffer || file

summary Elisp newbie has been given interactive code (aka commands, called with M-x whatever) that "does stuff" on the currently-selected region in the current buffer. What is an/the "elispish way" ...
11
votes
1answer
2k views

Open large files?

I want to open just the head of a large file. I know you can use a shell command (M-! RET head file RET), but I lose helm completion, it opens in a separate window, and the buffer has the ...
3
votes
2answers
2k views

Setting default-directory does not change find-file directory

I try to set a default path for opening a file via C-x C-f by adding the following to my .emacs: (setq default-directory "~/some_dir/") However, after I launch Emacs in some directory, the find-file ...
1
vote
0answers
109 views

Mac OS X problem accessing file via symlink

GNU Emacs 24 on El Capitan. When opening a file whose path includes a directory which is a symlink, Emacs emits the following error: *ERROR*: Wrong type argument: numberp, "Bus error: 10" If I ...
1
vote
0answers
30 views

Is it possible to display and edit the contents of a linked file?

In a Stack Overflow question, another poster wants to write OpenGL shader programs near to where they are used. However, performance tuning indicates that you should compile these shaders once at the ...
4
votes
2answers
2k views

How to do a simple write to file

I simply need to take the output of org-element-parse-buffer and put it in a file -- maybe with some "if-does-not-exist" etc. bells and whistles. In CL I have with-open-file and write as tools. For ...
1
vote
2answers
129 views

Recognize template filename extension?

I use a template engine for a lot of files in my project. The specific one is irrelevant -- let's say all my template files end with .template. Now, I've got many different kinds of templated files, ...
2
votes
2answers
113 views

find-file, but suppress buffer?

I have a function that opens a buffer in order to extract some information from it, then switches back to the original buffer and inserts some text: (save-excursion (find-file ThisFile) (setq ...
5
votes
1answer
104 views

How do I include non-code resources as part of an Emacs package?

I have a project that wants to play a sound file. I'd like to distribute this project in MELPA. There are two issues I'm having with that. They're both part of the question "how do I use resources in ...
5
votes
0answers
376 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 ...
1
vote
1answer
32 views

Defining a function that takes as an input the current buffer's path

I am hoping to define an interactive function that I can invoke with M-x <function-name> and that will: Automatically grab the path to the file Run the following code on it: (require 'tramp) ...
0
votes
1answer
969 views

How to delete file permanently in dired

The logical way should be C-u D to delete selected files permanently. How can we do that?
3
votes
1answer
487 views

Opening multiple files from the command lines puts the buffer order in the middle

Let's say I have a Linux directory that looks like -rw-r--r-- 1 hooked se 0 Sep 16 16:02 a -rw-r--r-- 1 hooked se 0 Sep 16 16:02 b -rw-r--r-- 1 hooked se 0 Sep 16 16:02 c When I type ...
6
votes
1answer
84 views

Emacs handle when file renamed externally

How can I configure Emacs to update a buffer's file association when the file is renamed externally? In Textmate, I can open a file "foo.txt", use a different program to rename the file to "bar.txt", ...
2
votes
1answer
110 views

file renaming not always caught by filenotify

I'm using file-notify-add-watch from filenotify.el to watch a dired directory so it can revert when a file is modified within the directory. This generally works, but I've noticed that it only works ...