summaryrefslogtreecommitdiffstats
path: root/fcomp.el
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2019-03-20 19:34:39 +0200
committergramanas <anastasis.gramm2@gmail.com>2019-03-20 19:34:39 +0200
commit90dc7b2d2f19944b5be9b19175db14a7ece35c99 (patch)
tree61fdd1eef6528d14eddb260fbc3926bb96674d8c /fcomp.el
parent896c4369bb9cd38aa828516f084df54e35f1371e (diff)
downloadfcomp-90dc7b2d2f19944b5be9b19175db14a7ece35c99.tar.gz
fcomp-90dc7b2d2f19944b5be9b19175db14a7ece35c99.tar.bz2
fcomp-90dc7b2d2f19944b5be9b19175db14a7ece35c99.zip
Add uniq flag for print_all and emacs frontend
Diffstat (limited to 'fcomp.el')
-rw-r--r--fcomp.el108
1 files changed, 108 insertions, 0 deletions
diff --git a/fcomp.el b/fcomp.el
new file mode 100644
index 0000000..4e046d9
--- /dev/null
+++ b/fcomp.el
@@ -0,0 +1,108 @@
+;;; fcomp.el --- fcomp front-end -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2019 Anastasis Grammenos
+
+;; Author: Anastasis Grammenos <anastasis.gramm2@gmail.com>
+;; Keywords: lisp
+;; Version: 0.0.1
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Emacs front-end for fcomp. Get if from https://ubuntos.dynu.net/git/fcomp
+
+;;; Install:
+
+;; git clone https://ubuntos.dynu.net/git/fcomp && cd fcomp
+;; make && sudo ln -s fcomp /usr/local/bin/fcomp # or mv
+
+;; In the emacs init file:
+;; (add-to-list 'load-path "/your/custom/path")
+;; (require 'fcomp)
+;; (setq fcomp-path "/your/custom/path/fcomp")
+;; (global-set-key (kbd "M-i") 'fcomp-autocomplete)
+
+;; or with use-package
+;; (use-package fcomp
+;; :load-path "/your/custom/path"
+;; :bind (("M-i" . fcomp-autocomplete))
+;; :config
+;; (setq fcomp-path "/your/custom/path/fcomp"))
+
+
+;;; Code:
+
+(require 'ido)
+(require 'subr-x)
+
+(defvar fcomp-path "/usr/local/bin/fcomp")
+(defvar fcomp-min-word-length 3)
+(defvar fcomp-extra-valid-chars "")
+(defvar fcomp-extra-invalid-chars "")
+
+(defun pr ()
+ (message "Status: %s" (process-status "fcomp")))
+
+;; (thing-at-point 'word 'no-properties)
+(defun fcomp-filter (proc str)
+ (let* ((fcomp-pre
+ (if (null (process-get proc 'input-word))
+ nil
+ (format "%s" (process-get proc 'input-word)))))
+ ;; (enable-recursive-minibuffers t))
+ ;; (setq result (substring result (* -1 (- (length result) (length word))) nil))
+ (progn
+ (pr)
+ (setq result
+ (ido-completing-read
+ "Complete:"
+ (remove "" (split-string str "\n"))
+ nil nil
+ fcomp-pre))
+ (if (null result)
+ nil
+ (insert
+ (string-remove-prefix
+ (if (null fcomp-pre)
+ (format "%s" "")
+ (format "%s" fcomp-pre))
+ result))))))
+
+(defun fcomp-autocomplete ()
+ (interactive)
+ (fcomp--autocomplete (thing-at-point 'word 'no-properties)))
+
+(defun fcomp--autocomplete (word)
+ "Do stuff and ac"
+ (let ((term (if (null word)
+ (format "%s" "-au")
+ (format "%s" word)))
+ (input (buffer-substring-no-properties (point-min) (point-max))))
+ (with-temp-buffer
+ (set-process-filter
+ (start-process
+ "fcomp"
+ nil
+ fcomp-path
+ "-w" (format "%s" fcomp-min-word-length)
+ "-F" input
+ "-v" (format "%s" fcomp-extra-valid-chars)
+ "-i" (format "%s" fcomp-extra-invalid-chars)
+ term)
+ #'fcomp-filter)
+ (process-put (get-process "fcomp") 'input-word word))))
+
+(provide 'fcomp)
+;;; fcomp.el ends here