Subject: bug#79168: [PATCH 03/11] Reorder code to put defcustom/defvar at the beginning part

From: Xiyue Deng <[email-masked]>
Date: Sun, 3 Aug 2025 17:20:41 -0700

Adapted from bug#52476 by Aleksandr Vityazev.
---
 oauth2.el | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/oauth2.el b/oauth2.el
index c3aa45ed69..eccf439130 100644
--- a/oauth2.el
+++ b/oauth2.el
@@ -53,9 +53,17 @@
   :link '(url-link :tag "Savannah" "https://git.savannah.gnu.org/cgit/emacs/elpa.git/tree/?h=externals/oauth2")
   :link '(url-link :tag "ELPA" "https://elpa.gnu.org/packages/oauth2.html"))
 
+(defcustom oauth2-token-file (concat user-emacs-directory "oauth2.plstore")
+  "File path where store OAuth tokens."
+  :group 'oauth2
+  :type 'file)
+
 (defvar oauth2-debug nil
   "Enable verbose logging in oauth2 to help debugging.")
 
+(defvar oauth--url-advice nil)
+(defvar oauth--token-data)
+
 (defun oauth2--do-debug (&rest msg)
   "Output debug messages when `oauth2-debug' is enabled."
   (when oauth2-debug
@@ -174,11 +182,6 @@ TOKEN should be obtained with `oauth2-request-access'."
     auth-url client-id scope state redirect-uri)
    redirect-uri))
 
-(defcustom oauth2-token-file (concat user-emacs-directory "oauth2.plstore")
-  "File path where store OAuth tokens."
-  :group 'oauth2
-  :type 'file)
-
 (defun oauth2-compute-id (auth-url token-url scope client-id)
   "Compute an unique id based on URLs.
 This allows to store the token in an unique way."
@@ -222,9 +225,6 @@ This allows to store the token in an unique way."
           (if (string-match-p "\?" url) "&" "?")
           "access_token=" (oauth2-token-access-token token)))
 
-(defvar oauth--url-advice nil)
-(defvar oauth--token-data)
-
 (defun oauth2-authz-bearer-header (token)
   "Return `Authoriztions: Bearer' header with TOKEN."
   (cons "Authorization" (format "Bearer %s" token)))
-- 
2.39.5