aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2021-11-09 10:18:24 +0200
committerJuri Linkov2021-11-09 10:18:24 +0200
commit565514fe96a575ceda2db229ac2dc7a78c2f9abd (patch)
tree665d6d7f82e4428fe18984b8938c0f6cf8c0d255
parente379cb6f1385cdbb5eda8b2cbfc2e65264fb824d (diff)
downloademacs-565514fe96a575ceda2db229ac2dc7a78c2f9abd.tar.gz
emacs-565514fe96a575ceda2db229ac2dc7a78c2f9abd.zip
* lisp/vc/diff-mode.el (diff-setup-buffer-type): Move to diff-setup-whitespace
* lisp/vc/vc.el: Add declare-function for diff-setup-buffer-type (bug#51016).
-rw-r--r--lisp/vc/diff-mode.el30
-rw-r--r--lisp/vc/vc.el3
2 files changed, 17 insertions, 16 deletions
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 9bac3aa67d8..e68aa2257d2 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1475,21 +1475,6 @@ See `after-change-functions' for the meaning of BEG, END and LEN."
1475 ;; Added when diff--font-lock-prettify is non-nil! 1475 ;; Added when diff--font-lock-prettify is non-nil!
1476 (cl-pushnew 'display font-lock-extra-managed-props))) 1476 (cl-pushnew 'display font-lock-extra-managed-props)))
1477 1477
1478(defun diff-setup-buffer-type ()
1479 "Try to guess the `diff-buffer-type' from content of current Diff mode buffer.
1480`outline-regexp' is updated accordingly."
1481 (save-excursion
1482 (goto-char (point-min))
1483 (setq-local diff-buffer-type
1484 (if (re-search-forward "^diff --git" nil t)
1485 'git
1486 nil)))
1487 (when (eq diff-buffer-type 'git)
1488 (setq diff-outline-regexp
1489 (concat "\\(^diff --git.*\n\\|" diff-hunk-header-re "\\)"))
1490 (setq-local outline-level #'diff--outline-level))
1491 (setq-local outline-regexp diff-outline-regexp))
1492
1493(defvar whitespace-style) 1478(defvar whitespace-style)
1494(defvar whitespace-trailing-regexp) 1479(defvar whitespace-trailing-regexp)
1495 1480
@@ -1591,6 +1576,21 @@ modified lines of the diff."
1591 "^[-+!] .*?\\([\t ]+\\)$" 1576 "^[-+!] .*?\\([\t ]+\\)$"
1592 "^[-+!<>].*?\\([\t ]+\\)$")))) 1577 "^[-+!<>].*?\\([\t ]+\\)$"))))
1593 1578
1579(defun diff-setup-buffer-type ()
1580 "Try to guess the `diff-buffer-type' from content of current Diff mode buffer.
1581`outline-regexp' is updated accordingly."
1582 (save-excursion
1583 (goto-char (point-min))
1584 (setq-local diff-buffer-type
1585 (if (re-search-forward "^diff --git" nil t)
1586 'git
1587 nil)))
1588 (when (eq diff-buffer-type 'git)
1589 (setq diff-outline-regexp
1590 (concat "\\(^diff --git.*\n\\|" diff-hunk-header-re "\\)"))
1591 (setq-local outline-level #'diff--outline-level))
1592 (setq-local outline-regexp diff-outline-regexp))
1593
1594(defun diff-delete-if-empty () 1594(defun diff-delete-if-empty ()
1595 ;; An empty diff file means there's no more diffs to integrate, so we 1595 ;; An empty diff file means there's no more diffs to integrate, so we
1596 ;; can just remove the file altogether. Very handy for .rej files if we 1596 ;; can just remove the file altogether. Very handy for .rej files if we
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 87137d8ede2..4b56f1b795c 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -739,6 +739,7 @@
739(require 'cl-lib) 739(require 'cl-lib)
740 740
741(declare-function diff-setup-whitespace "diff-mode" ()) 741(declare-function diff-setup-whitespace "diff-mode" ())
742(declare-function diff-setup-buffer-type "diff-mode" ())
742 743
743(eval-when-compile 744(eval-when-compile
744 (require 'dired)) 745 (require 'dired))
@@ -1739,7 +1740,7 @@ to override the value of `vc-diff-switches' and `diff-switches'."
1739 (insert (cdr messages) ".\n") 1740 (insert (cdr messages) ".\n")
1740 (message "%s" (cdr messages)))) 1741 (message "%s" (cdr messages))))
1741 (diff-setup-whitespace) 1742 (diff-setup-whitespace)
1742 (diff-setup-buffer-type) 1743 (diff-setup-buffer-type)
1743 (goto-char (point-min)) 1744 (goto-char (point-min))
1744 (when window 1745 (when window
1745 (shrink-window-if-larger-than-buffer window))) 1746 (shrink-window-if-larger-than-buffer window)))