From dcf93b3f4cf0f2f7e4f9f16d10dfd475a26d28d2 Mon Sep 17 00:00:00 2001 From: Anastasios Grammenos Date: Sat, 26 Sep 2020 13:22:30 +0300 Subject: Update fcomp.el in light of company-mode support --- fcomp.el | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'fcomp.el') diff --git a/fcomp.el b/fcomp.el index 40a0e5b..e765162 100644 --- a/fcomp.el +++ b/fcomp.el @@ -128,24 +128,30 @@ (process-send-string proc "\n") (process-send-eof proc) (if (accept-process-output proc nil nil t) - (if x - (message "%s" "blabla") - (fcomp--handle-output)) + (unless x + (fcomp--handle-output)) (progn - (message "No completion for %s" word) + (unless x + (message "No completion for %s" word)) (delete-process proc))))) +(defun fcomp--make-syntax-table () + "Modifies the current active sytanx table to include '_', '-' +and `fcomp-extra-valid-chars' as part of a word." + ;; Thanks Dan for the syntax-table trick + ;; https://emacs.stackexchange.com/questions/9583/how-to-treat-underscore-as-part-of-the-word + (let ((table (copy-syntax-table (syntax-table)))) + (when (not (empty-string-p fcomp-extra-valid-chars)) + (mapc (lambda (char) (modify-syntax-entry char "w" table)) fcomp-extra-valid-chars)) + (modify-syntax-entry ?- "w" table) + (modify-syntax-entry ?_ "w" table) + (copy-syntax-table table))) + (defun fcomp-get-canditates (word) - "" + "Return a list of candidates for WORD curated by fcomp." (progn - (let ((table (copy-syntax-table (syntax-table)))) - (modify-syntax-entry ?- "w" table) - (modify-syntax-entry ?_ "w" table) - (when (not (empty-string-p fcomp-extra-valid-chars)) - (mapc (lambda (char) (modify-syntax-entry char "w" table)) fcomp-extra-valid-chars)) - (with-syntax-table table - (fcomp--autocomplete word (point) t))) - (remove "" (split-string fcomp--output "\n")))) + (fcomp--autocomplete word (point) t)) + (remove "" (split-string fcomp--output "\n"))) (defun fcomp-autocomplete () "Autocompete using fcomp.c @@ -154,20 +160,14 @@ When `thing-at-point' is a word, autocomplete it based on buffer contents. When invoked with no `thing-at-point' show a list of all possible candidates. -The syntax-table is temporarily modified and includes '_' '-' and +The syntax-table is temporarily modified and includes '_', '-' and `fcomp-extra-valid-chars' as part of a word. -Requires fcomp. Get it at URL `https://ubuntos.dynu.net/git/fcomp'" - ;; Thanks Dan for the syntax-table trick - ;; https://emacs.stackexchange.com/questions/9583/how-to-treat-underscore-as-part-of-the-word +Requires fcomp. Get it at URL `https://git.eyesin.space/git/fcomp'" (interactive) - (let ((table (copy-syntax-table (syntax-table)))) - (modify-syntax-entry ?- "w" table) - (modify-syntax-entry ?_ "w" table) - (when (not (empty-string-p fcomp-extra-valid-chars)) - (mapc (lambda (char) (modify-syntax-entry char "w" table)) fcomp-extra-valid-chars)) - (with-syntax-table table - (fcomp--autocomplete (thing-at-point 'word 'no-properties) (point))))) + (with-syntax-table (fcomp--make-syntax-table) + (fcomp--autocomplete (thing-at-point 'word 'no-properties) (point)))) (provide 'fcomp) ;;; fcomp.el ends here + -- cgit v1.2.3