diff options
Diffstat (limited to 'fcomp.el')
-rw-r--r-- | fcomp.el | 48 |
1 files changed, 24 insertions, 24 deletions
@@ -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 + |