hlissner/emacs-company-dict

How can I use minor-mode-list first when I'm in major mode?

Closed this issue · 2 comments

I hope to use the major-mode to complete first,then use the all file,how can I set the priority
level?

Sorry for the tremendously late reply. Unfortunately this is hard-coded in:

(defun company-dict--relevant-dicts ()
  "Merge all dicts together into one large list."
  (let ((dicts (append (gethash 'all company-dict-table)
                       (gethash major-mode company-dict-table))))
    (mapc (lambda (mode)
            (when (and (boundp mode) (symbol-value mode))
              (setq dicts (append dicts (gethash mode company-dict-table)))))
          company-dict-minor-mode-list)
    dicts))

You could get around it, you'll have to replace this function. e.g.

(defun my-relevant-dicts (dicts)
  (append (cl-loop for mode in company-dict-minor-mode-list
                   if (and (boundp mode)
                           (symbol-value mode))
                   nconc (gethash mode company-dict-table))
          (gethash major-mode company-dict-table)
          (gethash 'all company-dict-table)
          nil))
(advice-add #'company-dict--relevant-dicts :override #'my-relevant-dicts)

Hope that helps!

Thx. I change your code ,and this works for me

(defun my-relevant-dicts ()
  (append          (gethash major-mode company-dict-table)
                   (gethash 'all company-dict-table)
                   (cl-loop for mode in company-dict-minor-mode-list
                            if (and (boundp mode)
                                    (symbol-value mode))
                            nconc (gethash mode company-dict-table))

                   nil))
(advice-add #'company-dict--relevant-dicts :override #'my-relevant-dicts)