Skip to content

thisirs/find-temp-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 

Repository files navigation

find-temp-file

This package allows you to quickly open a temporary file corresponding to a given extension. No need to specify a name, just an extension or better, just a keystroke.

Installation

Install the ELPA package from MELPA with M-x package-install RET find-temp-file or put find-temp-file.el in you load path and require it somewhere in your .emacs.

(require 'find-temp-file)

Settings

You may want to bind find-temp-file to a convenient keystroke. In my setup, I bound it to C-x C-t. To quickly find a file, press C-x C-t and type the extension of the temporary file you want to open or just press ENTER to select the default extension which is the extension of the currently visited file. You can nonetheless specify the full filename if the extension you type contains a dot.

Examples

The following setting stores temporary files in ~/drafts. The file name used is the next available in find-temp-file-prefix plus the provided extension.

(setq find-temp-file-directory "~/drafts")
(setq find-temp-template-default "%N.%E")

The generated names are maybe too simple and could clash with other existing non-temporary files. We can then use the spec %T or %U that provide 5-characters long.

(setq find-temp-template-default "%N-%U.%E")

Some extensions might require their files having a special format. This can be done with find-temp-template-alist that maps extensions to file name templates.

With that setting, we might quite rapidly run out of automatically generated names. To remedy this, we add a sub-directory named after the current date.

(setq find-temp-template-default "%D/%N-%U.%E")

We can also have our files to be sorted after the major mode they trigger.

(setq find-temp-template-default "%M/%D/%N-%U.%E")

For any other behaviour, custom specs can be added to find-temp-custom-spec.

(setq find-temp-custom-spec '((?D . (lambda () (format-time-string "%m"))))

About

Open quickly a temporary file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published