Closed jeongsoolee09 closed 5 years ago
After evaluating those two lines, :q
closes the current buffer for me and :quit
closes Spacemacs.
On the develop
branch with updated packages.
In both Windows 10:
(autohotkey emacs-lisp git helm markdown multiple-cursors
(org :variables org-enable-org-journal-support t)
spell-checking treemacs version-control)
And Ubuntu 18.04:
(emacs-lisp git helm multiple-cursors org spell-checking treemacs version-control)
Yes, simply evaluating them in the scratch buffer rebinds :q without any problems for me also. It is when I add the two lines in my .spacemaacs that things go wrong. After closing Spacemacs having evaluated those lines, the effect stops to take place, and :q simply shuts down Spacemacs entirely. :(
They still work for me when I add them to the dotspacemacs/user-config
section of my .spacemacs
.
Are you on the Spacemacs master
branch?
You can copy your system information to the clipboard by pressing SPC h d s
.
Oops, I have totally forgotten this issue for the last two weeks. I have not yet tested if I was on the master
branch; I have simply rolled back to regular Emacs. For now, I will close this issue and reopen it if this problem still occurs after I test it out again in the near future. Thanks!
I also did put the lines
(evil-ex-define-cmd "q" 'kill-this-buffer)
(evil-ex-define-cmd "quit" 'evil-quit)
in my .spacemacs user-config section. However, when using :q it exits Spacemacs competely (also on :quit). I'm on develop - any ideas on what direction to look in order to solve this?
(html helm auto-completion emacs-lisp git org
(osx :variables osx-option-as 'meta osx-right-option-as 'none)
python)
I'm still getting the expected behavior:
:q
only closes the current buffer:quit
closes Spacemacs#### System Info :computer: - OS: gnu/linux - Emacs: 26.3.50 - Spacemacs: 0.300.0 - Spacemacs branch: develop (rev. e0aee1554) - 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")) pdf (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 SOUND DBUS GSETTINGS GLIB NOTIFY LIBSELINUX GNUTLS FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS
#### System Info :computer: - OS: windows-nt - Emacs: 26.3 - Spacemacs: 0.300.0 - Spacemacs branch: develop (rev. e0aee1554) - Graphic display: t - Distribution: spacemacs - Editing style: vim - Completion: helm - Layers: ```elisp (autohotkey auto-completion c-c++ command-log emacs-lisp git github (gnus :variables gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject) go helm imenu-list javascript (markdown :variables markdown-live-preview-engine 'vmd markdown-command "vmd") multiple-cursors org pdf (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
But it seems like the kill-this-buffer
command only is intended to be used from the menu-bar (which Spacemacs disables by default. It can be toggled on/off with: SPC T m
)
I found out about the kill-this-buffer
commands "limitation" when I searched for:
emacs kill buffer
and found a suggestion of binding a new function to:
(kill-buffer (current-buffer))
http://pragmaticemacs.com/emacs/dont-kill-buffer-kill-this-buffer-instead/
(defun bjm/kill-this-buffer ()
"Kill the current buffer."
(interactive)
(kill-buffer (current-buffer)))
(global-set-key (kbd "C-x k") 'bjm/kill-this-buffer)
with the comment:
Commenter thbit points out that using kill-this-buffer in this way is unstable (see discussion here). Here is a safer alternative.
It links to this thread: https://www.reddit.com/r/emacs/comments/64xb3q/killthisbuffer_sometimes_just_stops_working/
where an Emacs maintainer says:
If you disable the menu bar, then how you invoke kill-this-buffer? That command is intended to be invoked from the menu bar.
https://www.reddit.com/r/emacs/comments/64xb3q/killthisbuffer_sometimes_just_stops_working/dg5tgew/
A later comment says: https://www.reddit.com/r/emacs/comments/64xb3q/killthisbuffer_sometimes_just_stops_working/dg5z0v6/
It originally could be invoked by other inputs, and was made menu-bar specific just 9 years ago.
So it's been menu-bar specific for a while.
The suggested expression (kill-buffer (current-buffer))
can be bound to evil ex cmd q
like this:
(defun my/kill-this-buffer ()
(interactive)
(kill-buffer (current-buffer)))
(evil-ex-define-cmd "q" 'my/kill-this-buffer)
OS: OS X Mojave Emacs: 26.2
What I did: I added the following to my .spcaemacs:
Expected Behavior: Command :q is rebound to killing the current buffer: i.e. equivalent to pressing
SPC b d
.What actually happened: Spacemacs reports that it detected an error in .spacemacs. It enters into debugging mode after asking an edit mode for recovery.
I am certain that the error is caused by the two lines of code above, since commenting both out does not cause any problem.
The
evil-ex-define-cmd
function used to work in regular Emacs, and I have discovered some suggestions from Spacemacs users to use the above code. I am not sure why they do not work properly for mine.