--- /dev/null
+(require 'company)
+(require 'ispell)
+(eval-when-compile (require 'cl))
+
+(defcustom company-ispell-dictionary nil
+ "*Dictionary to use for `company-ispell'.
+If nil, use `ispell-complete-word-dict'."
+ :group 'company
+ :type '(choice (const :tag "default (nil)" nil)
+ (file :tag "dictionary" t)))
+
+(defun company-ispell (command &optional arg &rest ignored)
+ (case command
+ ('prefix (company-grab "\\<\\w+\\>"))
+ ('candidates (lookup-words arg (or company-ispell-dictionary
+ ispell-complete-word-dict)))
+ ('sorted t)
+ ('ignore-case t)))
+
+(provide 'company-ispell)
+;;; company-ispell.el ends here
company-preview-if-just-one-frontend)
(function :tag "custom function" nil))))
-(defcustom company-backends '(company-elisp company-nxml company-css)
+(defcustom company-backends '(company-elisp company-nxml company-css
+ company-ispell)
"*"
:group 'company
:type '(repeat (function :tag "function" nil)))
(let ((offset (- company-selection display-limit -1)))
(max offset 0)))
+(defsubst company-reformat (candidate)
+ ;; company-ispell needs this, because the results are always lower-case
+ ;; It's mory efficient to fix it only when they are displayed.
+ (concat company-prefix (substring candidate (length company-prefix))))
+
(defsubst company-should-complete (prefix)
(and (eq company-idle-delay t)
(>= (length prefix) company-minimum-prefix-length)))
(defun company-begin ()
(or (company-continue-or-cancel)
- (let ((completion-ignore-case nil) ;; TODO: make this optional
- prefix)
+ (let (prefix)
(dolist (backend company-backends)
(unless (fboundp backend)
(ignore-errors (require backend nil t)))
company-candidates
(funcall company-backend 'candidates prefix)
company-common
- (try-completion prefix company-candidates)
+ (let ((completion-ignore-case (funcall backend
+ 'ignore-case)))
+ (try-completion prefix company-candidates))
company-selection 0
company-point (point))
(unless (funcall company-backend 'sorted)
(setq width (max (length (pop lines-copy)) width)))
(setq width (min width (- (window-width) column)))
(dotimes (i len)
- (push (company-fill-propertize (pop lines) width (equal i selection))
+ (push (company-fill-propertize (company-reformat (pop lines))
+ width (equal i selection))
new))
(nreverse new)))
(len -1)
comp msg)
(while candidates
- (setq comp (pop candidates)
+ (setq comp (company-reformat (pop candidates))
len (+ len 1 (length comp)))
(if (>= len limit)
(setq candidates nil)