spacemacs
spacemacs copied to clipboard
Spacemacs inserts a newline in cursor place after exiting (C-x C-c).
Description :octocat:
Spacemacs inserts a newline in cursor place after exiting (C-x C-c). Not intended behavior. Affects spacemacs, spacemacs-base, ivy and helm alike. I use emacs keybindings.
Reproduction guide :beetle:
- Start Emacs
- Open file
- Exit using C-x C-c
- Emacs will ask if you want to save changes (Why would it? We just wanted to exit)
- If yes, the file will have a newline after opening the file again
Observed behaviour: :eyes: :broken_heart: A newline is inserted after exiting.
Expected behaviour: :heart: :smile: The file should be intact after exiting, as we did not modify it whatsoever.
System Info :computer:
- OS: gnu/linux
- Emacs: 26.1
- Spacemacs: 0.200.13
- Spacemacs branch: master (rev. c7a103a77)
- Graphic display: t
- Distribution: spacemacs-base
- Editing style: emacs
- Completion: ivy
- Layers:
(ivy emacs-lisp)
- System configuration features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES THREADS LIBSYSTEMD LCMS2
Bumping this thread as this still applies to latest spacemacs. Am I the only one experiencing this?
That is a feature, not an issue. Many files I have seen, have a newline at the end of the file. You can turn off this feature by setting require-final-newline
to nil
.
I double checked and it doesn't seem to affect the bug I'm talking about. My issue is about the creation of newlines in the place the cursor was before it was saved and closed, not the final newline that is added to all texts.
That is a feature, not an issue. Many files I have seen, have a newline at the end of the file. You can turn off this feature by setting
require-final-newline
tonil
.
Actually, (setq require-final-newline nil)
won't work, value of require-final-newline
is still t
, you have to set (setq-default mode-require-final-newline nil)
I believe the newline is inserted when you open a file by clicking on the file name from the spacemacs home page. Try click on a file from the spacemacs home page and then C-/ it will undo the newline inserted to the buffer. I noticed the newline is inserted after the cursor position not at the end of file.
And try open the file by C-x C-f, it won't insert newline
@mateodif Please check kill-emacs-hook
.
The second reproduction step needs to clarify how the file is opened:
Open file
If it only occurs as hamadmarri suggests. When mouse clicking on a file in the Spacemacs home buffer, then it sounds like this issue: Auto paste into the files opened by mouse-click the item below Recent Files in Spacemacs buffer #5435
This seems to be the most up voted work-around: https://github.com/syl20bnr/spacemacs/issues/5435#issuecomment-195862080
I have the same issue on macos. @duianto , that solution doesn't work for me; I just get control code printed to minibuffer when clicking on links (in dumb terminal).
@paxperscientiam Could you provide some reproduction steps and include your system info.
Press SPC h d s
to copy your system info to the clipboard.
It would also be helpful if your able to copy the buffers contents both before and after the issue occurs. If your unable to copy the contents, then you can post screenshots.
I believe the newline is inserted when you open a file by clicking on the file name from the spacemacs home page. Try click on a file from the spacemacs home page and then C-/ it will undo the newline inserted to the buffer. I noticed the newline is inserted after the cursor position not at the end of file.
And try open the file by C-x C-f, it won't insert newline
I can confirm it does insert the new line ONLY when you click the on the file in the landing buffer.
System Info :computer:
- OS: gnu/linux
- Emacs: 26.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. c9c5637ac)
- Graphic display: t
- Distribution: spacemacs
- Editing style: emacs
- Completion: helm
- Layers:
(javascript helm auto-completion emacs-lisp git markdown html syntax-checking erlang elm)
- System configuration features: XAW3D XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 THREADS LIBSYSTEMD LCMS2
@memer-boy As I mentioned in the comment above ☝️ https://github.com/syl20bnr/spacemacs/issues/11733#issuecomment-578527067
There's an open issue about that: Auto paste into the files opened by mouse-click the item below Recent Files in Spacemacs buffer #5435
it has an up voted workaround: https://github.com/syl20bnr/spacemacs/issues/5435#issuecomment-195862080
;; This problem may be related with wid-edit.el and mouse-1-click-follows-link.
;; Now I can avoid automatic yank by putting the following config in
;; spacemacs/user-config.
(add-hook 'spacemacs-buffer-mode-hook
(lambda () (set (make-local-variable
'mouse-1-click-follows-link)
nil)))
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!
I actually participated in a discussion over at emacs-dashboard/emacs-dashboard about this very issue. Long story short, there's a solution that can now be adopted.
https://github.com/emacs-dashboard/emacs-dashboard/pull/285
Actually,
(setq require-final-newline nil)
won't work, value ofrequire-final-newline
is stillt
, you have to set(setq-default mode-require-final-newline nil)
In my case, (setq require-final-newline nil)
worked, and (setq-default mode-require-final-newline nil)
didn't. 🤷♂️