1 |
commit: 6d7464806738628ad29b18daa796366e462897f3 |
2 |
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Feb 27 21:58:07 2017 +0000 |
4 |
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Feb 27 21:58:07 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/emacs-tools.git/commit/?id=6d746480 |
7 |
|
8 |
Make fixing of whitespace before saving conditional. |
9 |
|
10 |
* ebuild-mode.el (ebuild-mode): New customisation group. |
11 |
(ebuild-mode-portdir): Change to custom variable. |
12 |
(ebuild-mode-fix-whitespace): New custom variable, defaults to t. |
13 |
(ebuild-mode-before-save): Make fixing of whitespace conditional. |
14 |
|
15 |
ChangeLog | 5 +++++ |
16 |
ebuild-mode.el | 26 ++++++++++++++++++++------ |
17 |
2 files changed, 25 insertions(+), 6 deletions(-) |
18 |
|
19 |
diff --git a/ChangeLog b/ChangeLog |
20 |
index fe1ced8..285118d 100644 |
21 |
--- a/ChangeLog |
22 |
+++ b/ChangeLog |
23 |
@@ -1,5 +1,10 @@ |
24 |
2017-02-27 Ulrich Müller <ulm@g.o> |
25 |
|
26 |
+ * ebuild-mode.el (ebuild-mode): New customisation group. |
27 |
+ (ebuild-mode-portdir): Change to custom variable. |
28 |
+ (ebuild-mode-fix-whitespace): New custom variable, defaults to t. |
29 |
+ (ebuild-mode-before-save): Make fixing of whitespace conditional. |
30 |
+ |
31 |
* ebuild-mode.el: |
32 |
* ebuild-mode.texi: Update documentation to use generic terms |
33 |
where possible, instead of being Portage specific. |
34 |
|
35 |
diff --git a/ebuild-mode.el b/ebuild-mode.el |
36 |
index 3f3e0fe..85491f8 100644 |
37 |
--- a/ebuild-mode.el |
38 |
+++ b/ebuild-mode.el |
39 |
@@ -59,6 +59,23 @@ A formfeed is not considered whitespace by this function." |
40 |
|
41 |
;;; Variables. |
42 |
|
43 |
+(defgroup ebuild-mode nil |
44 |
+ "Ebuild mode." |
45 |
+ :group 'languages) |
46 |
+ |
47 |
+(defcustom ebuild-mode-portdir |
48 |
+ "/usr/portage" |
49 |
+ "Location of the ebuild repository." |
50 |
+ :type 'string |
51 |
+ :group 'ebuild-mode) |
52 |
+ |
53 |
+(defcustom ebuild-mode-fix-whitespace t |
54 |
+ "If non-nil, fix whitespace before writing a file. |
55 |
+Namely, delete trailing whitespace and tabify whitespace at beginning |
56 |
+of lines." |
57 |
+ :type 'boolean |
58 |
+ :group 'ebuild-mode) |
59 |
+ |
60 |
;; Predicate function for comparison of architecture keywords |
61 |
;; (needed for variable definitions below) |
62 |
(defun ebuild-mode-arch-lessp (a b) |
63 |
@@ -71,10 +88,6 @@ A formfeed is not considered whitespace by this function." |
64 |
(string-lessp (car as) (car bs)) |
65 |
(string-lessp (cadr as) (cadr bs))))) |
66 |
|
67 |
-(defvar ebuild-mode-portdir |
68 |
- "/usr/portage" |
69 |
- "Location of the ebuild repository.") |
70 |
- |
71 |
(defvar ebuild-mode-arch-list |
72 |
(or |
73 |
(condition-case nil |
74 |
@@ -220,8 +233,9 @@ Optional argument LIMIT restarts collection after that number of elements." |
75 |
(indent-to end-col))))))) |
76 |
|
77 |
(defun ebuild-mode-before-save () |
78 |
- (delete-trailing-whitespace) |
79 |
- (ebuild-mode-tabify) |
80 |
+ (when ebuild-mode-fix-whitespace |
81 |
+ (delete-trailing-whitespace) |
82 |
+ (ebuild-mode-tabify)) |
83 |
;;(copyright-update) ; doesn't exist in XEmacs |
84 |
;; return nil, otherwise the file is presumed to be written |
85 |
nil) |