diff options
| author | John Paul Wallington | 2008-06-26 15:26:58 +0000 |
|---|---|---|
| committer | John Paul Wallington | 2008-06-26 15:26:58 +0000 |
| commit | c93addf59ea9bd82117b70a8a3ddc9428b3a1919 (patch) | |
| tree | 3a59088a7e60f8f3107f95125f97d4908f1ebdc2 | |
| parent | c9fc02c727886c8ca8863365a395c91024455789 (diff) | |
| download | emacs-c93addf59ea9bd82117b70a8a3ddc9428b3a1919.tar.gz emacs-c93addf59ea9bd82117b70a8a3ddc9428b3a1919.zip | |
(ibuffer-diff-buffer-with-file-1): New function.
(ibuffer-diff-with-file): Use it. Do diff on marked buffers
(ibuffer-mark-on-buffer): Don't display message when removing marks.
(ibuffer-mark-by-mode): Use `buffer-local-value'.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/ibuf-ext.el | 67 |
2 files changed, 66 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4464702584e..ddbb560e9af 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2008-06-26 John Paul Wallington <jpw@pobox.com> | ||
| 2 | |||
| 3 | * ibuf-ext.el (ibuffer-diff-buffer-with-file-1): New function. | ||
| 4 | (ibuffer-diff-with-file): Use it. Do diff on marked buffers | ||
| 5 | (ibuffer-mark-on-buffer): Don't display message when removing marks. | ||
| 6 | (ibuffer-mark-by-mode): Use `buffer-local-value'. | ||
| 7 | |||
| 1 | 2008-06-26 Dan Nicolaescu <dann@ics.uci.edu> | 8 | 2008-06-26 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 9 | ||
| 3 | * vc-dir.el (tool-bar): Require. | 10 | * vc-dir.el (tool-bar): Require. |
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 257fe89c03b..2624fdaff69 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el | |||
| @@ -1298,15 +1298,66 @@ a prefix argument reverses the meaning of that variable." | |||
| 1298 | (error "No buffer with name %s" name) | 1298 | (error "No buffer with name %s" name) |
| 1299 | (goto-char buf-point))))) | 1299 | (goto-char buf-point))))) |
| 1300 | 1300 | ||
| 1301 | (defun ibuffer-diff-buffer-with-file-1 (buffer) | ||
| 1302 | (let ((bufferfile (buffer-local-value 'buffer-file-name buffer)) | ||
| 1303 | (tempfile (make-temp-file "buffer-content-"))) | ||
| 1304 | (when bufferfile | ||
| 1305 | (unwind-protect | ||
| 1306 | (progn | ||
| 1307 | (with-current-buffer buffer | ||
| 1308 | (write-region nil nil tempfile nil 'nomessage)) | ||
| 1309 | (let* ((old (expand-file-name bufferfile)) | ||
| 1310 | (new (expand-file-name tempfile)) | ||
| 1311 | (oldtmp (file-local-copy old)) | ||
| 1312 | (newtmp (file-local-copy new)) | ||
| 1313 | (switches diff-switches) | ||
| 1314 | (command | ||
| 1315 | (mapconcat | ||
| 1316 | 'identity | ||
| 1317 | `(,diff-command | ||
| 1318 | ;; Use explicitly specified switches | ||
| 1319 | ,@(if (listp switches) switches (list switches)) | ||
| 1320 | ,@(if (or old new) | ||
| 1321 | (list "-L" old | ||
| 1322 | "-L" (shell-quote-argument | ||
| 1323 | (format "Buffer %s" (buffer-name buffer))))) | ||
| 1324 | ,(shell-quote-argument (or oldtmp old)) | ||
| 1325 | ,(shell-quote-argument (or newtmp new))) | ||
| 1326 | " ")) | ||
| 1327 | proc) | ||
| 1328 | (let ((inhibit-read-only t)) | ||
| 1329 | (insert command "\n") | ||
| 1330 | (diff-sentinel | ||
| 1331 | (call-process shell-file-name nil | ||
| 1332 | (current-buffer) nil | ||
| 1333 | shell-command-switch command))) | ||
| 1334 | (insert "\n")))) | ||
| 1335 | (sit-for 0) | ||
| 1336 | (when (file-exists-p tempfile) | ||
| 1337 | (delete-file tempfile))))) | ||
| 1338 | |||
| 1301 | ;;;###autoload | 1339 | ;;;###autoload |
| 1302 | (defun ibuffer-diff-with-file () | 1340 | (defun ibuffer-diff-with-file () |
| 1303 | "View the differences between this buffer and its associated file. | 1341 | "View the differences between marked buffers and their associated files. |
| 1342 | If no buffers are marked, use buffer at point. | ||
| 1304 | This requires the external program \"diff\" to be in your `exec-path'." | 1343 | This requires the external program \"diff\" to be in your `exec-path'." |
| 1305 | (interactive) | 1344 | (interactive) |
| 1306 | (let ((buf (ibuffer-current-buffer))) | 1345 | (require 'diff) |
| 1307 | (unless (buffer-live-p buf) | 1346 | (let ((marked-bufs (ibuffer-get-marked-buffers))) |
| 1308 | (error "Buffer %s has been killed" buf)) | 1347 | (when (null marked-bufs) |
| 1309 | (diff-buffer-with-file buf))) | 1348 | (setq marked-bufs (list (ibuffer-current-buffer t)))) |
| 1349 | (with-current-buffer (get-buffer-create "*Ibuffer Diff*") | ||
| 1350 | (setq buffer-read-only nil) | ||
| 1351 | (buffer-disable-undo (current-buffer)) | ||
| 1352 | (erase-buffer) | ||
| 1353 | (buffer-enable-undo (current-buffer)) | ||
| 1354 | (diff-mode) | ||
| 1355 | (dolist (buf marked-bufs) | ||
| 1356 | (unless (buffer-live-p buf) | ||
| 1357 | (error "Buffer %s has been killed" buf)) | ||
| 1358 | (ibuffer-diff-buffer-with-file-1 buf)) | ||
| 1359 | (setq buffer-read-only t))) | ||
| 1360 | (switch-to-buffer "*Ibuffer Diff*")) | ||
| 1310 | 1361 | ||
| 1311 | ;;;###autoload | 1362 | ;;;###autoload |
| 1312 | (defun ibuffer-copy-filename-as-kill (&optional arg) | 1363 | (defun ibuffer-copy-filename-as-kill (&optional arg) |
| @@ -1361,7 +1412,8 @@ You can then feed the file name(s) to other commands with \\[yank]." | |||
| 1361 | nil | 1412 | nil |
| 1362 | group))) | 1413 | group))) |
| 1363 | (ibuffer-redisplay t) | 1414 | (ibuffer-redisplay t) |
| 1364 | (message "Marked %s buffers" count))) | 1415 | (unless (eq ibuffer-mark-on-buffer-mark ?\s) |
| 1416 | (message "Marked %s buffers" count)))) | ||
| 1365 | 1417 | ||
| 1366 | ;;;###autoload | 1418 | ;;;###autoload |
| 1367 | (defun ibuffer-mark-by-name-regexp (regexp) | 1419 | (defun ibuffer-mark-by-name-regexp (regexp) |
| @@ -1414,8 +1466,7 @@ You can then feed the file name(s) to other commands with \\[yank]." | |||
| 1414 | "")))))) | 1466 | "")))))) |
| 1415 | (ibuffer-mark-on-buffer | 1467 | (ibuffer-mark-on-buffer |
| 1416 | #'(lambda (buf) | 1468 | #'(lambda (buf) |
| 1417 | (with-current-buffer buf | 1469 | (eq (buffer-local-value 'major-mode buf) mode)))) |
| 1418 | (eq major-mode mode))))) | ||
| 1419 | 1470 | ||
| 1420 | ;;;###autoload | 1471 | ;;;###autoload |
| 1421 | (defun ibuffer-mark-modified-buffers () | 1472 | (defun ibuffer-mark-modified-buffers () |