syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.67k stars 4.89k forks source link

why auto add space in shell buffer and dired mode? #13232

Closed csfreebird closed 3 months ago

csfreebird commented 4 years ago

My shell layer configured like this:

     (shell :variables
            shell-default-height 30
            shell-default-shell 'shell
            shell-default-position 'bottom)

Today I find when pressing tab to auto-complete the dir path as following: cd ~/work I get cd ~/work/[ ] [ ] is a space It's strange, what happened, how to fix this?

Also, when rename a file int dired mode, always got one or two space in new file name.

emacs18 commented 4 years ago

This seems to be caused by an upstream changes, i.e., one of the packages. I can tell, because I tested two cases. First I used latest develop branch of spacemacs along with very recently built packages within the past few days. Second I tested the same spacemacs but with packages from about a month ago. First case shows the problem. Second case does not.

I suppose next step is determining which package or pacakges were updated in the past month to cause this problem.

csfreebird commented 4 years ago

yes, I ran into this problem recently. Before that, it worked fine. Who can fix this?

emacs18 commented 4 years ago

I tried removing all installed packages and reinstalling all latest versions. I no longer see the extra-space-at-the-end problem.

Also I learned that even earlier versions of packages showed the problem if emacs was re-started after installing packages. I observed no problem only when all packages are removed, then emacs started so that all packages are installed. I did not observe the problem. However if I exist emacs, and restart it (no packages would be installed this time since they were already installed), then I observed the problem.

emacs18 commented 4 years ago

@csfreebird can you close this issue after you verify that the problem no longer exist with latest packages?

csfreebird commented 4 years ago

I use newest code in develop branch, still has the problem. I try to update packages in spacemacs buffer twice, got another problem. I will try the third time today.

csfreebird commented 4 years ago

"removing all installed packages" How to remove theses in spacemacs?

emacs18 commented 4 years ago

Remove all files and directories under the directory specified by package-user-dir elisp variable.

duianto commented 4 years ago

Also, when rename a file int dired mode, always got one or two space in new file name.

Could you provide some reproduction steps?

When I press R on a file in a dired buffer and give it a new name, then it's renamed just as I typed, where are you seeing a space in the file name?

Could you provide your system info: Press SPC h d s to copy it to your clipboard.


In the shell SPC '

I'm not seeing an extra space after typing:

cd ~/Doc

Pressing: TAB results in:

cd ~/Documents/

with the cursor to the right of the second slash /.

Observed in both PopOS and Windows, on the latest Spacemacs develop branch with updated packages.

PopOS 19.10
#### System Info :computer:
- OS: gnu/linux
- Emacs: 26.3
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 4415131e4)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
```elisp
(auto-completion command-log emacs-lisp git helm markdown multiple-cursors
                 (org :variables org-agenda-files
                      '("~/org/notes.org"))
                 (shell :variables shell-default-shell 'shell shell-default-height 30 shell-default-position 'bottom)
                 spell-checking syntax-checking treemacs version-control)
```
- System configuration features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM THREADS LIBSYSTEMD LCMS2
Windows 1903
#### System Info :computer:
- OS: windows-nt
- Emacs: 26.3
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 4415131e4)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
```elisp
(autohotkey auto-completion command-log emacs-lisp git github
            (gnus :variables gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject)
            helm imenu-list javascript
            (markdown :variables markdown-live-preview-engine 'vmd markdown-command "vmd")
            multiple-cursors org
            (shell :variables shell-default-shell 'shell shell-default-height 30 shell-default-position 'bottom)
            spell-checking syntax-checking treemacs version-control)
```
- System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS THREADS LCMS2
csfreebird commented 4 years ago

I can't. Because I just purchased a new computer, old computer motherboard was destroyed by water. I installed spacemacs on new computer, the problem is gone. I will keep an eye on this, if it gets back, I will provide more information.

a-schaefers commented 3 years ago

I too encounter this issue, develop branch, arch linux

a-schaefers commented 3 years ago

To reproduce on latest dev branch

M-x shell touch ~/file ls ~/filTAB

results

ls ~/file [space]

a-schaefers commented 3 years ago

I disabled every explicit layer in .spacemacs and it still occurs,

here is what minor modes were enabled

Anzu Async-Bytecomp-Package Auto-Composition Auto-Compression Auto-Encryption Clean-Aindent Column-Number Dired-Async Editorconfig Electric-Indent Evil Evil-Local Eyebrowse File-Name-Shadow Font-Lock Global-Anzu Global-Auto-Revert Global-Eldoc Global-Font-Lock Global-Hl-Line Global-Hl-Todo Global-Origami Global-Page-Break-Lines Global-Spacemacs-Leader-Override Global-Spacemacs-Whitespace-Cleanup Global-Undo-Tree Global-Vi-Tilde-Fringe Helm Helm-Descbinds Helm-Flx Holy Ido-Vertical Line-Number Mouse-Wheel Origami Override-Global Persistent-Scratch-Autosave Persp Projectile Pupo Purpose Recentf Save-Place Savehist Shell-Dirtrack Show-Smartparens Show-Smartparens-Global Shx Smartparens Smartparens-Strict Spaceline-Helm Spaceline-Info Spacemacs-Leader-Override Spacemacs-Whitespace-Cleanup Transient-Mark Undo-Tree Unkillable-Scratch Vi-Tilde-Fringe Which-Key Winner Winum Xterm-Mouse

and of course yes it does not not happen with emacs -Q

emacs18 commented 3 years ago

Did you try removing your install packages? I suggest that you install new versions of packages. One sure way to do that is to remove all installed packages and let spacemacs reinstall them. Installed packages are under "elpa" subdirectory of spacemacs. You can just remove this completely, .e.,g rm -rf elpa.

a-schaefers commented 3 years ago

Yeah I did try that emacs18, I removed everything and reinstalled, same issue persists

emacs18 commented 3 years ago

Another thing I would try is to start over with fresh spacemacs file, i.e., ~/.spacemacs. You can save away your existing file, and let spacemacs recreate a fresh copy by starting emacs. See if the problem persist without any custom changes to ~/.spacemacs file. If the problem does not persist, then you can start to migrate toward your customization by first making changes to layers, then retesting.

a-schaefers commented 3 years ago

It is helm mode that is doing it, the problem goes away when you disable helm-mode

alexey0308 commented 3 years ago

related? https://github.com/emacs-helm/helm/issues/2274#issuecomment-751504105

a-schaefers commented 3 years ago

Looks like it @alexey0308 nice catch

a-schaefers commented 3 years ago

For users who depend heavily on M-x shell, a workaround until helm is fixed is to just switch to ivy.

alexey0308 commented 3 years ago

Have you actually updated packages and restarted emacs? It should be fixed now.

emacs18 commented 3 years ago

In my testing, the problem persist even with latest packages. It is easy to reproduce the problem. Just use vanilla spacemacs develop branch with no customizations. I verified that helm master branch indeed had recent fixes from helm devel branch. I also verified that spacemacs installed the latest version of helm, e.g., helm-20201228.517.

If I swap out helm layer with ivy, then the problem goes away.

This is puzzling to me. My normal spacemacs config uses helm. Yet I don't observe the problem. I only observe the problem if I use vanilla spacemacs.

alexey0308 commented 3 years ago

@emacs18 how do you quickly check vanilla spacemacs?

emacs18 commented 3 years ago

I use chemacs package so that I can choose one of the following profiles on emacs starup:

I tweaked few lines in spacemacs so that ~/.spacemacs is not used. I also do rm ~/.spacemacs; touch ~/.spacemacs; chmod 444 ~/.spacemacs to make sure it is not messed with in any way.

emacs18 commented 3 years ago

I discovered how I solved the extra space problem. Following customization resolved the problem for me.

(define-hook-helper shell-mode ()

  ...

  ;; I discovered the hard way that the following two changes are needed to
  ;; prevent emacs from inserting a space after file name completions. -rk
  ;; 8/19/2020
  (setq comint-completion-addsuffix nil)
  (setq pcomplete-termination-string "")
  )

comint-completion-addsuffix documentation is:

If non-nil, add ‘ ’ to file names.
It can either be a string FILESUFFIX or a cons (DIRSUFFIX . FILESUFFIX)
where DIRSUFFIX is ignored and FILESUFFIX is a string added on unambiguous
or exact completion.
This mirrors the optional behavior of tcsh.

pcomlete-termination-string documentation is:

This function is obsolete since 27.1;
use completion-at-point and pcomplete-completions-at-point
Probably introduced at or before Emacs version 21.1.

Support extensible programmable completion.
To use this function, just bind the TAB key to it, or add it to your
completion functions list (it should occur fairly early in the list).
github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!