rougier / nano-emacs

GNU Emacs / N Λ N O - Emacs made simple
GNU General Public License v3.0
2.5k stars 191 forks source link

Attempt to delete the sole visible or iconified frame #128

Closed philipsd6 closed 1 year ago

philipsd6 commented 1 year ago

nano--delete-frame-or-kill-emacs (C-c C-x) after extended use frequently results in an error:

nano--delete-frame-or-kill-emacs: Attempt to delete the sole visible or iconified frame

This is because the code is checking for a frame-list > 1, and the list has multiple frames, but only one is left visible. I don't know why I have so many invisible frames, but daemon-mode for one will always be at least one more frame than one, right?

(frame-list)
(#<frame  0x5590911dce60> #<frame  0x559082a71850> #<frame  0x5590851585f0> #<frame  0x559081392328>)
Debugger entered--Lisp error: (error "Attempt to delete the sole visible or iconified fr...")
  delete-frame()
  nano--delete-frame-or-kill-emacs()
  eval-expression((nano--delete-frame-or-kill-emacs) nil nil 127)
  funcall-interactively(eval-expression (nano--delete-frame-or-kill-emacs) nil nil 127)
  command-execute(eval-expression)
rougier commented 1 year ago

I've modified if locally (without pushing) to:

(defun my/kill-emacs ()
  "Delete frame or kill Emacs if there is only one frame."

  (interactive)
  (condition-case nil
      (delete-frame)
    (error (save-buffers-kill-terminal))))
philipsd6 commented 1 year ago

That works for me, I'll incorporate it in my config. Thanks!