Closed hongyi-zhao closed 2 years ago
Thanks for the issue. This package is only for shell-mode
and doesn’t work in ansi-term-mode
. See this for a description of the differences.
Thank you for your comment. I tried with M-x shell RET
and still only see partial keywords complete, compare to what I see in the native shell console:
See the following keywords' candidate list, which is triggered in the native shell console:
$ echo $H<TAB>
$HISTCMD $HISTFILESIZE $HISTTIMEFORMAT $HOSTNAME
$HISTFILE $HISTSIZE $HOME $HOSTTYPE
Thank you for your comment. I tried with
M-x shell RET
and still only see partial keywords complete, compare to what I see in the native shell console:
I've just installed the package (thank you for finally making this!) and face a similar problem as the issue author.
~/Code/marketplace (main)$ echo $H
$HISTCMD $HISTCONTROL $HISTFILE $HISTFILESIZE $HISTSIZE $HOME $HOSTNAME $HOSTTYPE
But in my emacs shell with native-complete echo $H<TAB>
actually auto-completes to $HOME
every time without displaying any of the options.
output from describe-mode
Enabled minor modes: Anzu Auto-Composition Auto-Compression
Auto-Encryption Clean-Aindent Column-Number Counsel Editorconfig
Electric-Indent Eval-Sexp-Fu-Flash Evil Evil-Escape Evil-Local
Evil-Surround Eyebrowse File-Name-Shadow Flycheck-Pos-Tip Font-Lock
Global-Anzu Global-Auto-Revert Global-Display-Line-Numbers Global-Eldoc
Global-Evil-Surround Global-Flycheck Global-Font-Lock Global-Git-Commit
Global-Git-Gutter+ Global-Hl-Line Global-Hl-Todo Global-Page-Break-Lines
Global-Rbenv Global-Spacemacs-Leader-Override Global-Undo-Tree
Global-Vi-Tilde-Fringe Ido-Vertical Ivy Line-Number Menu-Bar Mouse-Wheel
Override-Global Persp Projectile Projectile-Rails-Global Pupo Purpose
Recentf Save-Place Savehist Shell-Dirtrack Show-Smartparens
Show-Smartparens-Global Smartparens Spaceline-Info
Spacemacs-Leader-Override Transient-Mark Treemacs-Filewatch
Treemacs-Follow Treemacs-Fringe-Indicator Treemacs-Icons-Dired Undo-Tree
Vi-Tilde-Fringe Which-Key Winner Winum Xterm-Mouse Yas-Global
Okay let's see if we can get to the bottom of this.
First can you verify that we should be seeing more variables? Run env | grep '^H'
in your shell
buffer and look at the output.
Then can you run (native-complete-get-completion-style)
when the cursor is at an empty shell prompt and see what it reports?
Run
env | grep '^H'
in yourshell
buffer and look at the output.
$ env | grep '^H'
HISTTIMEFORMAT=%y-%m-%d %T
HOME=/home/werner
Then can you run
(native-complete-get-completion-style)
when the cursor is at an empty shell prompt and see what it reports?
M-: (native-complete-get-completion-style) RET
hmm. So it looks like several of those variables are bash specific and don't show up in the environment, but they should show up in completions.
I see in your company pop-up that it is using capf
. Have you added company-native-complete
to company-backends
?
M-x shell RET
then M-: (add-to-list 'company-backends 'company-native-complete) RET
will do the trick.
But as you can see, the prompt string will always display twice. And furthermore, the following error will often be triggered:
I did a poor job documenting this requirement. Can you look at this newly added section of the readme and see if it explains it well? customize the prompt
Also I added a new function called native-complete-check-config
that will check for common problems. Please run that as well.
customize the prompt
I changed to the following configuration:
;; https://melpa.org/#/native-complete
;; https://melpa.org/#/company-native-complete
;; https://github.com/CeleritasCelery/emacs-native-shell-complete#1-emacs-setup
(use-package native-complete
:straight ( :host github :repo "CeleritasCelery/emacs-native-shell-complete"
:files (:defaults)
;; https://github.com/raxod502/straight.el#the-recipe-format
;; :includes indicates a package is a superset of another package.
:includes company-native-complete
)
;; https://github.com/CeleritasCelery/emacs-native-shell-complete#2-shell-setup
:config
;; https://github.com/CeleritasCelery/emacs-native-shell-complete#if-using-company-mode
(add-to-list 'company-backends 'company-native-complete)
;; https://github.com/CeleritasCelery/emacs-native-shell-complete#customize-the-prompt-regex
(add-hook 'shell-mode-hook (lambda () (setq comint-prompt-regex "^.+[$%>] ")))
;; https://github.com/CeleritasCelery/emacs-native-shell-complete#bash
(with-eval-after-load 'shell
(native-complete-setup-bash))
)
When I hit M-x shell RET
, the following screenshot still will be triggered:
Also I added a new function called
native-complete-check-config
I don't know how to use it. Any more hints?
I don't know how to use it. Any more hints?
call it with M-x native-complete-check-config
This following error is triggered by the aforementioned command:
Thanks. I pushed a fix that will report the error message correctly. In this case just hit enter so that there is only one prompt on the line and it should work.
Still encounter the same problem while issue M-x shell RET
command:
$ git log -1
commit 5f94022fc9168971c77f8c12f9efd569c45f4850 (HEAD -> master, origin/master, origin/HEAD)
Author: Troy Hinckley <t.macman@gmail.com>
Date: Mon Jan 24 11:06:15 2022 -0700
Clarify error message in check config
What error did it report?
That is a use-package
error. Probably because you are not loading company mode before trying to assign company-backends
Now, I added the :after company
to native-complete
's use-package
configuration:
;; https://melpa.org/#/native-complete
;; https://melpa.org/#/company-native-complete
;; https://github.com/CeleritasCelery/emacs-native-shell-complete#1-emacs-setup
(use-package native-complete
:straight ( :host github :repo "CeleritasCelery/emacs-native-shell-complete"
:files (:defaults)
;; https://github.com/raxod502/straight.el#the-recipe-format
;; :includes indicates a package is a superset of another package.
:includes company-native-complete
)
;; https://github.com/CeleritasCelery/emacs-native-shell-complete/issues/17#issuecomment-1019382934
;; https://github.com/CeleritasCelery/emacs-native-shell-complete#2-shell-setup
:after company
:config
;; https://github.com/CeleritasCelery/emacs-native-shell-complete#if-using-company-mode
(add-to-list 'company-backends 'company-native-complete)
;; https://github.com/CeleritasCelery/emacs-native-shell-complete#customize-the-prompt-regex
(add-hook 'shell-mode-hook (lambda () (setq comint-prompt-regex "^.+[$%>] ")))
;; https://github.com/CeleritasCelery/emacs-native-shell-complete#bash
(with-eval-after-load 'shell
(native-complete-setup-bash))
)
This fixed the warning mentioned above, but still the double prompt strings will be triggered:
I don’t think that is related to this package. Do you still see the double prompt when you don’t use this package?
You're right. This problem is triggered by comint-mime
. See here for the related discussion.
On Ubuntu 20.04.3 LTS, I'm using the self compiled git master Emacs, and try to install emacs-native-shell-complete with the following configuration following the guides here and here:
But I can't get the completion effect shown in the README.org when running
M-x ansi-term RET
in Emacs and then typing some commands, as shown in the screenshot below:Any hints for this problem? See here for relevant discussions.
Regards, HZ