;; 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:
(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