commit:     04dc62243b36c185e426df1eb80eadcbb482afb0
Author:     Maciej Barć <xgqt <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 17 00:31:00 2022 +0000
Commit:     Maciej Barć <xgqt <AT> gentoo <DOT> org>
CommitDate: Wed Aug 17 00:31:00 2022 +0000
URL:        
https://gitweb.gentoo.org/proj/company-ebuild.git/commit/?id=04dc6224

company-ebuild.el: change character syntax-table temporarily

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

 company-ebuild.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/company-ebuild.el b/company-ebuild.el
index ef4096b..b50900a 100644
--- a/company-ebuild.el
+++ b/company-ebuild.el
@@ -218,6 +218,14 @@ FILE-PATH is the location from which we start searching 
for Eclass files."
   (company-ebuild--regenerate-dynamic-keywords-packages)
   (company-ebuild--regenerate-dynamic-keywords-licenses))
 
+(defun company-ebuild--grab-symbol ()
+  "Workaround wrapper for `company-grab-symbol'."
+  ;; TODO: (Hard mode) write a proper `company-grab-symbol' replacement.
+  (with-syntax-table (copy-syntax-table (syntax-table))
+    (modify-syntax-entry ?/ "w")
+    (modify-syntax-entry ?@ "w")  ; To make Eclass tags work.
+    (company-grab-symbol)))
+
 
 ;;;###autoload
 (defun company-ebuild (command &optional arg &rest ignored)
@@ -242,7 +250,7 @@ ARG is the completion argument for annotation and 
candidates."
     (kind
      (cdr (company-ebuild--annotation-and-kind arg)))
     (prefix
-     (and (eq major-mode 'ebuild-mode) (company-grab-symbol)))
+     (and (eq major-mode 'ebuild-mode) (company-ebuild--grab-symbol)))
     (require-match
      nil)))
 
@@ -255,10 +263,6 @@ in your config:
 \(add-hook 'ebuild-mode-hook 'company-ebuild-setup)
 or `require' Company-Ebuild:
 \(require 'company-ebuild)"
-  ;; HACK: Modify syntax to treat "/" as a word constituent.
-  ;; TODO: (Hard mode) write a proper `company-grab-symbol' replacement.
-  (modify-syntax-entry ?/ "w")
-  (modify-syntax-entry ?@ "w")  ; To make Eclass tags work.
   ;; Force-enable `company-mode'.
   (when (null company-mode)
     (company-mode +1))

Reply via email to