[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/reformatter 394b3a6606 55/81: Add reformatter-temp-file-in
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/reformatter 394b3a6606 55/81: Add reformatter-temp-file-in-current-directory |
Date: |
Tue, 5 Sep 2023 04:03:37 -0400 (EDT) |
branch: elpa/reformatter
commit 394b3a66068d9ff71122d3b36db726244231e965
Author: Steve Purcell <steve@sanityinc.com>
Commit: Steve Purcell <steve@sanityinc.com>
Add reformatter-temp-file-in-current-directory
---
reformatter.el | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/reformatter.el b/reformatter.el
index cb8d06e277..9e3aa2e205 100644
--- a/reformatter.el
+++ b/reformatter.el
@@ -188,7 +188,8 @@ INPUT-FILE
It must not produce the same path as the current buffer's file
if that is set: you shouldn't be operating directly on the
buffer's backing file. The temporary input file will be
- deleted automatically.
+ deleted automatically. You might find the function
+ `reformatter-temp-file-in-current-directory' helpful.
MODE
@@ -298,5 +299,17 @@ DISPLAY-ERRORS, shows a buffer if the formatting fails."
(insert-file-contents file nil nil nil t))
+(defun reformatter-temp-file-in-current-directory (&optional default-extension)
+ "Make a temp file in the current directory re-using the current extension.
+If the current file is not backed by a file, then use
+DEFAULT-EXTENSION."
+ (let ((temporary-file-directory default-directory)
+ (extension (if buffer-file-name
+ (file-name-extension buffer-file-name)
+ default-extension)))
+ (make-temp-file "reformatter" nil
+ (when extension
+ (concat "." extension)))))
+
(provide 'reformatter)
;;; reformatter.el ends here
- [nongnu] elpa/reformatter e15598a0cc 40/81: Prefer `delete-trailing-whitespace` to the aggressive `whitespace-cleanup`, (continued)
- [nongnu] elpa/reformatter e15598a0cc 40/81: Prefer `delete-trailing-whitespace` to the aggressive `whitespace-cleanup`, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 1bf00b2aa3 43/81: Add FUNDING.yml, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 16a7b32736 25/81: Prefer zerop to (eq 0 ...), ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter ac980a8797 27/81: Fix typo in comment, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter aeef16ff67 53/81: Support formatters that operate on files in place, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 27348d5da3 31/81: Use string as modeline lighter format in README, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 897f3ba503 67/81: Handle slashes in names of created functions, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 45c0add950 57/81: Move conditional input file path to compile time, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 5aa8c18679 59/81: Specify "from" in nix-env invocation, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 452a99b556 66/81: Add Emacs 28.1 to CI matrix, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 394b3a6606 55/81: Add reformatter-temp-file-in-current-directory,
ELPA Syncer <=
- [nongnu] elpa/reformatter 576d339aa8 60/81: Add Emacs 27.2 to CI matrix, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 19582a205e 62/81: Use Emacs > 21 define-minor-mode call convention, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter b57f5d4800 65/81: Merge pull request #33 from bcc32/display-call-process-signal-error-in-buffer, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 7ba5486696 56/81: Clarify that extension does not include the dot, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter c9cf3f0227 80/81: Merge pull request #42 from purcell/dependabot/github_actions/actions/checkout-4, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 6c4f35dd2b 81/81: Merge pull request #43 from purcell/dependabot/github_actions/cachix/install-nix-action-23, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter c1410f0c7a 75/81: chore(deps): bump cachix/install-nix-action from 12 to 22, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter edf1c42de8 71/81: Use -buffer suffix when calling reformatter in test, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 1428ca9e42 70/81: Fix form quoting, and tabs, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 84cff54b08 72/81: Merge pull request #36 from kenranunderscore/harden-temp-file-creation, ELPA Syncer, 2023/09/05