X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/cb0a58684509ba5d3546d7d08a11b136ca294c11..9b89556880e326ec3391cfda2a87eada101eaaae:/company-ispell.el diff --git a/company-ispell.el b/company-ispell.el index 05266af82..c275bbe41 100644 --- a/company-ispell.el +++ b/company-ispell.el @@ -1,6 +1,6 @@ -;;; company-ispell.el --- A company-mode completion back-end using ispell +;;; company-ispell.el --- company-mode completion backend using Ispell -;; Copyright (C) 2009-2011 Free Software Foundation, Inc. +;; Copyright (C) 2009-2011, 2013-2016 Free Software Foundation, Inc. ;; Author: Nikolaj Schumacher @@ -26,23 +26,31 @@ ;;; Code: (require 'company) +(require 'cl-lib) (require 'ispell) -(eval-when-compile (require 'cl)) + +(defgroup company-ispell nil + "Completion backend using Ispell." + :group 'company) (defcustom company-ispell-dictionary nil - "*Dictionary to use for `company-ispell'. + "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))) (defvar company-ispell-available 'unknown) +(defalias 'company-ispell--lookup-words + (if (fboundp 'ispell-lookup-words) + 'ispell-lookup-words + 'lookup-words)) + (defun company-ispell-available () (when (eq company-ispell-available 'unknown) (condition-case err (progn - (lookup-words "WHATEVER") + (company-ispell--lookup-words "WHATEVER") (setq company-ispell-available t)) (error (message "Company: ispell-look-command not found") @@ -51,16 +59,24 @@ If nil, use `ispell-complete-word-dict'." ;;;###autoload (defun company-ispell (command &optional arg &rest ignored) - "A `company-mode' completion back-end using ispell." + "`company-mode' completion backend using Ispell." (interactive (list 'interactive)) - (case command + (cl-case command (interactive (company-begin-backend 'company-ispell)) (prefix (when (company-ispell-available) (company-grab-word))) - (candidates (lookup-words arg (or company-ispell-dictionary - ispell-complete-word-dict))) + (candidates + (let ((words (company-ispell--lookup-words + arg + (or company-ispell-dictionary ispell-complete-word-dict))) + (completion-ignore-case t)) + (if (string= arg "") + ;; Small optimization. + words + ;; Work around issue #284. + (all-completions arg words)))) (sorted t) - (ignore-case t))) + (ignore-case 'keep-prefix))) (provide 'company-ispell) ;;; company-ispell.el ends here