aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/vc
diff options
context:
space:
mode:
authorStefan Monnier2012-08-13 15:10:35 -0400
committerStefan Monnier2012-08-13 15:10:35 -0400
commitaa7c6dbeba48522d892cbf011c40a9fef0c369f7 (patch)
tree0f984a2054ada80ca4922a9bc47021a27f264ef6 /lisp/vc
parent89660017d14b5c2ca7d621636604f4acab63138c (diff)
downloademacs-aa7c6dbeba48522d892cbf011c40a9fef0c369f7.tar.gz
emacs-aa7c6dbeba48522d892cbf011c40a9fef0c369f7.zip
* lisp/color.el (color-xyz-to-lab, color-lab-to-xyz, color-cie-de2000):
Prefer pcase-let over destructuring-bind. * lisp/vc/diff-mode.el (diff-remove-trailing-whitespace): Same. Also, remove whitespace as we go, rather than after accumulating the various places.
Diffstat (limited to 'lisp/vc')
-rw-r--r--lisp/vc/diff-mode.el49
1 files changed, 19 insertions, 30 deletions
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index d3d9878c5ad..3fa7788002e 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2024,37 +2024,26 @@ with the name of the altered buffers, which are unsaved. If a
2024file referenced on the diff has no buffer and needs to be fixed, 2024file referenced on the diff has no buffer and needs to be fixed,
2025a buffer visiting that file is created." 2025a buffer visiting that file is created."
2026 (interactive) 2026 (interactive)
2027 (goto-char (point-min)) 2027 ;; We assume that the diff header has no trailing whitespace.
2028 (let 2028 (let ((modified-buffers nil))
2029 ;; We assume that the diff header has no trailing whitespace. 2029 (save-excursion
2030 ((modified-buffers nil) 2030 (goto-char (point-min))
2031 (white-positions nil)) 2031 (while (re-search-forward "^[+!>].*[ \t]+$" (point-max) t)
2032 (while (re-search-forward "^[+!>].*[ \t]+$" (point-max) t) 2032 (pcase-let ((`(,buf ,line-offset ,pos ,src ,_dst ,_switched)
2033 (save-excursion 2033 (diff-find-source-location t t)))
2034 (cl-destructuring-bind (buf line-offset pos src _dst &optional _switched) 2034 (when line-offset
2035 (diff-find-source-location t t) 2035 (with-current-buffer buf
2036 (when line-offset 2036 (save-excursion
2037 (set-buffer buf) 2037 (goto-char (+ (car pos) (cdr src)))
2038 (save-excursion 2038 (beginning-of-line)
2039 (goto-char (+ (car pos) (cdr src))) 2039 (when (re-search-forward "\\([ \t]+\\)$" (line-end-position) t)
2040 (beginning-of-line) 2040 (unless (memq buf modified-buffers)
2041 (when (re-search-forward "\\([ \t]+\\)$" (line-end-position) t) 2041 (push buf modified-buffers))
2042 (when (not (member buf modified-buffers)) 2042 (replace-match ""))))))))
2043 (push buf modified-buffers))
2044 (goto-char (match-end 0))
2045 (push (point-marker) white-positions)
2046 (goto-char (match-beginning 0))
2047 (push (point-marker) white-positions)
2048 (push buf white-positions)))))))
2049 (while white-positions
2050 (save-excursion
2051 (set-buffer (pop white-positions))
2052 (delete-region (pop white-positions) (pop white-positions))))
2053 (if modified-buffers 2043 (if modified-buffers
2054 (let ((msg "Deleted new trailing whitespace from:")) 2044 (message "Deleted new trailing whitespace from: %s"
2055 (dolist (f modified-buffers) 2045 (mapconcat (lambda (buf) (concat "`" (buffer-name buf) "'"))
2056 (setq msg (concat msg " `" (buffer-name f) "'"))) 2046 modified-buffers " "))
2057 (message "%s" msg))
2058 (message "No trailing whitespace fixes needed.")))) 2047 (message "No trailing whitespace fixes needed."))))
2059 2048
2060;; provide the package 2049;; provide the package