commit:     39424f5d9ff5a79b69e0bf0b5ed2b94e51a90340
Author:     Maciej Barć <xgqt <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 20 13:05:16 2022 +0000
Commit:     Maciej Barć <xgqt <AT> gentoo <DOT> org>
CommitDate: Sat Aug 20 13:05:16 2022 +0000
URL:        
https://gitweb.gentoo.org/proj/company-ebuild.git/commit/?id=39424f5d

company-ebuild-custom.el: add; enable customization of some features from 
company-ebuild.el

Signed-off-by: Maciej Barć <xgqt <AT> gentoo.org>

 Cask                     |  3 ++-
 Makefile                 |  2 +-
 company-ebuild-custom.el | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
 company-ebuild.el        | 23 +++++++++-------
 4 files changed, 86 insertions(+), 12 deletions(-)

diff --git a/Cask b/Cask
index 250f6e3..90b5586 100644
--- a/Cask
+++ b/Cask
@@ -2,7 +2,8 @@
 
 (package-file "company-ebuild.el")
 
-(files "company-ebuild-keywords.el"
+(files "company-ebuild-custom.el"
+       "company-ebuild-keywords.el"
        "company-ebuild.el")
 
 (development (depends-on "company")

diff --git a/Makefile b/Makefile
index c89fa82..606ff5d 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ clean:
        $(EMACSCMD) --eval "(byte-compile-file \"$(*).el\" 0)"
 
 .PHONY: compile
-compile: company-ebuild-keywords.elc company-ebuild.elc
+compile: company-ebuild-custom.elc company-ebuild-keywords.elc 
company-ebuild.elc
 
 
 .PHONY: install

diff --git a/company-ebuild-custom.el b/company-ebuild-custom.el
new file mode 100644
index 0000000..3df3e03
--- /dev/null
+++ b/company-ebuild-custom.el
@@ -0,0 +1,70 @@
+;;; company-ebuild-custom.el --- Company-Ebuild customization -*- 
lexical-binding: t -*-
+
+
+
+;; Copyright 2022 Gentoo Authors
+
+
+;; This file is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 2 of the License, or
+;; (at your option) any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+
+
+;;; Commentary:
+
+
+;; Company-Ebuild customization.
+
+
+
+;;; Code:
+
+
+(defgroup company-ebuild nil
+  "Company backend for editing Ebuild files."
+  :group 'company
+  :group 'ebuild)
+
+
+(defcustom company-ebuild-qsearch-executable (executable-find "qsearch")
+  "Path to the \"qsearch\" executable binary."
+  :safe 'stringp
+  :type 'file
+  :group 'company-ebuild)
+
+(defcustom company-ebuild--regenerate-dynamic-keywords-eclass t
+  "Whether to regenerate ‘company-ebuild--dynamic-keywords-eclass’."
+  :type 'boolean
+  :group 'company-ebuild)
+
+(defcustom company-ebuild--regenerate-dynamic-keywords-use-flags t
+  "Whether to regenerate ‘company-ebuild--dynamic-keywords-use-flags’."
+  :type 'boolean
+  :group 'company-ebuild)
+
+(defcustom company-ebuild--regenerate-dynamic-keywords-packages t
+  "Whether to regenerate ‘company-ebuild--dynamic-keywords-packages’."
+  :type 'boolean
+  :group 'company-ebuild)
+
+(defcustom company-ebuild--regenerate-dynamic-keywords-licenses t
+  "Whether to regenerate ‘company-ebuild--dynamic-keywords-licenses’."
+  :type 'boolean
+  :group 'company-ebuild)
+
+
+(provide 'company-ebuild-custom)
+
+
+
+;;; company-ebuild-custom.el ends here

diff --git a/company-ebuild.el b/company-ebuild.el
index d01160f..30f564a 100644
--- a/company-ebuild.el
+++ b/company-ebuild.el
@@ -44,6 +44,7 @@
 (require 'company)
 (require 'ebuild-mode)
 
+(require 'company-ebuild-custom)
 (require 'company-ebuild-keywords)
 
 
@@ -94,25 +95,23 @@
   "Return a list of all available packages.
 
 Uses the \"qsearch\" tool to get the packages."
-  (let ((qsearch
-         (executable-find "qsearch"))
-        (qsearch-formats
+  (let ((qsearch-formats
          '("%{CATEGORY}/%{PN}"
            "%{CATEGORY}/%{PN}-%{PV}"
            "%{CATEGORY}/%{PN}-%{PV}:%{SLOT}"
            "%{CATEGORY}/%{PN}-%{PV}:%{SLOT}::%{REPO}")))
     (cond
-     (qsearch
+     (company-ebuild-qsearch-executable
       (mapcan (lambda (qsearch-format)
                 (let ((qlist-result
                        (shell-command-to-string
                         (format "%s --all --format \"%s\" --name-only 
--nocolor"
-                                qsearch
+                                company-ebuild-qsearch-executable
                                 qsearch-format))))
                   (split-string qlist-result "\n" t)))
               qsearch-formats))
      (t
-      nil))))
+      '()))))
 
 (defun company-ebuild--get-tags (file-path tag-name)
   "Return all tags with TAG-NAME from file at FILE-PATH.
@@ -205,10 +204,14 @@ REPO-ROOT is the location from which we start searching 
for Eclass files."
 
 (defun company-ebuild--regenerate-dynamic-keywords ()
   "Regenerate dynamic keywords."
-  (company-ebuild--regenerate-dynamic-keywords-eclass)
-  (company-ebuild--regenerate-dynamic-keywords-use-flags)
-  (company-ebuild--regenerate-dynamic-keywords-packages)
-  (company-ebuild--regenerate-dynamic-keywords-licenses))
+  (when company-ebuild--regenerate-dynamic-keywords-eclass
+    (company-ebuild--regenerate-dynamic-keywords-eclass))
+  (when company-ebuild--regenerate-dynamic-keywords-use-flags
+    (company-ebuild--regenerate-dynamic-keywords-use-flags))
+  (when company-ebuild--regenerate-dynamic-keywords-use-flags
+    (company-ebuild--regenerate-dynamic-keywords-packages))
+  (when company-ebuild--regenerate-dynamic-keywords-licenses
+    (company-ebuild--regenerate-dynamic-keywords-licenses)))
 
 (defun company-ebuild--grab-symbol ()
   "Workaround wrapper for `company-grab-symbol'."

Reply via email to