Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > On Sat, May 6, 2023 at 7:58 PM Arash Esbati wrote: >> >> You want to activate AUCTeX for your experiment. > > But, we are doing the test using `emacs -Q` and how can I in this > scenario to enable AUCTeX? I presumed that you have installed AUCTeX via package.el from ELPA, therefore, I wrote in my other mail: • M-x package-initialize RET If you have installed AUCTeX any other way, you have to find out about equivalent to `package-initialize'. > I mean, it seems that enabling AUCTeX needs complicated > configurations, so we use `init.el` to do the trick. Your assumption above is plain wrong. Best, Arash
Re: LaTeX commands and packages names autocomplete.
On Sat, May 6, 2023 at 8:22 PM Hongyi Zhao wrote: > > On Sat, May 6, 2023 at 7:58 PM Arash Esbati wrote: > > > > Hongyi Zhao writes: > > > > > I use the following tex file to do the test, but nothing is completed: > > > > From your screenshot, you're using the built-in latex-mode provided by > > Emacs. > > Thank you for pointing this out to me. > > > You want to activate AUCTeX for your experiment. > > But, we are doing the test using `emacs -Q` and how can I in this > scenario to enable AUCTeX? I mean, it seems that enabling AUCTeX needs > complicated configurations, so we use `init.el` to do the trick. It seems that https://www.gnu.org/software/auctex/manual/auctex.html#Quick-Start gives some clues, but I'm not sure if eval the following in scratch or minibuffer is enough for testing with `emacs -Q`: (setq TeX-auto-save t) (setq TeX-parse-self t) (setq-default TeX-master nil) > > Then, the > > value of `completion-at-point-functions' should be: > > > > (TeX--completion-at-point t LaTeX--arguments-completion-at-point) > > > > and you should get in-buffer completion. > > > > Best, Arash > > Regards, Zhao
Re: LaTeX commands and packages names autocomplete.
On Sat, May 6, 2023 at 7:58 PM Arash Esbati wrote: > > Hongyi Zhao writes: > > > I use the following tex file to do the test, but nothing is completed: > > From your screenshot, you're using the built-in latex-mode provided by > Emacs. Thank you for pointing this out to me. > You want to activate AUCTeX for your experiment. But, we are doing the test using `emacs -Q` and how can I in this scenario to enable AUCTeX? I mean, it seems that enabling AUCTeX needs complicated configurations, so we use `init.el` to do the trick. > Then, the > value of `completion-at-point-functions' should be: > > (TeX--completion-at-point t LaTeX--arguments-completion-at-point) > > and you should get in-buffer completion. > > Best, Arash Regards, Zhao
Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > I use the following tex file to do the test, but nothing is completed: >From your screenshot, you're using the built-in latex-mode provided by Emacs. You want to activate AUCTeX for your experiment. Then, the value of `completion-at-point-functions' should be: (TeX--completion-at-point t LaTeX--arguments-completion-at-point) and you should get in-buffer completion. Best, Arash
Re: LaTeX commands and packages names autocomplete.
On Fri, May 5, 2023 at 2:23 PM Arash Esbati wrote: > > Hongyi Zhao writes: > > > Now, I add the `:demand t` to the corfu's use-package configuration, > > but the problem still remains: > > I don't think this is a corfu/AUCTeX issue. Try: > > • emacs -Q > • M-x package-initialize RET > • eval (setq tab-always-indent 'complete) I tried both methods: `M-: (setq tab-always-indent 'complete)` in minibuffer. And `C-x C-e (setq tab-always-indent 'complete)` in scratch buffer. > • Open a .tex file and do 'M-x corfu-mode RET' > • In your .tex file, do '$\be $' I use the following tex file to do the test, but nothing is completed: \documentclass{article} \begin{document} $\be$ \end{document} %%% Local Variables: %%% mode: latex %%% TeX-master: t %%% End: > I get the candidates instantly. > > Best, Arash
Re: LaTeX commands and packages names autocomplete.
On Fri, May 5, 2023 at 6:21 PM Hongyi Zhao wrote: > > On Fri, May 5, 2023 at 5:58 PM Hongyi Zhao wrote: > > > > On Fri, May 5, 2023 at 4:17 PM Arash Esbati wrote: > > > > > > Hongyi Zhao writes: > > > > > > > Perhaps the simplest solution is to use the cape to interface to > > > > well-developed backends. > > > > > > Please feel free to try it out; maybe you report back how good it works > > > with other available backends. I'd be curious to know how good > > > completion for package names in \usepackage{} and > > > corresponding package options works. > > > > My previous experience of such completions has been based on specific > > backends of company-mode. It seems that they do not provide package > > options completion. > > > > > I suspect that in your other message[1], you wanted to complete to > > > 'hyperref'; > > > > Yes. > > > > > that's a good example for your experiments. > > > > I got the inspiration from the discussions below, but it still seems > > complicated to me to figure them out completely: > > > > Using Corfu and Company simultaneously in different modes. > > https://github.com/minad/corfu/issues/321 > > > > In-buffer completion for normal text/word with ispell + corfu + orderless. > > https://github.com/minad/corfu/issues/323 > > And also the shockingly powerful description of cape given in its document > [1]: > > Cape has the super power to transform Company backends into Capfs and > merge multiple Capfs into a Super-Capf! These transformers allow you > to still take advantage of Company backends even if you are not using > Company as frontend. > > [1] https://github.com/minad/cape#capeel---let-your-completions-fly I conducted some simple testings using the official example configuration as follows: (use-package cape ;; Bind dedicated completion commands ;; Alternative prefix keys: C-c p, M-p, M-+, ... :bind (("C-c p p" . completion-at-point) ;; capf ("C-c p t" . complete-tag);; etags ("C-c p d" . cape-dabbrev);; or dabbrev-completion ("C-c p h" . cape-history) ("C-c p f" . cape-file) ("C-c p k" . cape-keyword) ("C-c p s" . cape-symbol) ("C-c p a" . cape-abbrev) ("C-c p l" . cape-line) ("C-c p w" . cape-dict) ("C-c p \\" . cape-tex) ("C-c p _" . cape-tex) ("C-c p ^" . cape-tex) ("C-c p &" . cape-sgml) ("C-c p r" . cape-rfc1345)) :init ;; Add `completion-at-point-functions', used by `completion-at-point'. ;; NOTE: The order matters! (add-to-list 'completion-at-point-functions #'cape-dabbrev) (add-to-list 'completion-at-point-functions #'cape-file) ;; (add-to-list 'completion-at-point-functions #'cape-elisp-block) ;;(add-to-list 'completion-at-point-functions #'cape-history) (add-to-list 'completion-at-point-functions #'cape-keyword) ;; (add-to-list 'completion-at-point-functions #'cape-tex) ;;(add-to-list 'completion-at-point-functions #'cape-sgml) ;;(add-to-list 'completion-at-point-functions #'cape-rfc1345) (add-to-list 'completion-at-point-functions #'cape-abbrev) (add-to-list 'completion-at-point-functions #'cape-dict) ;;(add-to-list 'completion-at-point-functions #'cape-symbol) ;; (add-to-list 'completion-at-point-functions #'cape-line) ;; Use Company backends as Capfs. (setq-local completion-at-point-functions (mapcar #'cape-company-to-capf (list #'company-files #'company-ispell #'company-dabbrev))) ) At this point, the completion result is clearly incorrect. Therefore, further precise control is necessary. > > > Best, Arash > > > > Best Regards, > > Zhao > > > > > Footnotes: > > > [1] https://lists.gnu.org/archive/html/auctex/2023-05/msg00053.html
Re: LaTeX commands and packages names autocomplete.
On Fri, May 5, 2023 at 5:58 PM Hongyi Zhao wrote: > > On Fri, May 5, 2023 at 4:17 PM Arash Esbati wrote: > > > > Hongyi Zhao writes: > > > > > Perhaps the simplest solution is to use the cape to interface to > > > well-developed backends. > > > > Please feel free to try it out; maybe you report back how good it works > > with other available backends. I'd be curious to know how good > > completion for package names in \usepackage{} and > > corresponding package options works. > > My previous experience of such completions has been based on specific > backends of company-mode. It seems that they do not provide package > options completion. > > > I suspect that in your other message[1], you wanted to complete to > > 'hyperref'; > > Yes. > > > that's a good example for your experiments. > > I got the inspiration from the discussions below, but it still seems > complicated to me to figure them out completely: > > Using Corfu and Company simultaneously in different modes. > https://github.com/minad/corfu/issues/321 > > In-buffer completion for normal text/word with ispell + corfu + orderless. > https://github.com/minad/corfu/issues/323 And also the shockingly powerful description of cape given in its document [1]: Cape has the super power to transform Company backends into Capfs and merge multiple Capfs into a Super-Capf! These transformers allow you to still take advantage of Company backends even if you are not using Company as frontend. [1] https://github.com/minad/cape#capeel---let-your-completions-fly > > Best, Arash > > Best Regards, > Zhao > > > Footnotes: > > [1] https://lists.gnu.org/archive/html/auctex/2023-05/msg00053.html
Re: LaTeX commands and packages names autocomplete.
On Fri, May 5, 2023 at 4:17 PM Arash Esbati wrote: > > Hongyi Zhao writes: > > > Perhaps the simplest solution is to use the cape to interface to > > well-developed backends. > > Please feel free to try it out; maybe you report back how good it works > with other available backends. I'd be curious to know how good > completion for package names in \usepackage{} and > corresponding package options works. My previous experience of such completions has been based on specific backends of company-mode. It seems that they do not provide package options completion. > I suspect that in your other message[1], you wanted to complete to 'hyperref'; Yes. > that's a good example for your experiments. I got the inspiration from the discussions below, but it still seems complicated to me to figure them out completely: Using Corfu and Company simultaneously in different modes. https://github.com/minad/corfu/issues/321 In-buffer completion for normal text/word with ispell + corfu + orderless. https://github.com/minad/corfu/issues/323 > Best, Arash Best Regards, Zhao > Footnotes: > [1] https://lists.gnu.org/archive/html/auctex/2023-05/msg00053.html
Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > Perhaps the simplest solution is to use the cape to interface to > well-developed backends. Please feel free to try it out; maybe you report back how good it works with other available backends. I'd be curious to know how good completion for package names in \usepackage{} and corresponding package options works. I suspect that in your other message[1], you wanted to complete to 'hyperref'; that's a good example for your experiments. Best, Arash Footnotes: [1] https://lists.gnu.org/archive/html/auctex/2023-05/msg00053.html
Re: LaTeX commands and packages names autocomplete.
On Fri, May 5, 2023 at 2:23 PM Arash Esbati wrote: > > Hongyi Zhao writes: > > > 2. Package names still cannot be automatically completed, as shown in > > the attached screenshot. > > Yes, in-buffer completion for package/class names and options isn't > implemented yet, patches welcome. Perhaps the simplest solution is to use the cape [1] to interface to well-developed backends. [1] https://github.com/minad/cape > Best, Arash Regards, Zhao
Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > Now, I add the `:demand t` to the corfu's use-package configuration, > but the problem still remains: I don't think this is a corfu/AUCTeX issue. Try: • emacs -Q • M-x package-initialize RET • eval (setq tab-always-indent 'complete) • Open a .tex file and do 'M-x corfu-mode RET' • In your .tex file, do '$\be $' I get the candidates instantly. Best, Arash
Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > 2. Package names still cannot be automatically completed, as shown in > the attached screenshot. Yes, in-buffer completion for package/class names and options isn't implemented yet, patches welcome. Best, Arash
Re: LaTeX commands and packages names autocomplete.
On Fri, May 5, 2023 at 7:58 AM Hongyi Zhao wrote: > > On Fri, May 5, 2023 at 2:18 AM Arash Esbati wrote: > > > > Hongyi Zhao writes: > > > > > I should have also uncommented the above line. But even so, I have the > > > following problems: > > > > > > 1. I must at least type 3 letters to trigger the completion. > > > > ,[ C-h v corfu-auto-prefix RET ] > > | corfu-auto-prefix is a variable defined in ‘corfu.el’. > > | > > | Its value is 3 > > | > > | Minimum length of prefix for auto completion. > > | The completion backend can override this with > > | :company-prefix-length. It is *not recommended* to use a small > > | prefix length (below 2), since this will create high load for > > | Emacs. See also ‘corfu-auto-delay’. > > | > > | You can customize this variable. > > | > > ` > > > > > 2. Furthermore, my completion candidates list entries are less than > > > yours, as shown in the attached screenshot. > > > > If you take a closer look, you'll see that the screenshot I sent had > > also a candidate "because" since I hit TAB after only 2 characters, you > > have 3 characters "bec" in the buffer where the completion kicks in, > > hence one candidate is missing. > > You're right. Set `(corfu-auto-prefix 2)` does the trick, as shown in > the attached screenshot. > > > In your other mail, you wrote: > > > > > Another problem I noticed: > > > > > > 3. The speed of triggering the candidate list for the first time is > > > very slow, while company-mode does not seem to have this problem. > > > > I don't use use-package, but you'll know that it loads packages lazily, > > so if you're using corfu in your .tex file for the first in a fresh > > Emacs instance, it has to be loaded; maybe that's the reason. I observe > > the same thing if I deactivate corfu in a .tex buffer and activate > > company; it takes a sec before it's ready to go. > > Now, I add the `:demand t` to the corfu's use-package configuration, > but the problem still remains: > > (use-package corfu > :demand t > ;; Optional customizations > :custom > ;; (corfu-cycle t);; Enable cycling for > `corfu-next/previous' > (corfu-auto t) ;; Enable auto completion > (corfu-auto-prefix 2) > ;; (corfu-separator ?\s) ;; Orderless field separator > ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary > ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match > ;; (corfu-preview-current nil);; Disable current candidate preview > ;; (corfu-preselect 'prompt) ;; Preselect the prompt > ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches > ;; (corfu-scroll-margin 5);; Use scroll margin > > ;; Enable Corfu only for certain modes. > ;; :hook ((prog-mode . corfu-mode) > ;;(shell-mode . corfu-mode) > ;;(eshell-mode . corfu-mode)) > > ;; Recommended: Enable Corfu globally. > ;; This is recommended since Dabbrev can be used globally (M-/). > ;; See also `corfu-exclude-modes'. > :init > (global-corfu-mode)) > > ;; A few more useful configurations... > (use-package emacs > :init > ;; TAB cycle if there are only few candidates > ;; (setq completion-cycle-threshold 3) > > ;; Emacs 28: Hide commands in M-x which do not apply to the current mode. > ;; Corfu commands are hidden, since they are not supposed to be used via > M-x. > ;; (setq read-extended-command-predicate > ;; #'command-completion-default-include-p) > > ;; Enable indentation+completion using the TAB key. > ;; `completion-at-point' is often bound to M-TAB. > (setq tab-always-indent 'complete)) Till now, I still encounter the following problems: 1. After I've enabled the following option, continuous pressing Tab key doesn't cycle through the candidates. (setq completion-cycle-threshold 3) 2. Package names still cannot be automatically completed, as shown in the attached screenshot. > > Best, Arash > > Regards, Zhao
Re: LaTeX commands and packages names autocomplete.
On Fri, May 5, 2023 at 2:18 AM Arash Esbati wrote: > > Hongyi Zhao writes: > > > I should have also uncommented the above line. But even so, I have the > > following problems: > > > > 1. I must at least type 3 letters to trigger the completion. > > ,[ C-h v corfu-auto-prefix RET ] > | corfu-auto-prefix is a variable defined in ‘corfu.el’. > | > | Its value is 3 > | > | Minimum length of prefix for auto completion. > | The completion backend can override this with > | :company-prefix-length. It is *not recommended* to use a small > | prefix length (below 2), since this will create high load for > | Emacs. See also ‘corfu-auto-delay’. > | > | You can customize this variable. > | > ` > > > 2. Furthermore, my completion candidates list entries are less than > > yours, as shown in the attached screenshot. > > If you take a closer look, you'll see that the screenshot I sent had > also a candidate "because" since I hit TAB after only 2 characters, you > have 3 characters "bec" in the buffer where the completion kicks in, > hence one candidate is missing. You're right. Set `(corfu-auto-prefix 2)` does the trick, as shown in the attached screenshot. > In your other mail, you wrote: > > > Another problem I noticed: > > > > 3. The speed of triggering the candidate list for the first time is > > very slow, while company-mode does not seem to have this problem. > > I don't use use-package, but you'll know that it loads packages lazily, > so if you're using corfu in your .tex file for the first in a fresh > Emacs instance, it has to be loaded; maybe that's the reason. I observe > the same thing if I deactivate corfu in a .tex buffer and activate > company; it takes a sec before it's ready to go. Now, I add the `:demand t` to the corfu's use-package configuration, but the problem still remains: (use-package corfu :demand t ;; Optional customizations :custom ;; (corfu-cycle t);; Enable cycling for `corfu-next/previous' (corfu-auto t) ;; Enable auto completion (corfu-auto-prefix 2) ;; (corfu-separator ?\s) ;; Orderless field separator ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match ;; (corfu-preview-current nil);; Disable current candidate preview ;; (corfu-preselect 'prompt) ;; Preselect the prompt ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches ;; (corfu-scroll-margin 5);; Use scroll margin ;; Enable Corfu only for certain modes. ;; :hook ((prog-mode . corfu-mode) ;;(shell-mode . corfu-mode) ;;(eshell-mode . corfu-mode)) ;; Recommended: Enable Corfu globally. ;; This is recommended since Dabbrev can be used globally (M-/). ;; See also `corfu-exclude-modes'. :init (global-corfu-mode)) ;; A few more useful configurations... (use-package emacs :init ;; TAB cycle if there are only few candidates ;; (setq completion-cycle-threshold 3) ;; Emacs 28: Hide commands in M-x which do not apply to the current mode. ;; Corfu commands are hidden, since they are not supposed to be used via M-x. ;; (setq read-extended-command-predicate ;; #'command-completion-default-include-p) ;; Enable indentation+completion using the TAB key. ;; `completion-at-point' is often bound to M-TAB. (setq tab-always-indent 'complete)) > Best, Arash Regards, Zhao
Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > I should have also uncommented the above line. But even so, I have the > following problems: > > 1. I must at least type 3 letters to trigger the completion. ,[ C-h v corfu-auto-prefix RET ] | corfu-auto-prefix is a variable defined in ‘corfu.el’. | | Its value is 3 | | Minimum length of prefix for auto completion. | The completion backend can override this with | :company-prefix-length. It is *not recommended* to use a small | prefix length (below 2), since this will create high load for | Emacs. See also ‘corfu-auto-delay’. | | You can customize this variable. | ` > 2. Furthermore, my completion candidates list entries are less than > yours, as shown in the attached screenshot. If you take a closer look, you'll see that the screenshot I sent had also a candidate "because" since I hit TAB after only 2 characters, you have 3 characters "bec" in the buffer where the completion kicks in, hence one candidate is missing. In your other mail, you wrote: > Another problem I noticed: > > 3. The speed of triggering the candidate list for the first time is > very slow, while company-mode does not seem to have this problem. I don't use use-package, but you'll know that it loads packages lazily, so if you're using corfu in your .tex file for the first in a fresh Emacs instance, it has to be loaded; maybe that's the reason. I observe the same thing if I deactivate corfu in a .tex buffer and activate company; it takes a sec before it's ready to go. Best, Arash
Re: LaTeX commands and packages names autocomplete.
On Thu, May 4, 2023 at 11:40 PM Hongyi Zhao wrote: > > On Thu, May 4, 2023 at 10:54 PM Hongyi Zhao wrote: > > > > On Tue, May 2, 2023 at 1:30 PM Arash Esbati wrote: > > > > > > Hongyi Zhao writes: > > > > > > > My current configuration: > > > > > > > > (use-package company-math > > > > :hook > > > > ;; This will enable the company-math backend for LaTeX mode > > > > (LaTeX-mode . (lambda () > > > > (setq-local company-backends > > > > (append '((company-math-symbols-latex > > > > company-latex-commands)) > > > > company-backends > > > > ) > > > > > > > > See the attached file for the results returned using your example. > > > > > > I think you need none of company-math-symbols-latex and > > > company-latex-commands, AUCTeX offers already a Capf for both of them, > > > so comment out that part and start company without any additions in your > > > .tex file. > > > > > > > What's your corfu configuration? > > > > > > (setq tab-always-indent 'complete) > > > (setq corfu-auto t) > > > (global-corfu-mode) > > > > Now, I've disabled all the company-mode related configuration and try > > switching to corfu as follows: > > > > ;; https://github.com/minad/corfu#installation-and-configuration > > (use-package corfu > > ;; Optional customizations > > ;; :custom > > I should have also uncommented the above line. But even so, I have the > following problems: > > 1. I must at least type 3 letters to trigger the completion. > 2. Furthermore, my completion candidates list entries are less than > yours, as shown in the attached screenshot. Another problem I noticed: 3. The speed of triggering the candidate list for the first time is very slow, while company-mode does not seem to have this problem. > > ;; (corfu-cycle t);; Enable cycling for > > `corfu-next/previous' > > (corfu-auto t) ;; Enable auto completion > > ;; (corfu-separator ?\s) ;; Orderless field separator > > ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary > > ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match > > ;; (corfu-preview-current nil);; Disable current candidate preview > > ;; (corfu-preselect 'prompt) ;; Preselect the prompt > > ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches > > ;; (corfu-scroll-margin 5);; Use scroll margin > > > > ;; Enable Corfu only for certain modes. > > ;; :hook ((prog-mode . corfu-mode) > > ;;(shell-mode . corfu-mode) > > ;;(eshell-mode . corfu-mode)) > > > > ;; Recommended: Enable Corfu globally. > > ;; This is recommended since Dabbrev can be used globally (M-/). > > ;; See also `corfu-exclude-modes'. > > :init > > (global-corfu-mode)) > > > > ;; A few more useful configurations... > > (use-package emacs > > :init > > ;; TAB cycle if there are only few candidates > > (setq completion-cycle-threshold 3) > > > > ;; Emacs 28: Hide commands in M-x which do not apply to the current mode. > > ;; Corfu commands are hidden, since they are not supposed to be used via > > M-x. > > ;; (setq read-extended-command-predicate > > ;; #'command-completion-default-include-p) > > > > ;; Enable indentation+completion using the TAB key. > > ;; `completion-at-point' is often bound to M-TAB. > > (setq tab-always-indent 'complete)) > > > > > > But I cannot get any completion effect provided by corfu, as shown in > > the attached screenshot. > > > > > Best, Arash > > > > Regards, Zhao
Re: LaTeX commands and packages names autocomplete.
On Thu, May 4, 2023 at 10:54 PM Hongyi Zhao wrote: > > On Tue, May 2, 2023 at 1:30 PM Arash Esbati wrote: > > > > Hongyi Zhao writes: > > > > > My current configuration: > > > > > > (use-package company-math > > > :hook > > > ;; This will enable the company-math backend for LaTeX mode > > > (LaTeX-mode . (lambda () > > > (setq-local company-backends > > > (append '((company-math-symbols-latex > > > company-latex-commands)) > > > company-backends > > > ) > > > > > > See the attached file for the results returned using your example. > > > > I think you need none of company-math-symbols-latex and > > company-latex-commands, AUCTeX offers already a Capf for both of them, > > so comment out that part and start company without any additions in your > > .tex file. > > > > > What's your corfu configuration? > > > > (setq tab-always-indent 'complete) > > (setq corfu-auto t) > > (global-corfu-mode) > > Now, I've disabled all the company-mode related configuration and try > switching to corfu as follows: > > ;; https://github.com/minad/corfu#installation-and-configuration > (use-package corfu > ;; Optional customizations > ;; :custom I should have also uncommented the above line. But even so, I have the following problems: 1. I must at least type 3 letters to trigger the completion. 2. Furthermore, my completion candidates list entries are less than yours, as shown in the attached screenshot. > ;; (corfu-cycle t);; Enable cycling for > `corfu-next/previous' > (corfu-auto t) ;; Enable auto completion > ;; (corfu-separator ?\s) ;; Orderless field separator > ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary > ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match > ;; (corfu-preview-current nil);; Disable current candidate preview > ;; (corfu-preselect 'prompt) ;; Preselect the prompt > ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches > ;; (corfu-scroll-margin 5);; Use scroll margin > > ;; Enable Corfu only for certain modes. > ;; :hook ((prog-mode . corfu-mode) > ;;(shell-mode . corfu-mode) > ;;(eshell-mode . corfu-mode)) > > ;; Recommended: Enable Corfu globally. > ;; This is recommended since Dabbrev can be used globally (M-/). > ;; See also `corfu-exclude-modes'. > :init > (global-corfu-mode)) > > ;; A few more useful configurations... > (use-package emacs > :init > ;; TAB cycle if there are only few candidates > (setq completion-cycle-threshold 3) > > ;; Emacs 28: Hide commands in M-x which do not apply to the current mode. > ;; Corfu commands are hidden, since they are not supposed to be used via > M-x. > ;; (setq read-extended-command-predicate > ;; #'command-completion-default-include-p) > > ;; Enable indentation+completion using the TAB key. > ;; `completion-at-point' is often bound to M-TAB. > (setq tab-always-indent 'complete)) > > > But I cannot get any completion effect provided by corfu, as shown in > the attached screenshot. > > > Best, Arash > > Regards, Zhao
Re: LaTeX commands and packages names autocomplete.
On Tue, May 2, 2023 at 1:30 PM Arash Esbati wrote: > > Hongyi Zhao writes: > > > My current configuration: > > > > (use-package company-math > > :hook > > ;; This will enable the company-math backend for LaTeX mode > > (LaTeX-mode . (lambda () > > (setq-local company-backends > > (append '((company-math-symbols-latex > > company-latex-commands)) > > company-backends > > ) > > > > See the attached file for the results returned using your example. > > I think you need none of company-math-symbols-latex and > company-latex-commands, AUCTeX offers already a Capf for both of them, > so comment out that part and start company without any additions in your > .tex file. > > > What's your corfu configuration? > > (setq tab-always-indent 'complete) > (setq corfu-auto t) > (global-corfu-mode) Now, I've disabled all the company-mode related configuration and try switching to corfu as follows: ;; https://github.com/minad/corfu#installation-and-configuration (use-package corfu ;; Optional customizations ;; :custom ;; (corfu-cycle t);; Enable cycling for `corfu-next/previous' (corfu-auto t) ;; Enable auto completion ;; (corfu-separator ?\s) ;; Orderless field separator ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match ;; (corfu-preview-current nil);; Disable current candidate preview ;; (corfu-preselect 'prompt) ;; Preselect the prompt ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches ;; (corfu-scroll-margin 5);; Use scroll margin ;; Enable Corfu only for certain modes. ;; :hook ((prog-mode . corfu-mode) ;;(shell-mode . corfu-mode) ;;(eshell-mode . corfu-mode)) ;; Recommended: Enable Corfu globally. ;; This is recommended since Dabbrev can be used globally (M-/). ;; See also `corfu-exclude-modes'. :init (global-corfu-mode)) ;; A few more useful configurations... (use-package emacs :init ;; TAB cycle if there are only few candidates (setq completion-cycle-threshold 3) ;; Emacs 28: Hide commands in M-x which do not apply to the current mode. ;; Corfu commands are hidden, since they are not supposed to be used via M-x. ;; (setq read-extended-command-predicate ;; #'command-completion-default-include-p) ;; Enable indentation+completion using the TAB key. ;; `completion-at-point' is often bound to M-TAB. (setq tab-always-indent 'complete)) But I cannot get any completion effect provided by corfu, as shown in the attached screenshot. > Best, Arash Regards, Zhao
Re: LaTeX commands and packages names autocomplete.
David Kastrup writes: > Huh? Things like \begin{smallmatrix} are certainly useful in inline > math. They make it hard to pick a good way of formatting the _source_, > but the output is certainly fine. Thanks for the correction. So I should have said: AUCTeX unfortunately doesn't support in-buffer completion for \begin/\end in inline math. Best, Arash
Re: LaTeX commands and packages names autocomplete.
Arash Esbati writes: > Hongyi Zhao writes: > >> I commented out the above code snippet, but nothing will be completed, >> as shown in the attached file. >> >> Here I want to point out two things: >> >> 1. As you can see, without using company-math, it seems that fewer >> candidates are returned. > > The upside is that you don't get candidates like \begin which is > nonsense in inline math. Huh? Things like \begin{smallmatrix} are certainly useful in inline math. They make it hard to pick a good way of formatting the _source_, but the output is certainly fine. -- David Kastrup
Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > I commented out the above code snippet, but nothing will be completed, > as shown in the attached file. > > Here I want to point out two things: > > 1. As you can see, without using company-math, it seems that fewer > candidates are returned. The upside is that you don't get candidates like \begin which is nonsense in inline math. The downside is that AUCTeX only caters for standard LaTeX and AMSTeX symbols; things like \benzenr provided by stix2 package are missing. Patches welcome. > 2. Without using company-math, I noticed that I must manually run `M-x > company-complete RET` to trigger the completion in math mode. > > Any further tips/comments will be appreciated. Read the company manual and configure it accordingly. Best, Arash
Re: LaTeX commands and packages names autocomplete.
On Tue, May 2, 2023 at 1:30 PM Arash Esbati wrote: > > Hongyi Zhao writes: > > > My current configuration: > > > > (use-package company-math > > :hook > > ;; This will enable the company-math backend for LaTeX mode > > (LaTeX-mode . (lambda () > > (setq-local company-backends > > (append '((company-math-symbols-latex > > company-latex-commands)) > > company-backends > > ) > > > > See the attached file for the results returned using your example. > > I think you need none of company-math-symbols-latex and > company-latex-commands, AUCTeX offers already a Capf for both of them, > so comment out that part and start company without any additions in your > .tex file. I commented out the above code snippet, but nothing will be completed, as shown in the attached file. Here I want to point out two things: 1. As you can see, without using company-math, it seems that fewer candidates are returned. 2. Without using company-math, I noticed that I must manually run `M-x company-complete RET` to trigger the completion in math mode. Any further tips/comments will be appreciated. > > What's your corfu configuration? > > (setq tab-always-indent 'complete) > (setq corfu-auto t) > (global-corfu-mode) > > Best, Arash Regards, Zhao
Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > My current configuration: > > (use-package company-math > :hook > ;; This will enable the company-math backend for LaTeX mode > (LaTeX-mode . (lambda () > (setq-local company-backends > (append '((company-math-symbols-latex > company-latex-commands)) > company-backends > ) > > See the attached file for the results returned using your example. I think you need none of company-math-symbols-latex and company-latex-commands, AUCTeX offers already a Capf for both of them, so comment out that part and start company without any additions in your .tex file. > What's your corfu configuration? (setq tab-always-indent 'complete) (setq corfu-auto t) (global-corfu-mode) Best, Arash
Re: LaTeX commands and packages names autocomplete.
On Tue, May 2, 2023 at 12:19 AM Arash Esbati wrote: > > Hongyi Zhao writes: > > > I commented out the `company-fuzzy` and `company-math` packages, now > > it works. > > > > But I really want to have the feature provided by `company-math`, and > > it seems that my following configuration seems to be both chaotic and > > problematic: > > [...] > > If anyone has experience about how to configure and use this package > > better, I will be very grateful. > > I have no idea about company-math, See https://github.com/vspinu/company-math for more information. My current configuration: (use-package company-math :hook ;; This will enable the company-math backend for LaTeX mode (LaTeX-mode . (lambda () (setq-local company-backends (append '((company-math-symbols-latex company-latex-commands)) company-backends ) See the attached file for the results returned using your example. > but AUCTeX offers in-buffer > completion for (La)TeX macros and math symbols; you could try that. A > simple example looks like this for me: > The example is with corfu and not with company. What's your corfu configuration? And also see here [1] for the related discussion. > The Capf provided by > AUCTeX is aware of math mode and doesn't offer math symbols outside math > environments. Since AUCTeX adds its Capf to standard Emacs machinery, > it should also work with standard company backends. [1] https://github.com/minad/corfu/issues/321#issuecomment-1529834819 > Best, Arash
Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > I commented out the `company-fuzzy` and `company-math` packages, now > it works. > > But I really want to have the feature provided by `company-math`, and > it seems that my following configuration seems to be both chaotic and > problematic: > [...] > If anyone has experience about how to configure and use this package > better, I will be very grateful. I have no idea about company-math, but AUCTeX offers in-buffer completion for (La)TeX macros and math symbols; you could try that. A simple example looks like this for me: The example is with corfu and not with company. The Capf provided by AUCTeX is aware of math mode and doesn't offer math symbols outside math environments. Since AUCTeX adds its Capf to standard Emacs machinery, it should also work with standard company backends. Best, Arash
Re: LaTeX commands and packages names autocomplete.
On Mon, May 1, 2023 at 8:47 PM Hongyi Zhao wrote: > > On Mon, May 1, 2023 at 6:20 PM Arash Esbati wrote: > > > > Hongyi Zhao writes: > > > > > Some time ago, it seemed that my auctex configuration was able to > > > provide autocomplete for LaTeX commands and packages names. However, > > > currently, all of these functions are disabled. How should I enable > > > these features again? > > > > Maybe you've changed to value of `TeX-arg-input-file-search'? > > > > ,[ C-h v TeX-arg-input-file-search RET ] > > | TeX-arg-input-file-search is a variable defined in ‘latex.el’. > > | > > | Its value is t > > | > > | If ‘TeX-arg-input-file’ should search for files. > > | If the value is t, files in TeX’s search path are searched for > > | and provided for completion. The file name is then inserted > > | without directory and extension. If the value is nil, the file > > | name can be specified manually and is inserted with a path > > | relative to the directory of the current buffer’s file and with > > | extension. If the value is ‘ask’, you are asked for the method > > | to use every time ‘TeX-arg-input-file’ is called. > > | > > | You can customize this variable. > > | > > ` > > I've the exactly same setting as yours. See the attached screenshot > for the real completion results in my currently case. > > It seems that the problem is caused by an incorrect company-backends > configurations, so I further checked by `C-h v company-backends RET` > and got the following value: > > Value: (company-fuzzy-all-other-backends) > Original value was > (company-bbdb company-semantic company-cmake company-capf > company-clang company-files > (company-dabbrev-code company-gtags company-etags company-keywords) > company-oddmuse company-dabbrev) > Local in buffer test.tex; global value is > (company-math-symbols-unicode company-native-complete company-bbdb > company-semantic company-cmake company-capf company-clang > company-files > (company-dabbrev-code company-gtags company-etags > company-keywords) > company-oddmuse company-dabbrev) I commented out the `company-fuzzy` and `company-math` packages, now it works. But I really want to have the feature provided by `company-math`, and it seems that my following configuration seems to be both chaotic and problematic: (use-package company-math :hook (LaTeX-mode . (lambda () (setq-local company-backends (append '(company-math-symbols-latex company-latex-commands) (company--backends) :config (add-to-list 'company-backends 'company-math-symbols-unicode) ;; https://github.com/company-mode/company-mode/discussions/1253 ;; (set-company-backend 'LaTeX-mode ;; 'company-math-symbols-latex 'company-latex-commands 'company-math-symbols-unicode) ) If anyone has experience about how to configure and use this package better, I will be very grateful. Regards, Zhao
Re: LaTeX commands and packages names autocomplete.
On Mon, May 1, 2023 at 6:20 PM David Kastrup wrote: > > Hongyi Zhao writes: > > > Hi here, > > > > Some time ago, it seemed that my auctex configuration was able to > > provide autocomplete for LaTeX commands and packages names. However, > > currently, all of these functions are disabled. How should I enable > > these features again? > > Undo whatever you did that disabled them. > > Seriously? How should we guess what you did when you provide absolutely > no relevant information about your configuration or even the system and > versions? > > You can try sending such a report after opening a .tex file using > > M-x TeX-submit-bug-report RET > > and at least get some details reported. I get the following report by the above method: To: bug-auc...@gnu.org Subject: 2023-01-20; completions of latex commands and package names From: werner --text follows this line-- Emacs : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.16.0) of 2023-01-24 Package: 2023-01-20 current state: == (setq AUCTeX-date "2023-01-20" window-system 'x LaTeX-version "2e" TeX-style-path '("/usr/local/var/auctex" "/home/werner/.emacs.d/straight/repos/auctex/style" "/home/werner/.emacs.d/auctex/.auctex-auto" "/home/werner/.emacs.d/auctex/.auctex-style" ".auctex-auto" ".auctex-style") TeX-auto-save t TeX-parse-self t TeX-master 'dwim TeX-command-list '(("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts) %S%(PDFout)%(mode)%' %(output-dir) %t" TeX-run-TeX nil (plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX") ("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX") ("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with Info output") ("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with HTML output") ("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %(output-dir) %t" TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX") ("ConTeXt" "%(cntxcom) --once --texutil %(extraopts) %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt once") ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt until completion") ("BibTeX" "%(bibtex) %s" TeX-run-BibTeX nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode context-mode) :help "Run BibTeX") ("Biber" "biber %(output-dir) %s" TeX-run-Biber nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run Biber") ("Texindex" "texindex %s.??" TeX-run-command nil (texinfo-mode) :help "Run Texindex") ("Texi2dvi" "%(PDF)texi2dvi %t" TeX-run-command nil (texinfo-mode) :help "Run Texi2dvi or Texi2pdf") ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer") ("Print" "%p" TeX-run-command t t :help "Print the file") ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible TeX-queue-command) ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Generate PostScript file") ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert DVI file to PostScript") ("Dvipdfmx" "dvipdfmx -o %(O?pdf) %d" TeX-run-dvipdfmx nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert DVI file to PDF with dvipdfmx") ("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert PostScript file to PDF") ("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run makeglossaries to create glossary file") ("Index" "%(makeindex) %s" TeX-run-index nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run makeindex to create index file") ("upMendex" "upmendex %(O?idx)" TeX-run-index t (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run
Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > Hi here, > > Some time ago, it seemed that my auctex configuration was able to > provide autocomplete for LaTeX commands and packages names. However, > currently, all of these functions are disabled. How should I enable > these features again? Undo whatever you did that disabled them. Seriously? How should we guess what you did when you provide absolutely no relevant information about your configuration or even the system and versions? You can try sending such a report after opening a .tex file using M-x TeX-submit-bug-report RET and at least get some details reported. -- David Kastrup
Re: LaTeX commands and packages names autocomplete.
Hongyi Zhao writes: > Some time ago, it seemed that my auctex configuration was able to > provide autocomplete for LaTeX commands and packages names. However, > currently, all of these functions are disabled. How should I enable > these features again? Maybe you've changed to value of `TeX-arg-input-file-search'? ,[ C-h v TeX-arg-input-file-search RET ] | TeX-arg-input-file-search is a variable defined in ‘latex.el’. | | Its value is t | | If ‘TeX-arg-input-file’ should search for files. | If the value is t, files in TeX’s search path are searched for | and provided for completion. The file name is then inserted | without directory and extension. If the value is nil, the file | name can be specified manually and is inserted with a path | relative to the directory of the current buffer’s file and with | extension. If the value is ‘ask’, you are asked for the method | to use every time ‘TeX-arg-input-file’ is called. | | You can customize this variable. | ` Best, Arash