summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2023-06-15 19:37:26 +0200
committerUlrich Müller <ulm@gentoo.org>2023-06-15 19:37:26 +0200
commitacf7d29b672785c2d3089d329e6e33d02363456b (patch)
tree54e4a7f1b5335ea84a6d8f448ea83bf1a32afd51
parentRename variable to ebuild-mode-keywords-eclassdoc (diff)
downloadebuild-mode-acf7d29b672785c2d3089d329e6e33d02363456b.tar.gz
ebuild-mode-acf7d29b672785c2d3089d329e6e33d02363456b.tar.bz2
ebuild-mode-acf7d29b672785c2d3089d329e6e33d02363456b.zip
Do not modify the buffer when KEYWORDS are unchanged
* ebuild-mode.el (ebuild-mode-put-keywords): Do not modify the buffer unless there is an actual change. Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r--ChangeLog3
-rw-r--r--ebuild-mode.el9
2 files changed, 8 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 625dca6..fbbb432 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2023-06-15 Ulrich Müller <ulm@gentoo.org>
+ * ebuild-mode.el (ebuild-mode-put-keywords): Do not modify the
+ buffer unless there is an actual change.
+
* ebuild-mode-keywords.el (ebuild-mode-keywords-eclassdoc):
Renamed from ebuild-mode-keywords-eclass-documentation.
* ebuild-mode.el (ebuild-mode-font-lock-keywords): Update.
diff --git a/ebuild-mode.el b/ebuild-mode.el
index 77c6e9d..60d7e2c 100644
--- a/ebuild-mode.el
+++ b/ebuild-mode.el
@@ -620,16 +620,17 @@ Signal an error if this is not possible, or return nil if the
optional second argument NOERROR is non-nil."
(save-excursion
(goto-char (point-min))
- (let ((case-fold-search nil))
+ (let ((case-fold-search nil)
+ (kw-string (mapconcat
+ (lambda (e) (concat (cdr e) (car e))) kw " ")))
(cond
((not (re-search-forward ebuild-mode-arch-regexp nil t))
(unless noerror (error "No KEYWORDS assignment found")))
((re-search-forward ebuild-mode-arch-regexp nil t)
(unless noerror (error "More than one KEYWORDS assignment found")))
(t
- (replace-match
- (mapconcat (lambda (e) (concat (cdr e) (car e))) kw " ")
- t t nil 1))))))
+ (unless (string-equal kw-string (match-string 1))
+ (replace-match kw-string t t nil 1)))))))
(defun ebuild-mode-modify-keywords (kw)
"Set keywords. KW is an alist of architectures and leaders."