Make checkdoc and package linter happy

master
Adam Kruszewski 2023-07-03 16:01:07 +02:00
parent b5b2b4c498
commit 4f9d20a47f
1 changed files with 28 additions and 25 deletions

View File

@ -1,16 +1,16 @@
;;; cape-jinx-completion.el --- Completion At Point Extensions using Jinx spell checking -*- lexical-binding: t -*-
;; Copyright (C) 2023 Free Software Foundation, Inc.
;; Copyright (C) 2021-2023 Adam Kruszewski
;; Author: Adam Kruszewski <adam@kruszewski.name>
;; Maintainer: Adam Kruszewski <adam@kruszewski.name>
;; Created: 2023
;; Version: 1.0
;; Package-Requires: ((emacs "27.1") (compat "29.1.4.0") (cape "0.15") (jinx "0.5"))
;; Package-Requires: ((emacs "28.1") (compat "29.1.4.0") (cape "0.15") (jinx "0.5"))
;; Homepage: https://code.bsdgeek.org/adam/cape-jinx-completion
;; Keywords: completion, spell-check
;; Keywords: convenience, completion, spell-check
;; This file is part of GNU Emacs.
;; This file is not part of GNU Emacs.
;; 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
@ -35,14 +35,17 @@
;; and C module bridge to enchant library.
;;
;; Having jinx and cape configured you just need to add:
;; (add-to-list 'completion-at-point-functions #'cape-jinx)
;; (add-to-list 'completion-at-point-functions #'cape-jinx-completion)
;; cape-jinx-completion to your completions-at-point-functions.
;;; Code:
(require 'cape)
(require 'jinx)
;; jinx.el version 0.5 is required
(defun jinx-suggest-for-word (word)
(defun cape-jinx-completion-suggest-for-word (word)
"Return suggestions as a list for `WORD'."
(when (not jinx--dicts)
(when (not (fboundp #'jinx--mod-dict))
(jinx--load-module))
@ -54,53 +57,53 @@
(cl-pushnew el result))))
(delete-dups result)))
;; cape-jinx (based on cape-dict)
(defgroup cape-jinx nil
;; cape-jinx-completion (based on cape-dict)
(defgroup cape-jinx-completion nil
"Completion At Point extensions using Jinx spell checking."
:prefix "cape-jinx"
:group 'cape-jinx)
:prefix "cape-jinx-completion"
:group 'cape-jinx-completion)
(defcustom cape-jinx-case-replace 'case-replace
(defcustom cape-jinx-completion-case-replace 'case-replace
"Preserve case of input.
See `dabbrev-case-replace' for details."
See `dabbrev-case-replace' for details."
:type '(choice (const :tag "off" nil)
(const :tag "use `case-replace'" case-replace)
(other :tag "on" t)))
(defcustom cape-jinx-case-fold 'case-fold-search
(defcustom cape-jinx-completion-case-fold 'case-fold-search
"Case fold search during search.
See `dabbrev-case-fold-search' for details."
See `dabbrev-case-fold-search' for details."
:type '(choice (const :tag "off" nil)
(const :tag "use `case-fold-search'" case-fold-search)
(other :tag "on" t)))
(defvar cape--jinx-properties
(defvar cape-jinx-completion--properties
(list :annotation-function (lambda (_) " Jinx")
:company-kind (lambda (_) 'text)
:exclusive 'no)
"Completion extra properties for `cape-jinx'.")
"Completion extra properties for `cape-jinx-completion'.")
(defun cape--jinx-list (input)
(defun cape-jinx-completion--list (input)
"Return all words from Jinx spell checking mechanism matching INPUT."
(unless (equal input "")
(cape--case-replace-list
cape-jinx-case-replace input
(jinx-suggest-for-word input))))
cape-jinx-completion-case-replace input
(cape-jinx-completion-suggest-for-word input))))
;;;###autoload
(defun cape-jinx (&optional interactive)
(defun cape-jinx-completion (&optional interactive)
"Complete word from Jinx spell checking at point.
If INTERACTIVE is nil the function acts like a Capf."
If INTERACTIVE is nil the function acts like a Capf."
(interactive (list t))
(if interactive
(cape-interactive #'cape-jinx)
(cape-interactive #'cape-jinx-completion)
(pcase-let ((`(,beg . ,end) (cape--bounds 'word)))
`(,beg ,end
,(cape--table-with-properties
(completion-table-case-fold
(cape--cached-table beg end #'cape--jinx-list #'string-search)
(not (cape--case-fold-p cape-jinx-case-fold)))
:category 'cape-jinx)
(cape--cached-table beg end #'cape-jinx-completion--list #'string-search)
(not (cape--case-fold-p cape-jinx-completion-case-fold)))
:category 'cape-jinx-completion)
,@cape--jinx-properties))))
;;; cape-jinx-completion.el ends here