branch: elpa/git-commit
commit 76fe46c098498deab54b6c5b11731e970040a52b
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    Place declare-function at top-level
    
    As suggested by Stefan Monnier:
    
    > I just saw this code in emacsql:
    >
    >     (unless (require 'sqlite3 nil t)
    >       (declare-function sqlite3-open "sqlite3-api")
    >       (declare-function sqlite3-exec "sqlite3-api")
    >       (declare-function sqlite3-close "sqlite3-api"))
    >
    > This isn't right: the `require` and the `unless` will be executed only at
    > runtime, not during compilation, but that that time the
    > `declare-function`s will have disappeared, so you'll end up running
    >
    >     (unless (require 'sqlite3 nil t)
    >       )
    >
    > Also the effect of `declare-function` should be limited to "the current
    > scope", which could be argued to end at the end of the `unless` (I don't
    > know if that's how the byte-compiler currently treats it, but that's how
    > I think it should, ideally).
    >
    > So I think you want to just remove the `unless`.
    > This way both the `require` and the `declare-function`s will be at
    > top-level where the compiler likes them to be.
---
 lisp/git-commit.el | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lisp/git-commit.el b/lisp/git-commit.el
index 7d77fa0075..aeefd68988 100644
--- a/lisp/git-commit.el
+++ b/lisp/git-commit.el
@@ -127,15 +127,15 @@
 (require 'with-editor)
 
 ;; For historic reasons Magit isn't a hard dependency.
-(unless (and (require 'magit-base nil t)
-             (require 'magit-git nil t))
-  (declare-function magit-completing-read "magit-base"
-                    ( prompt collection &optional predicate require-match
-                      initial-input hist def fallback))
-  (declare-function magit-expand-git-file-name "magit-git" (filename))
-  (declare-function magit-git-lines "magit-git" (&rest args))
-  (declare-function magit-hook-custom-get "magit-base" (symbol))
-  (declare-function magit-list-local-branch-names "magit-git" ()))
+(require 'magit-base nil t)
+(require 'magit-git nil t)
+(declare-function magit-completing-read "magit-base"
+                  ( prompt collection &optional predicate require-match
+                    initial-input hist def fallback))
+(declare-function magit-expand-git-file-name "magit-git" (filename))
+(declare-function magit-git-lines "magit-git" (&rest args))
+(declare-function magit-hook-custom-get "magit-base" (symbol))
+(declare-function magit-list-local-branch-names "magit-git" ())
 
 (defvar diff-default-read-only)
 (defvar flyspell-generic-check-word-predicate)

Reply via email to