Closed carrotflakes closed 2 years ago
I would encourage not doing this by default. lem
doesn't need to carry the whole baggage of emacs.
I'll close this issue once 🙏
This is not an Emacs-specific feature. Most applications running in a shell follow this convention. Vim/Neovim also allows users to suspend it temporarily, and I think it's quite useful to access the full shell.
Perhaps it can be omitted if Lem has a complete shell-mode, though.
This is a workaround to do in ~/lem/init.lisp
:
(define-command suspend-lem () ()
(charms/ll:endwin)
(uiop:launch-program `("kill" "-TSTP" ,(princ-to-string (sb-posix:getpid)))))
(define-key *global-keymap* "C-z" 'suspend-lem)
It fails randomly about 1 in 20 times because ncurses's wgetch
blocks signals from SBCL.
It can be solved by wrapping it by sb-sys:without-interrupts
, but it will introduce another small inconvenience when quitting Lem.
diff --git a/frontends/ncurses/ncurses.lisp b/frontends/ncurses/ncurses.lisp
index 628d487c..31d0e295 100644
--- a/frontends/ncurses/ncurses.lisp
+++ b/frontends/ncurses/ncurses.lisp
@@ -107,7 +107,8 @@
(setf *padwin* (charms/ll:newpad 1 1))
(charms/ll:keypad *padwin* 1)
(charms/ll:wtimeout *padwin* -1))
- (charms/ll:wgetch *padwin*))
+ (sb-sys:with-interrupts
+ (charms/ll:wgetch *padwin*)))
(defmacro with-getch-input-timeout ((time) &body body)
`(progn
(charms/ll:wtimeout *padwin* ,time)
I found this works perfectly without any problems. I added this to my init.lisp.
(define-command suspend-lem () ()
(charms/ll:endwin)
(sb-posix:kill (sb-posix:getpid) sb-posix:sigtstp))
(define-key *global-keymap* "C-z" 'suspend-lem)
charms/ll
doesn't exist when we run the SDL2 GUI, so we can do:
(define-command suspend-lem () ()
(when (find-package 'charms/ll)
(uiop:symbol-call 'charms/ll 'endwin)
(sb-posix:kill (sb-posix:getpid) sb-posix:sigtstp)))
Good point.
I run it only on lem-ncurses
like:
https://github.com/fukamachi/.lem/blob/master/init.lisp#L21-L27
oh, with:
#+(and lem-ncurses (not (and darwin arm64)))
that's better.
I want to move lem process to background, like emacs.