branch: externals/diff-hl
commit 11244fbc936df763d01014a0e759c1643295adfa
Merge: 6585e93849 f26003b6fa
Author: Dmitry Gutov <[email protected]>
Commit: GitHub <[email protected]>

    Merge pull request #255 from tarsiiformes/silencio
    
    Fix compiler warnings
---
 diff-hl.el | 69 ++++++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 40 insertions(+), 29 deletions(-)

diff --git a/diff-hl.el b/diff-hl.el
index edb99c2312..338ee98e7c 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -69,11 +69,20 @@
   (require 'vc-git)
   (require 'vc-hg)
   (require 'face-remap)
-  (declare-function project-buffers 'project)
-  (declare-function project-name 'project)
-  (declare-function project-roots 'project)
+  (require 'project)
   (declare-function smartrep-define-key 'smartrep))
 
+(defmacro static-if (condition then-form &rest else-forms) ; since Emacs 30.1
+  "A conditional compilation macro.
+Evaluate CONDITION at macro-expansion time.  If it is non-nil,
+expand the macro to THEN-FORM.  Otherwise expand it to ELSE-FORMS
+enclosed in a `progn' form.  ELSE-FORMS may be empty."
+  (declare (indent 2)
+           (debug (sexp sexp &rest sexp)))
+  (if (eval condition lexical-binding)
+      then-form
+    (cons 'progn else-forms)))
+
 (defgroup diff-hl nil
   "VC diff highlighting on the side of a window"
   :group 'vc)
@@ -385,35 +394,37 @@ It can be a relative expression as well, such as 
\"HEAD^\" with Git, or
     (ignored 'diff-hl-bmp-i)
     (t (intern (format "diff-hl-bmp-%s" type)))))
 
-(defvar vc-svn-diff-switches)
-(defvar vc-fossil-diff-switches)
-(defvar vc-jj-diff-switches)
-
 (defmacro diff-hl-with-diff-switches (body)
-  `(let ((vc-git-diff-switches
-          ;; https://github.com/dgutov/diff-hl/issues/67
-          (cons "-U0"
-                ;; https://github.com/dgutov/diff-hl/issues/9
-                (and (boundp 'vc-git-diff-switches)
-                     (listp vc-git-diff-switches)
-                     (cl-remove-if-not
-                      (lambda (arg)
-                        (member arg '("--histogram" "--patience" "--minimal" 
"--textconv")))
-                      vc-git-diff-switches))))
-         (vc-hg-diff-switches nil)
-         (vc-svn-diff-switches nil)
-         (vc-fossil-diff-switches '("-c" "0"))
-         (vc-jj-diff-switches '("--git" "--context=0"))
-         (vc-diff-switches '("-U0"))
-         ,@(when (boundp 'vc-disable-async-diff)
-             '((vc-disable-async-diff t))))
-     ,body))
+  `(progn
+     (defvar vc-svn-diff-switches)
+     (defvar vc-fossil-diff-switches)
+     (defvar vc-jj-diff-switches)
+     (let ((vc-git-diff-switches
+            ;; https://github.com/dgutov/diff-hl/issues/67
+            (cons "-U0"
+                  ;; https://github.com/dgutov/diff-hl/issues/9
+                  (and (boundp 'vc-git-diff-switches)
+                       (listp vc-git-diff-switches)
+                       (cl-remove-if-not
+                        (lambda (arg)
+                          (member arg '("--histogram" "--patience" "--minimal" 
"--textconv")))
+                        vc-git-diff-switches))))
+           (vc-hg-diff-switches nil)
+           (vc-svn-diff-switches nil)
+           (vc-fossil-diff-switches '("-c" "0"))
+           (vc-jj-diff-switches '("--git" "--context=0"))
+           (vc-diff-switches '("-U0"))
+           ,@(when (boundp 'vc-disable-async-diff)
+               '((vc-disable-async-diff t))))
+       ,body)))
 
 (defun diff-hl-modified-p (state)
   (or (memq state '(edited conflict))
       (and (eq state 'up-to-date)
            ;; VC state is stale in after-revert-hook.
-           (or revert-buffer-in-progress-p
+           (or (static-if (>= emacs-major-version 31)
+                   revert-buffer-in-progress
+                 revert-buffer-in-progress-p)
                ;; Diffing against an older revision.
                diff-hl-reference-revision))))
 
@@ -1666,9 +1677,9 @@ effect."
 
 (defun diff-hl--project-root (proj)
   ;; Emacs 26 and 27 don't have `project-root'.
-  (expand-file-name
-   (or (and (fboundp 'project-root) (project-root proj))
-       (project-roots proj))))
+  (expand-file-name (static-if (>= emacs-major-version 28)
+                        (project-root proj)
+                      (project-roots proj))))
 
 (defun diff-hl-set-reference-rev-in-project-internal (rev proj)
   (let* ((root (diff-hl--project-root proj)))

Reply via email to