]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cfengine.el
Cleanup cfengine3-mode so complete-symbol works again.
[gnu-emacs] / lisp / progmodes / cfengine.el
index 802561811872953a6fdd0a3f6b21b7f49004d3da..8d06041f919bd74c65ea2a11f8209d01ddb63bf1 100644 (file)
@@ -1165,24 +1165,18 @@ Intended as the value of `indent-line-function'."
 ;; CLASS: [.|&!()a-zA-Z0-9_\200-\377]+::
 ;; CATEGORY: [a-zA-Z_]+:
 
-(defun cfengine3--current-word (&optional bounds)
-  "Propose a word around point in the current CFEngine 3 buffer."
-  (save-excursion
-    (skip-syntax-forward "w_")
-    (when (search-backward-regexp
-           cfengine-mode-syntax-functions-regex
-           (point-at-bol)
-           t)
-      (if bounds
-          (list (point) (match-end 1))
-        (match-string 1)))))
-
 (defun cfengine3--current-function ()
   "Look up current CFEngine 3 function"
   (let* ((syntax (cfengine3-make-syntax-cache))
          (flist (assq 'functions syntax)))
     (when flist
-      (let ((w (cfengine3--current-word)))
+      (let ((w (save-excursion
+                 (skip-syntax-forward "w_")
+                 (when (search-backward-regexp
+                        cfengine-mode-syntax-functions-regex
+                        (point-at-bol)
+                        t)
+                   (match-string 1)))))
         (and w (assq (intern w) flist))))))
 
 ;; format from "cf-promises -s json", e.g. "sort" function:
@@ -1271,7 +1265,10 @@ see.  Use it by executing `turn-on-eldoc-mode'."
 (defun cfengine3-completion-function ()
   "Return completions for function name around or before point."
   (cfengine3-make-syntax-cache)
-  (let* ((bounds (cfengine3--current-word t))
+  (let* ((bounds (save-excursion
+                   (let ((p (point)))
+                     (skip-syntax-backward "w_" (point-at-bol))
+                     (list (point) p))))
          (syntax (cfengine3-make-syntax-cache))
          (flist (assq 'functions syntax)))
     (when bounds