mirror of
https://github.com/vale981/apheleia
synced 2025-03-05 09:31:40 -05:00
[#10] Make write-region hack more robust
This commit is contained in:
parent
d596a59355
commit
8112041d7e
1 changed files with 8 additions and 4 deletions
12
apheleia.el
12
apheleia.el
|
@ -318,15 +318,19 @@ provided that its exit status is 0."
|
||||||
|
|
||||||
(defun apheleia--write-region-silently
|
(defun apheleia--write-region-silently
|
||||||
(start end filename &optional
|
(start end filename &optional
|
||||||
append _visit lockname mustbenew write-region)
|
append visit lockname mustbenew write-region)
|
||||||
"Like `write-region', but silent.
|
"Like `write-region', but silent.
|
||||||
START, END, FILENAME, APPEND, VISIT, LOCKNAME, and MUSTBENEW are
|
START, END, FILENAME, APPEND, VISIT, LOCKNAME, and MUSTBENEW are
|
||||||
as in `write-region'. WRITE-REGION is used instead of the actual
|
as in `write-region'. WRITE-REGION is used instead of the actual
|
||||||
`write-region' function, if provided."
|
`write-region' function, if provided."
|
||||||
(funcall (or write-region #'write-region)
|
(funcall (or write-region #'write-region)
|
||||||
start end filename append 0 lockname mustbenew)
|
start end filename append 0 lockname mustbenew)
|
||||||
(set-buffer-modified-p nil)
|
(when (or (eq visit t) (stringp visit))
|
||||||
(set-visited-file-modtime))
|
(setq buffer-file-name (if (eq visit t)
|
||||||
|
filename
|
||||||
|
visit))
|
||||||
|
(set-visited-file-modtime)
|
||||||
|
(set-buffer-modified-p nil)))
|
||||||
|
|
||||||
(defun apheleia--write-file-silently (&optional filename)
|
(defun apheleia--write-file-silently (&optional filename)
|
||||||
"Write contents of current buffer into file FILENAME, silently.
|
"Write contents of current buffer into file FILENAME, silently.
|
||||||
|
@ -336,7 +340,7 @@ FILENAME defaults to value of variable `buffer-file-name'."
|
||||||
(lambda (start end filename &optional
|
(lambda (start end filename &optional
|
||||||
append _visit lockname mustbenew)
|
append _visit lockname mustbenew)
|
||||||
(apheleia--write-region-silently
|
(apheleia--write-region-silently
|
||||||
start end filename append 0 lockname mustbenew write-region)))
|
start end filename append t lockname mustbenew write-region)))
|
||||||
(message (symbol-function #'message))
|
(message (symbol-function #'message))
|
||||||
((symbol-function #'message)
|
((symbol-function #'message)
|
||||||
(lambda (format &rest args)
|
(lambda (format &rest args)
|
||||||
|
|
Loading…
Add table
Reference in a new issue