Klimi's new dotfiles with stow.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

82 Zeilen
2.5 KiB

vor 5 Jahren
  1. ;;; company-ispell.el --- company-mode completion backend using Ispell
  2. ;; Copyright (C) 2009-2011, 2013-2016 Free Software Foundation, Inc.
  3. ;; Author: Nikolaj Schumacher
  4. ;; This file is part of GNU Emacs.
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;;
  17. ;;; Code:
  18. (require 'company)
  19. (require 'cl-lib)
  20. (require 'ispell)
  21. (defgroup company-ispell nil
  22. "Completion backend using Ispell."
  23. :group 'company)
  24. (defcustom company-ispell-dictionary nil
  25. "Dictionary to use for `company-ispell'.
  26. If nil, use `ispell-complete-word-dict'."
  27. :type '(choice (const :tag "default (nil)" nil)
  28. (file :tag "dictionary" t)))
  29. (defvar company-ispell-available 'unknown)
  30. (defalias 'company-ispell--lookup-words
  31. (if (fboundp 'ispell-lookup-words)
  32. 'ispell-lookup-words
  33. 'lookup-words))
  34. (defun company-ispell-available ()
  35. (when (eq company-ispell-available 'unknown)
  36. (condition-case err
  37. (progn
  38. (company-ispell--lookup-words "WHATEVER")
  39. (setq company-ispell-available t))
  40. (error
  41. (message "Company-Ispell: %s" (error-message-string err))
  42. (setq company-ispell-available nil))))
  43. company-ispell-available)
  44. ;;;###autoload
  45. (defun company-ispell (command &optional arg &rest ignored)
  46. "`company-mode' completion backend using Ispell."
  47. (interactive (list 'interactive))
  48. (cl-case command
  49. (interactive (company-begin-backend 'company-ispell))
  50. (prefix (when (company-ispell-available)
  51. (company-grab-word)))
  52. (candidates
  53. (let ((words (company-ispell--lookup-words
  54. arg
  55. (or company-ispell-dictionary ispell-complete-word-dict)))
  56. (completion-ignore-case t))
  57. (if (string= arg "")
  58. ;; Small optimization.
  59. words
  60. ;; Work around issue #284.
  61. (all-completions arg words))))
  62. (sorted t)
  63. (ignore-case 'keep-prefix)))
  64. (provide 'company-ispell)
  65. ;;; company-ispell.el ends here