summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2024-06-25 18:14:46 +0200
committerUlrich Müller <ulm@gentoo.org>2024-06-28 17:07:01 +0200
commitf9a3535f94cf5afe1788f0e889d4a0a4027656c5 (patch)
tree80da0b631bfe86163bb7933cfa04f7e24010cdc5
parentNew major mode ebuild-eclass-mode (diff)
downloadebuild-mode-f9a3535f94cf5afe1788f0e889d4a0a4027656c5.tar.gz
ebuild-mode-f9a3535f94cf5afe1788f0e889d4a0a4027656c5.tar.bz2
ebuild-mode-f9a3535f94cf5afe1788f0e889d4a0a4027656c5.zip
Make fixing of whitespace in eclasses conditional
* ebuild-mode.el (ebuild-mode-fix-whitespace): Add new choice 'ebuild'. (ebuild-repo-mode-before-save): Make fixing of whitespace in eclasses conditional on it. Suggested-by: Florian Schmaus <flow@gentoo.org> Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r--ChangeLog5
-rw-r--r--ebuild-mode.el12
2 files changed, 14 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a20208c..9e3b7e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2024-06-25 Ulrich Müller <ulm@gentoo.org>
+ * ebuild-mode.el (ebuild-mode-fix-whitespace): Add new choice
+ 'ebuild'.
+ (ebuild-repo-mode-before-save): Make fixing of whitespace in
+ eclasses conditional on it.
+
* ebuild-mode.el (ebuild-eclass-mode): New major mode for editing
of eclasses, split off from ebuild-mode.
(auto-mode-alist): Add ebuild-eclass-mode.
diff --git a/ebuild-mode.el b/ebuild-mode.el
index 772b1f3..3821c4b 100644
--- a/ebuild-mode.el
+++ b/ebuild-mode.el
@@ -77,8 +77,12 @@ The most recent EAPI must be listed last."
(defcustom ebuild-mode-fix-whitespace t
"If non-nil, fix whitespace before writing a file.
Namely, delete trailing whitespace and tabify whitespace at beginning
-of lines."
- :type 'boolean
+of lines.
+If the value is `ebuild', fixes for tabs and newlines will only
+be applied to ebuilds but not to eclasses."
+ :type '(choice (const :tag "Yes" t)
+ (const :tag "No" nil)
+ (const :tag "Ebuilds only" ebuild))
:group 'ebuild)
(defcustom ebuild-mode-update-copyright t
@@ -800,7 +804,9 @@ This will be added to the `write-contents-functions' hook."
;; trim trailing whitespace, except for patches
(ebuild-mode-delete-trailing-whitespace)
;; tabify whitespace and squash multiple empty lines for ebuilds
- (when (derived-mode-p 'ebuild-mode)
+ (when (and (derived-mode-p 'ebuild-mode)
+ (or (eq major-mode 'ebuild-mode)
+ (not (eq ebuild-mode-fix-whitespace 'ebuild))))
(ebuild-mode-tabify)
(ebuild-mode-squash-empty-lines)))
(when ebuild-mode-update-copyright