emacs: User configuration & loading
Users can now use the Gerrit Repo extension by requiring the modules
and doing minimal configuration.
BUG=chromium:1111775
TEST=Loaded using test Emacs init.el and tested gerrit-comments interface.
Change-Id: I8b45017b272cbaf3ca29be096437c8d637203674
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2331862
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Sean McAllister <smcallis@google.com>
Tested-by: Aaron Massey <aaronmassey@chromium.org>
Commit-Queue: Aaron Massey <aaronmassey@chromium.org>
diff --git a/contrib/emacs/gerrit-section.el b/contrib/emacs/gerrit-section.el
index 3fecb52..779436c 100644
--- a/contrib/emacs/gerrit-section.el
+++ b/contrib/emacs/gerrit-section.el
@@ -6,7 +6,7 @@
(require 'magit)
(require 'magit-section)
-(require 'repo-gerrit)
+(require 'gerrit)
(defface gerrit-filepath
@@ -112,7 +112,7 @@
(find-file-noselect (gerrit--get-abs-path-to-file
filepath-from-project-root
project-branch-pair
- test-repo-root)))
+ gerrit-repo-root)))
(goto-char (point-min))
(beginning-of-line line))
@@ -228,3 +228,7 @@
'face 'link)
(gethash "message" comment-info)))))
+
+
+(provide 'gerrit-section)
+(require 'gerrit-section)
diff --git a/contrib/emacs/gerrit.el b/contrib/emacs/gerrit.el
index 6a6ab75..145d008 100644
--- a/contrib/emacs/gerrit.el
+++ b/contrib/emacs/gerrit.el
@@ -6,18 +6,51 @@
(require 'request)
(require 'xml)
-;; TODO this is test code to be removed in future CL.
-;; The following will become user configuration options.
-(setq test-user "aaronmassey@chromium.org")
-(setq test-host "chromium-review.googlesource.com")
-(setq test-repo-root (file-name-as-directory "~/chromiumos"))
-(setq test-repo-manifest-path (expand-file-name ".repo/manifests/default.xml" test-repo-root))
-;; TODO Make our parser self-discoverable by project instead of a parameter.
-(setq test-manifest-parser (expand-file-name "src/platform/dev/contrib/emacs/manifest_parser"
- test-repo-root))
+
+(defcustom gerrit-repo-root
+ nil
+ "The system path to the repo project root."
+ :type 'string)
+
+(defcustom gerrit-repo-manifest
+ nil
+ "The system path path to repo manifest file."
+ :type 'string)
+
+(defcustom gerrit-user
+ nil
+ "The username associated with your account on Gerrit."
+ :type 'string)
+
+(defcustom gerrit-host
+ nil
+ "The Gerrit host you're interested in reviewing comments from."
+ :type 'string)
+
+(defconst gerrit--manifest-parser
+ (expand-file-name
+ "manifest_parser"
+ (file-name-directory load-file-name))
+ "The executable used to parse the repo manifest as an alist.")
+
+
+(defvar gerrit-repo-manifest
+ nil
+ "The system path path to repo manifest file.
+Default is repo_root_path/.repo/manifests/default.xml")
+
+
(defun gerrit-init ()
- (gerrit--init-global-comment-map test-host test-user)
- (gerrit--init-global-repo-project-path-map test-manifest-parser test-repo-manifest-path))
+ "Initialize Repo Gerrit state."
+ (unless gerrit-repo-manifest
+ (setq gerrit-repo-manifest
+ (expand-file-name
+ ".repo/manifests/default.xml"
+ gerrit-repo-root)))
+
+ (gerrit--init-global-comment-map gerrit-host gerrit-user)
+ (gerrit--init-global-repo-project-path-map gerrit--manifest-parser
+ gerrit-repo-manifest))
(defvar gerrit--change-to-filepath-comments nil
@@ -146,4 +179,5 @@
abs-path-to-repo-root))))
-(provide 'repo-gerrit)
+(provide 'gerrit)
+(require 'gerrit)