summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnastasios Grammenos <anastasios.grammenos@noris.gr>2020-09-26 13:22:30 +0300
committerAnastasios Grammenos <anastasios.grammenos@noris.gr>2020-09-26 13:22:30 +0300
commitdcf93b3f4cf0f2f7e4f9f16d10dfd475a26d28d2 (patch)
tree6f564fd44d2f7c633270f061d71b3718de05180a
parent42ba97c086c473f8abc52108ca6ceb276525e027 (diff)
downloadfcomp-dcf93b3f4cf0f2f7e4f9f16d10dfd475a26d28d2.tar.gz
fcomp-dcf93b3f4cf0f2f7e4f9f16d10dfd475a26d28d2.tar.bz2
fcomp-dcf93b3f4cf0f2f7e4f9f16d10dfd475a26d28d2.zip
Update fcomp.el in light of company-mode support
-rw-r--r--fcomp.el48
1 files changed, 24 insertions, 24 deletions
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
+