diff options
| author | Matthias Meulien | 2021-11-29 16:42:02 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-11-29 16:42:02 +0100 |
| commit | 0d2f184a1107a910c2ebadbff1a88be32391bbf6 (patch) | |
| tree | 6cca0d3d96dc47463d31b99c53ad4b1eb5e230c9 | |
| parent | 4de13ef147a4c88c33fe608ee7ca5bd4212476ee (diff) | |
| download | emacs-0d2f184a1107a910c2ebadbff1a88be32391bbf6.tar.gz emacs-0d2f184a1107a910c2ebadbff1a88be32391bbf6.zip | |
project-kill-buffers can display list of buffers to kill
* lisp/progmodes/project.el
(project-kill-buffers-display-buffer-list): Option to toggle
temporarily display of the list of buffers to kill when calling
project-kill-buffers
(project-kill-buffers): Handle
project-kill-buffers-display-buffer-list option (bug#52148).
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/progmodes/project.el | 38 |
2 files changed, 38 insertions, 4 deletions
| @@ -427,6 +427,10 @@ it with new 'term-{faint,italic,slow-blink,fast-blink}' faces. | |||
| 427 | *** 'project-find-file' and 'project-or-external-find-file' now accept | 427 | *** 'project-find-file' and 'project-or-external-find-file' now accept |
| 428 | a prefix argument which is interpreted to mean "include all files". | 428 | a prefix argument which is interpreted to mean "include all files". |
| 429 | 429 | ||
| 430 | *** 'project-kill-buffers' can display the list of buffers to kill. | ||
| 431 | Customize the user option 'project-kill-buffers-display-buffer-list' | ||
| 432 | to enable the display of the buffer list. | ||
| 433 | |||
| 430 | +++ | 434 | +++ |
| 431 | *** New command 'xref-go-forward'. | 435 | *** New command 'xref-go-forward'. |
| 432 | It is bound to 'C-M-,' and jumps to the location where 'xref-go-back' | 436 | It is bound to 'C-M-,' and jumps to the location where 'xref-go-back' |
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index ed076a683d1..c2e125a017a 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el | |||
| @@ -1210,6 +1210,15 @@ current project, it will be killed." | |||
| 1210 | :group 'project | 1210 | :group 'project |
| 1211 | :package-version '(project . "0.6.0")) | 1211 | :package-version '(project . "0.6.0")) |
| 1212 | 1212 | ||
| 1213 | (defcustom project-kill-buffers-display-buffer-list nil | ||
| 1214 | "Non-nil to display list of buffers to kill before killing project buffers. | ||
| 1215 | Used by `project-kill-buffers'." | ||
| 1216 | :type 'boolean | ||
| 1217 | :version "29.1" | ||
| 1218 | :group 'project | ||
| 1219 | :package-version '(project . "0.8.1") | ||
| 1220 | :safe #'booleanp) | ||
| 1221 | |||
| 1213 | (defun project--buffer-list (pr) | 1222 | (defun project--buffer-list (pr) |
| 1214 | "Return the list of all buffers in project PR." | 1223 | "Return the list of all buffers in project PR." |
| 1215 | (let ((conn (file-remote-p (project-root pr))) | 1224 | (let ((conn (file-remote-p (project-root pr))) |
| @@ -1276,14 +1285,35 @@ NO-CONFIRM is always nil when the command is invoked | |||
| 1276 | interactively." | 1285 | interactively." |
| 1277 | (interactive) | 1286 | (interactive) |
| 1278 | (let* ((pr (project-current t)) | 1287 | (let* ((pr (project-current t)) |
| 1279 | (bufs (project--buffers-to-kill pr))) | 1288 | (bufs (project--buffers-to-kill pr)) |
| 1289 | (query-user (lambda () | ||
| 1290 | (yes-or-no-p | ||
| 1291 | (format "Kill %d buffers in %s? " | ||
| 1292 | (length bufs) | ||
| 1293 | (project-root pr)))))) | ||
| 1280 | (cond (no-confirm | 1294 | (cond (no-confirm |
| 1281 | (mapc #'kill-buffer bufs)) | 1295 | (mapc #'kill-buffer bufs)) |
| 1282 | ((null bufs) | 1296 | ((null bufs) |
| 1283 | (message "No buffers to kill")) | 1297 | (message "No buffers to kill")) |
| 1284 | ((yes-or-no-p (format "Kill %d buffers in %s? " | 1298 | (project-kill-buffers-display-buffer-list |
| 1285 | (length bufs) | 1299 | (when |
| 1286 | (project-root pr))) | 1300 | (with-current-buffer-window |
| 1301 | (get-buffer-create "*Buffer List*") | ||
| 1302 | `(display-buffer--maybe-at-bottom | ||
| 1303 | (dedicated . t) | ||
| 1304 | (window-height . (fit-window-to-buffer)) | ||
| 1305 | (preserve-size . (nil . t)) | ||
| 1306 | (body-function | ||
| 1307 | . ,#'(lambda (_window) | ||
| 1308 | (list-buffers-noselect nil bufs)))) | ||
| 1309 | #'(lambda (window _value) | ||
| 1310 | (with-selected-window window | ||
| 1311 | (unwind-protect | ||
| 1312 | (funcall query-user) | ||
| 1313 | (when (window-live-p window) | ||
| 1314 | (quit-restore-window window 'kill)))))) | ||
| 1315 | (mapc #'kill-buffer bufs))) | ||
| 1316 | ((funcall query-user) | ||
| 1287 | (mapc #'kill-buffer bufs))))) | 1317 | (mapc #'kill-buffer bufs))))) |
| 1288 | 1318 | ||
| 1289 | 1319 | ||