[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/editorconfig 676096fdae: (editorconfig--get-trailing-nl
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/editorconfig 676096fdae: (editorconfig--get-trailing-nl): Fix handling of `mode-require-final-newline` |
Date: |
Thu, 13 Jun 2024 11:39:16 -0400 (EDT) |
branch: scratch/editorconfig
commit 676096fdaedf3bdc1b9326c6d0c24cd42d64db05
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
(editorconfig--get-trailing-nl): Fix handling of
`mode-require-final-newline`
`mode-require-final-newline` is the customization with which users can say
how they want to add trailing newlines in those modes that should and it
is used inside the main body of major modes to set
`require-final-newline`. So setting it buffer-locally is at best useless
(and setting it via EditorConfig is too late anyway because the main
body of the major mode runs earlier).
Also, remove the FIXME that wants to remove final newlines, because
I don't know of a format that disallows a final newline, and in most
cases it's even hard to define what final newline would qualify: we'd need
to link it to something like a `trim_trailing_whitespace` except one that
applies to trailing empty lines rather than trailing spaces on lines.
* editorconfig.el (editorconfig--get-trailing-nl):
Obey `mode-require-final-newline` instead of setting it.
---
editorconfig.el | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/editorconfig.el b/editorconfig.el
index 25b5a3296d..68441d084e 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -605,16 +605,11 @@ This function will revert buffer when the coding-system
has been changed."
"Get the vars to require final newline according to FINAL-NEWLINE."
(pcase final-newline
("true"
- ;; Keep prefs around how/when the nl is added, if set - otherwise add on
- ;; save
- `((require-final-newline . ,(or require-final-newline t))
- ;; FIXME: Why do we set `mode-require-final-newline'?
- (mode-require-final-newline . ,(or mode-require-final-newline t))))
+ ;; Keep prefs around how/when the nl is added, if set.
+ `((require-final-newline
+ . ,(or require-final-newline mode-require-final-newline t))))
("false"
- ;; FIXME: Add functionality to actually REMOVE any trailing newlines here!
- ;; (rather than just making sure we don't automagically ADD a new one)
- `((require-final-newline . nil)
- (mode-require-final-newline . nil)))))
+ `((require-final-newline . nil)))))
(defun editorconfig--delete-trailing-whitespace ()
"Call `delete-trailing-whitespace' unless the buffer is read-only."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] scratch/editorconfig 676096fdae: (editorconfig--get-trailing-nl): Fix handling of `mode-require-final-newline`,
Stefan Monnier <=