diff options
author | Ulrich Müller <ulm@gentoo.org> | 2023-08-20 10:39:57 +0200 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2023-08-20 10:39:57 +0200 |
commit | 9b1ac979fd51c8bf92ec5be64b8662ef239dfa1b (patch) | |
tree | 654850698fe590eda605e2bfea210fe9ec3570e7 | |
parent | Keywords regenerated from eclasses (diff) | |
download | ebuild-mode-9b1ac979fd51c8bf92ec5be64b8662ef239dfa1b.tar.gz ebuild-mode-9b1ac979fd51c8bf92ec5be64b8662ef239dfa1b.tar.bz2 ebuild-mode-9b1ac979fd51c8bf92ec5be64b8662ef239dfa1b.zip |
Avoid redefining delete-trailing-whitespace
* ebuild-mode.el (ebuild-mode-delete-trailing-whitespace):
New function. This avoids redefining delete-trailing-whitespace.
(ebuild-repo-mode-before-save): Update caller.
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ebuild-mode.el | 35 |
2 files changed, 16 insertions, 25 deletions
@@ -1,3 +1,9 @@ +2023-08-20 Ulrich Müller <ulm@gentoo.org> + + * ebuild-mode.el (ebuild-mode-delete-trailing-whitespace): + New function. This avoids redefining delete-trailing-whitespace. + (ebuild-repo-mode-before-save): Update caller. + 2023-08-01 Ulrich Müller <ulm@gentoo.org> * ebuild-mode-keywords.el (ebuild-mode-keywords-eclass): diff --git a/ebuild-mode.el b/ebuild-mode.el index 6a8326c..3d20ed8 100644 --- a/ebuild-mode.el +++ b/ebuild-mode.el @@ -33,30 +33,6 @@ (require 'skeleton) -;;; Compatibility code. - -(eval-and-compile - (or (fboundp 'delete-trailing-whitespace) ; doesn't exist in XEmacs 21.4 - ;; from simple.el of GNU Emacs 22.1 -(defun delete-trailing-whitespace () - "Delete all the trailing whitespace across the current buffer. -All whitespace after the last non-whitespace character in a line is deleted. -This respects narrowing, created by \\[narrow-to-region] and friends. -A formfeed is not considered whitespace by this function." - (interactive "*") - (save-match-data - (save-excursion - (goto-char (point-min)) - (while (re-search-forward "\\s-$" nil t) - (skip-syntax-backward "-" (save-excursion (forward-line 0) (point))) - ;; Don't delete formfeeds, even if they are considered whitespace. - (save-match-data - (if (looking-at ".*\f") - (goto-char (match-end 0)))) - (delete-region (point) (match-end 0)))))) -)) - - ;;; Variables. (defgroup ebuild nil @@ -365,6 +341,15 @@ Compatibility function for XEmacs." (delete-region (match-beginning 0) (point)) (indent-to end-col))))))) +(defun ebuild-mode-delete-trailing-whitespace () + "Delete all the trailing spaces and tabs across the current buffer." + ;; Simple non-interactive version of delete-trailing-whitespace + ;; which doesn't exist in XEmacs + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "[ \t]+$" nil t) + (replace-match "")))) + (defun ebuild-mode-squash-empty-lines () "Replace multiple consecutive empty lines by a single one." (save-excursion @@ -800,7 +785,7 @@ that shall be manipulated." This will be added to the `write-contents-functions' hook." (when ebuild-mode-fix-whitespace ;; trim trailing whitespace, except for patches - (delete-trailing-whitespace) + (ebuild-mode-delete-trailing-whitespace) ;; tabify whitespace and squash multiple empty lines for ebuilds (when (derived-mode-p 'ebuild-mode) (ebuild-mode-tabify) |