Skip to content

Commit

Permalink
Merge pull request #851 from Sasanidas/main
Browse files Browse the repository at this point in the history
Add modified buffers information when exit Lem
  • Loading branch information
cxxxr authored Jul 19, 2023
2 parents 16786b6 + 88e2f87 commit da9ab6a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/base/buffers.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
(buffer-modified-p buffer)))
(buffer-list)))

(defun modified-buffers ()
(remove-if (lambda (buffer)
(not (and (buffer-filename buffer)
(buffer-modified-p buffer))))
(buffer-list)))

(defun get-buffer (buffer-or-name)
"`buffer-or-name`がバッファならそのまま返し、
文字列ならその名前のバッファを返します。"
Expand Down
1 change: 1 addition & 0 deletions src/base/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
:kill-buffer-hook
:buffer-list
:any-modified-buffer-p
:modified-buffers
:get-buffer
:get-or-create-buffer
:unique-buffer-name
Expand Down
14 changes: 10 additions & 4 deletions src/commands/other.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@

(define-command exit-lem (&optional (ask t)) ()
"Ask for modified buffers before exiting lem."
(when (or (null ask)
(not (any-modified-buffer-p))
(prompt-for-y-or-n-p "Modified buffers exist. Leave anyway"))
(exit-editor)))
(let ((modified-buffers
(mapcar #'buffer-name (modified-buffers))))
(and (or
(null ask)
(not modified-buffers)
(prompt-for-y-or-n-p
(format nil
"Modified buffers exist:~%~{~a~%~}Leave anyway?"
modified-buffers)))
(exit-editor))))

(define-command quick-exit () ()
"Exit the lem job and kill it."
Expand Down

0 comments on commit da9ab6a

Please sign in to comment.