jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.39k stars 259 forks source link

Configure use-package with complex logic. #941

Closed hongyi-zhao closed 3 years ago

hongyi-zhao commented 3 years ago

I'm currently using the following configuration for auctex's LaTeX mode with company:

(use-package company
  :custom
  ;https://github.com/company-mode/company-mode/issues/14#issuecomment-290261406
  ; Do not downcase the returned candidates automatically
  (company-dabbrev-downcase nil) 
  (company-idle-delay 0) 
  (company-minimum-prefix-length 1)
  (company-tooltip-align-annotations t)
  (company-dabbrev-other-buffers t) ; search buffers with the same major mode
 )

(defun my-latex-mode-setup ()
(setq-local company-backends
                (append '((
                           ;company-math-symbols-latex
                           ;company-latex-commands
                           ; https://github.com/joaotavora/eglot/issues/708#issuecomment-869121578
                           company-ispell
                           company-capf
              ))
                        company-backends)))

;https://github.com/KaratasFurkan/.emacs.d/issues/1#issuecomment-864574670
(dolist (fn '(company-mode my-latex-mode-setup))
  (add-hook 'TeX-mode-hook fn))

How can I integrate all the above configurations into use-package?

Regards, HY

progfolio commented 3 years ago

Typically code like your defun would go in a :config section of a use package declaration. Also see the documentation on adding hooks on a per-package basis: https://github.com/jwiegley/use-package#hooks

hongyi-zhao commented 3 years ago

Thank you for your hints. I've found some examples since this issue has been filed, as shown here, here, and here.