From 5b9b750ae038c45377d04355739477c6dae37cb1 Mon Sep 17 00:00:00 2001 From: Ted Zlatanov Date: Mon, 16 Dec 2013 10:49:25 -0500 Subject: [PATCH] Cleanup cfengine3-mode so complete-symbol works again. * progmodes/cfengine.el (cfengine3--current-word): Remove. (cfengine3--current-function): Bring in the current-function functionality from `cfengine3--current-word'. (cfengine3-completion-function): Bring in the bounds-of-current-word functionality from `cfengine3--current-word'. --- lisp/ChangeLog | 9 +++++++++ lisp/progmodes/cfengine.el | 25 +++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5876dc37fbf..9ccc510ce1a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2013-12-16 Teodor Zlatanov + + * progmodes/cfengine.el (cfengine3--current-word): Remove. + (cfengine3--current-function): Bring in the current-function + functionality from `cfengine3--current-word'. + (cfengine3-completion-function): Bring in the + bounds-of-current-word functionality from + `cfengine3--current-word'. + 2013-12-16 Martin Rudalics * window.el (display-buffer-below-selected): Bind diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el index 80256181187..8d06041f919 100644 --- a/lisp/progmodes/cfengine.el +++ b/lisp/progmodes/cfengine.el @@ -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 -- 2.39.2