minad / cape

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

No such file or directory /etc/dictionaries-common/words #60

Closed haji-ali closed 1 year ago

haji-ali commented 1 year ago

The variable cape-dict-file holds the value /etc/dictionaries-common/words which does not exist on my systems (CentOS 7 and Mac OS) hence I keep getting these errors.

This seems to be a Debian package. What should variable be set to in other systems? Also, I suggest that the definition is changed as follows

(defcustom cape-dict-file  
  (let ((x "/etc/dictionaries-common/words"))
    (and (file-readable-p x) x))
  "Dictionary word list file."
  :type 'string)

and

(defun cape--dict-words ()
  "Dictionary words."
  (or cape--dict-words
      (setq cape--dict-words
            (and cape-dict-file
                 (split-string (with-temp-buffer
                                 (insert-file-contents cape-dict-file)
                                 (buffer-string))
                               "\n" 'omit-nulls)))))
minad commented 1 year ago

It is okay to throw an error if the file is not found. That's better than silently bailing out. Just set the variable to another file which exists on your system. However we could do a bit better with the default setting and try different common paths for various OSes. Any suggestions for paths we should try?

haji-ali commented 1 year ago

On MacOS, the file is /usr/share/dict/words so I think it should be tried as well. In Ubuntu, the file /etc/dictionaries-common/words seems to be a symlink to a file in /usr/share/dict/. I am not sure about other systems.

minad commented 1 year ago

It seems /usr/share/dict/words exists on Debian too, so it seems to be a better default value which works across more systems (Linux, BSDs, Mac).