minad / cape

🦸cape.el - Completion At Point Extensions
GNU General Public License v3.0
573 stars 20 forks source link

Questions on cape-word, cape-ispell and completion-at-point #74

Closed deb75 closed 1 year ago

deb75 commented 1 year ago

Hi,

I tried to use cape-ispell, it answers no completions. However, ispell-word works.

Actually, the ispell package is configured to use aspell command.

Am I missing something ?

For cape-dict, I noticed dictionnary files should be placed in cape-dict-file path, but which type of dictionaries are used ?

I configured several completion functions for orgmode :

(add-hook 'org-mode-hook
          (lambda ()
            (setq-local completion-at-point-functions
                        (mapcar #'cape-company-to-capf
                                (list #'company-math-symbols-latex #'company-org-block)))))

How completion-at-point works with several functions ? What will I be proposed first when completing at point ? Can I cycle between functions ?

Regards

minad commented 1 year ago

I tried to use cape-ispell, it answers no completions.

This must be an issue of your setup. ispell-word is different from ispell-lookup-words, which is used by cape-ispell.

For cape-dict, I noticed dictionnary files should be placed in cape-dict-file path, but which type of dictionaries are used ?

This file is a word list with one word per line.

How completion-at-point works with several functions ? What will I be proposed first when completing at point ?

Check out the Emacs manual and the docstring of completion-at-point-functions. Emacs is self documenting after all. :)

deb75 commented 1 year ago

Hi,

Thanks for your answer.

I did try (ispell-lookup-words "hel") and indeed I run into the error :

Debugger entered--Lisp error: (error "lookup-words error: Unreadable or missing plain wo...")
  error("lookup-words error: Unreadable or missing plain word-list %s." "english")
  ispell-lookup-words("hel")
  eval-expression((ispell-lookup-words "hel") nil nil 127)
  funcall-interactively(eval-expression (ispell-lookup-words "hel") nil nil 127)
  command-execute(eval-expression)

but ispell-word works well. My settings for ispell are :

(require 'ispell)
(setq-default ispell-program-name local/ispell-program-name)
(setq ispell-aspell-data-dir local/ispell-aspell-data-dir)
(setq ispell-aspell-dict-dir local/ispell-aspell-dict-dir)
(setq ispell-dictionary "english"
      ispell-complete-word-dict "english"
      ispell-local-dictionary "english"
      ispell-alternate-dictionary "english")

I did read the documentation for completion-at-point-functions. Unfortunately, it does not answer my question or I missed completely. When calling completion-at-point all functions are called successively, those which are not relevant for the part to be completed return nil and, my guess, the first function returning non nil is used. My initial setting included cape-line which was most of the time used although this was not this kind of completion I was expecting. Maybe I need to train myself with cape a little more, I wonder if for example, there could be a shortcut to jump from next function returning non nil in the completion-at-point-functions list.

About cape-dict, I have the command line of stardict (sdcv) working well under windows10/mingw64. Do you think it could be an option to make cape-dict use an external directory program like sdcv ?

I wonder also if a reference completion could be implemented. The idea is that when you want to reference a label (of an equation, a section, a table or an image), you could type "ref" or "eqref" and the completion system would propose you all the possibilities. Note that cape-line is quite near to this, when I search for a label, except that I do not have the context (lines surrounding it) of the label. This is what org-ref is doing, but I would like to move to citar and org-cite which only manages citations (to my knowledge).

Regards