]> git.eshelyaron.com Git - emacs.git/commitdiff
Close SQL database when corresponding 'sqlite-mode' buffer is killed
authorThomas Hilke <t.hilke@rollomatic.ch>
Fri, 15 Sep 2023 08:30:25 +0000 (10:30 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 16 Sep 2023 10:20:45 +0000 (13:20 +0300)
* lisp/sqlite-mode.el (sqlite-mode-open-file): Close DB when the
buffer is killed.  (Bug#65998)

Copyright-paperwork-exempt: yes

lisp/sqlite-mode.el

index 8cb944853693f85d34a80be53f7b926547dddbf0..71c9e57fc12d2404aee1c8c1adbfc572be3870c9 100644 (file)
@@ -63,6 +63,7 @@
   (setq-local sqlite--db (sqlite-open file))
   (unless (sqlitep sqlite--db)
     (error "`sqlite-open' failed to open SQLite file"))
+  (add-hook 'kill-buffer-hook (lambda () (sqlite-close sqlite--db)) nil t)
   (sqlite-mode-list-tables))
 
 (defun sqlite-mode-list-tables ()