diff options
| author | foudfou | 2015-12-12 22:06:03 +0100 |
|---|---|---|
| committer | John Wiegley | 2015-12-14 12:21:51 -0800 |
| commit | 97abf9273a80e0890b4756ec4d09d8bfe4077bba (patch) | |
| tree | 9336afd96b2cd60badd3f37f7dd42549568800b9 | |
| parent | ecaaf900e84233d142a656250767544ff34d010a (diff) | |
| download | emacs-97abf9273a80e0890b4756ec4d09d8bfe4077bba.tar.gz emacs-97abf9273a80e0890b4756ec4d09d8bfe4077bba.zip | |
* lisp/ibuffer.el: Add ability to (un-)mark or delete buffers in the region.
| -rw-r--r-- | lisp/ibuffer.el | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 5819f63c671..bfb247ca842 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el | |||
| @@ -1354,23 +1354,36 @@ group." | |||
| 1354 | (message "%s buffers marked" count)) | 1354 | (message "%s buffers marked" count)) |
| 1355 | (ibuffer-redisplay t)) | 1355 | (ibuffer-redisplay t)) |
| 1356 | 1356 | ||
| 1357 | (defun ibuffer-mark-forward (arg) | 1357 | (defsubst ibuffer-get-region-and-prefix () |
| 1358 | "Mark the buffer on this line, and move forward ARG lines. | 1358 | (let ((arg (prefix-numeric-value current-prefix-arg))) |
| 1359 | (if (use-region-p) (list (region-beginning) (region-end) arg) | ||
| 1360 | (list nil nil arg)))) | ||
| 1361 | |||
| 1362 | (defun ibuffer-mark-forward (start end arg) | ||
| 1363 | "Mark the buffers in the region, or ARG buffers. | ||
| 1359 | If point is on a group name, this function operates on that group." | 1364 | If point is on a group name, this function operates on that group." |
| 1360 | (interactive "p") | 1365 | (interactive (ibuffer-get-region-and-prefix)) |
| 1361 | (ibuffer-mark-interactive arg ibuffer-marked-char)) | 1366 | (ibuffer-mark-region-or-n-with-char start end arg ibuffer-marked-char)) |
| 1362 | 1367 | ||
| 1363 | (defun ibuffer-unmark-forward (arg) | 1368 | (defun ibuffer-unmark-forward (start end arg) |
| 1364 | "Unmark the buffer on this line, and move forward ARG lines. | 1369 | "Unmark the buffers in the region, or ARG buffers. |
| 1365 | If point is on a group name, this function operates on that group." | 1370 | If point is on a group name, this function operates on that group." |
| 1366 | (interactive "p") | 1371 | (interactive (ibuffer-get-region-and-prefix)) |
| 1367 | (ibuffer-mark-interactive arg ?\s)) | 1372 | (ibuffer-mark-region-or-n-with-char start end arg ?\s)) |
| 1368 | 1373 | ||
| 1369 | (defun ibuffer-unmark-backward (arg) | 1374 | (defun ibuffer-unmark-backward (arg) |
| 1370 | "Unmark the buffer on this line, and move backward ARG lines. | 1375 | "Unmark the ARG previous buffers. |
| 1371 | If point is on a group name, this function operates on that group." | 1376 | If point is on a group name, this function operates on that group." |
| 1372 | (interactive "p") | 1377 | (interactive "p") |
| 1373 | (ibuffer-unmark-forward (- arg))) | 1378 | (ibuffer-unmark-forward nil nil (- arg))) |
| 1379 | |||
| 1380 | (defun ibuffer-mark-region-or-n-with-char (start end arg mark-char) | ||
| 1381 | (if (use-region-p) | ||
| 1382 | (let ((cur (point)) (line-count (count-lines start end))) | ||
| 1383 | (goto-char start) | ||
| 1384 | (ibuffer-mark-interactive line-count mark-char) | ||
| 1385 | (goto-char cur)) | ||
| 1386 | (ibuffer-mark-interactive arg mark-char))) | ||
| 1374 | 1387 | ||
| 1375 | (defun ibuffer-mark-interactive (arg mark &optional movement) | 1388 | (defun ibuffer-mark-interactive (arg mark &optional movement) |
| 1376 | (ibuffer-assert-ibuffer-mode) | 1389 | (ibuffer-assert-ibuffer-mode) |
| @@ -1409,16 +1422,16 @@ If point is on a group name, this function operates on that group." | |||
| 1409 | (list (ibuffer-current-buffer) | 1422 | (list (ibuffer-current-buffer) |
| 1410 | mark)))) | 1423 | mark)))) |
| 1411 | 1424 | ||
| 1412 | (defun ibuffer-mark-for-delete (arg) | 1425 | (defun ibuffer-mark-for-delete (start end arg) |
| 1413 | "Mark the buffers on ARG lines forward for deletion. | 1426 | "Mark for deletion the buffers in the region, or ARG buffers. |
| 1414 | If point is on a group name, this function operates on that group." | 1427 | If point is on a group name, this function operates on that group." |
| 1415 | (interactive "P") | 1428 | (interactive (ibuffer-get-region-and-prefix)) |
| 1416 | (ibuffer-mark-interactive arg ibuffer-deletion-char 1)) | 1429 | (ibuffer-mark-region-or-n-with-char start end arg ibuffer-deletion-char)) |
| 1417 | 1430 | ||
| 1418 | (defun ibuffer-mark-for-delete-backwards (arg) | 1431 | (defun ibuffer-mark-for-delete-backwards (arg) |
| 1419 | "Mark the buffers on ARG lines backward for deletion. | 1432 | "Mark for deletion the ARG previous buffers. |
| 1420 | If point is on a group name, this function operates on that group." | 1433 | If point is on a group name, this function operates on that group." |
| 1421 | (interactive "P") | 1434 | (interactive "p") |
| 1422 | (ibuffer-mark-interactive arg ibuffer-deletion-char -1)) | 1435 | (ibuffer-mark-interactive arg ibuffer-deletion-char -1)) |
| 1423 | 1436 | ||
| 1424 | (defun ibuffer-current-buffer (&optional must-be-live) | 1437 | (defun ibuffer-current-buffer (&optional must-be-live) |