mirror of
https://github.com/vale981/apheleia
synced 2025-03-05 09:31:40 -05:00
Revert "[#30] Run formatters in project root"
This reverts commit 66777303dc
.
See https://github.com/raxod502/apheleia/issues/36,
https://github.com/raxod502/apheleia/pull/37 for discussion.
This commit is contained in:
parent
b4975ca1bb
commit
87115f5cda
2 changed files with 9 additions and 36 deletions
|
@ -4,11 +4,6 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog].
|
||||
|
||||
## Unreleased
|
||||
### Enhancements
|
||||
* Formatters are now run by default in the root directory of your
|
||||
project (as defined by `project.el` or Projectile, defaulting to the
|
||||
working directory). See [#30].
|
||||
|
||||
### Bugs fixed
|
||||
* Fix spelling error in generated process names ([#32]).
|
||||
|
||||
|
|
24
apheleia.el
24
apheleia.el
|
@ -25,35 +25,14 @@
|
|||
|
||||
(require 'cl-lib)
|
||||
(require 'map)
|
||||
(require 'project)
|
||||
(require 'subr-x)
|
||||
|
||||
(declare-function projectile-project-root "ext:projectile")
|
||||
|
||||
(defgroup apheleia nil
|
||||
"Reformat buffer without moving point."
|
||||
:group 'external
|
||||
:link '(url-link :tag "GitHub" "https://github.com/raxod502/apheleia")
|
||||
:link '(emacs-commentary-link :tag "Commentary" "apheleia"))
|
||||
|
||||
(defun apheleia--project-root ()
|
||||
"Return the directory containing the current project.
|
||||
This is an absolute path ending in a slash. It uses `project' and
|
||||
then `projectile' (if the latter is installed), before falling
|
||||
back to `default-directory'."
|
||||
(expand-file-name
|
||||
(if-let ((project (project-current)))
|
||||
;; `project-roots' was replaced with `project-root' in Emacs
|
||||
;; 28, and the former function deprecated. Use whichever one is
|
||||
;; available and non-deprecated.
|
||||
(with-no-warnings
|
||||
(if (fboundp 'project-root)
|
||||
(project-root project)
|
||||
(car (project-roots project))))
|
||||
(or (and (require 'projectile nil 'noerror)
|
||||
(projectile-project-root))
|
||||
default-directory))))
|
||||
|
||||
(cl-defun apheleia--edit-distance-table (s1 s2)
|
||||
"Align strings S1 and S2 for minimum edit distance.
|
||||
Return the dynamic programming table as has table which maps cons
|
||||
|
@ -458,7 +437,6 @@ modified from what is written to disk, then don't do anything."
|
|||
output-fname
|
||||
arg))
|
||||
command)))
|
||||
(let ((default-directory (apheleia--project-root)))
|
||||
(apheleia--make-process
|
||||
:command command
|
||||
:stdin (unless input-fname
|
||||
|
@ -467,7 +445,7 @@ modified from what is written to disk, then don't do anything."
|
|||
(when output-fname
|
||||
(erase-buffer)
|
||||
(insert-file-contents-literally output-fname))
|
||||
(funcall callback stdout)))))))
|
||||
(funcall callback stdout))))))
|
||||
|
||||
(defcustom apheleia-formatters
|
||||
'((black . ("black" "-"))
|
||||
|
|
Loading…
Add table
Reference in a new issue