aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters2002-04-14 01:50:57 +0000
committerColin Walters2002-04-14 01:50:57 +0000
commit57c9cc3ee1c9c375535fb35f33588b8eced9292a (patch)
tree75e3437a1632bc11218560382b6548b92e4b9aa2
parente32ddb14af010ca165179da623faac94d2d4d341 (diff)
downloademacs-57c9cc3ee1c9c375535fb35f33588b8eced9292a.tar.gz
emacs-57c9cc3ee1c9c375535fb35f33588b8eced9292a.zip
(ibuffer-forward-line): Just skip header if we're
only moving one line forward. (ibuffer-map-lines): Preserve point position even if we delete lines. Only call mapping functions with buffer and mark arguments; the other two were unused. (ibuffer-redisplay, ibuffer-update): Always skip special areas.
-rw-r--r--lisp/ibuffer.el127
1 files changed, 65 insertions, 62 deletions
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index b936bb15afe..b981ac304da 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -826,8 +826,11 @@ width and the longest string in LIST."
826 (when (or (eobp) 826 (when (or (eobp)
827 (get-text-property (point) 'ibuffer-summary)) 827 (get-text-property (point) 'ibuffer-summary))
828 (goto-char (point-min))) 828 (goto-char (point-min)))
829 (while (get-text-property (point) 'ibuffer-title) 829 (when (get-text-property (point) 'ibuffer-title)
830 (forward-line 1)) 830 (if (> arg 0)
831 (decf arg))
832 (while (get-text-property (point) 'ibuffer-title)
833 (forward-line 1)))
831 (if (< arg 0) 834 (if (< arg 0)
832 (ibuffer-backward-line (- arg)) 835 (ibuffer-backward-line (- arg))
833 (while (> arg 0) 836 (while (> arg 0)
@@ -1006,7 +1009,7 @@ a new window in the current frame, splitting vertically."
1006(defun ibuffer-buffer-names-with-mark (mark) 1009(defun ibuffer-buffer-names-with-mark (mark)
1007 (let ((ibuffer-buffer-names-with-mark-result nil)) 1010 (let ((ibuffer-buffer-names-with-mark-result nil))
1008 (ibuffer-map-lines-nomodify 1011 (ibuffer-map-lines-nomodify
1009 #'(lambda (buf mk beg end) 1012 #'(lambda (buf mk)
1010 (when (char-equal mark mk) 1013 (when (char-equal mark mk)
1011 (push (buffer-name buf) 1014 (push (buffer-name buf)
1012 ibuffer-buffer-names-with-mark-result)))) 1015 ibuffer-buffer-names-with-mark-result))))
@@ -1021,15 +1024,15 @@ a new window in the current frame, splitting vertically."
1021(defun ibuffer-count-marked-lines (&optional all) 1024(defun ibuffer-count-marked-lines (&optional all)
1022 (if all 1025 (if all
1023 (ibuffer-map-lines-nomodify 1026 (ibuffer-map-lines-nomodify
1024 #'(lambda (buf mark beg end) 1027 #'(lambda (buf mark)
1025 (not (char-equal mark ? )))) 1028 (not (char-equal mark ? ))))
1026 (ibuffer-map-lines-nomodify 1029 (ibuffer-map-lines-nomodify
1027 #'(lambda (buf mark beg end) 1030 #'(lambda (buf mark)
1028 (char-equal mark ibuffer-marked-char))))) 1031 (char-equal mark ibuffer-marked-char)))))
1029 1032
1030(defsubst ibuffer-count-deletion-lines () 1033(defsubst ibuffer-count-deletion-lines ()
1031 (ibuffer-map-lines-nomodify 1034 (ibuffer-map-lines-nomodify
1032 #'(lambda (buf mark beg end) 1035 #'(lambda (buf mark)
1033 (char-equal mark ibuffer-deletion-char)))) 1036 (char-equal mark ibuffer-deletion-char))))
1034 1037
1035(defsubst ibuffer-map-deletion-lines (func) 1038(defsubst ibuffer-map-deletion-lines (func)
@@ -1095,17 +1098,17 @@ a new window in the current frame, splitting vertically."
1095 (cond 1098 (cond
1096 ((char-equal mark ibuffer-marked-char) 1099 ((char-equal mark ibuffer-marked-char)
1097 (ibuffer-map-marked-lines 1100 (ibuffer-map-marked-lines
1098 #'(lambda (buf mark beg end) 1101 #'(lambda (buf mark)
1099 (ibuffer-set-mark-1 ? ) 1102 (ibuffer-set-mark-1 ? )
1100 t))) 1103 t)))
1101 ((char-equal mark ibuffer-deletion-char) 1104 ((char-equal mark ibuffer-deletion-char)
1102 (ibuffer-map-deletion-lines 1105 (ibuffer-map-deletion-lines
1103 #'(lambda (buf mark beg end) 1106 #'(lambda (buf mark)
1104 (ibuffer-set-mark-1 ? ) 1107 (ibuffer-set-mark-1 ? )
1105 t))) 1108 t)))
1106 (t 1109 (t
1107 (ibuffer-map-lines 1110 (ibuffer-map-lines
1108 #'(lambda (buf mark beg end) 1111 #'(lambda (buf mark)
1109 (when (not (char-equal mark ? )) 1112 (when (not (char-equal mark ? ))
1110 (ibuffer-set-mark-1 ? )) 1113 (ibuffer-set-mark-1 ? ))
1111 t))))) 1114 t)))))
@@ -1118,7 +1121,7 @@ become unmarked."
1118 (interactive) 1121 (interactive)
1119 (let ((count 1122 (let ((count
1120 (ibuffer-map-lines 1123 (ibuffer-map-lines
1121 #'(lambda (buf mark beg end) 1124 #'(lambda (buf mark)
1122 (cond ((eq mark ibuffer-marked-char) 1125 (cond ((eq mark ibuffer-marked-char)
1123 (ibuffer-set-mark-1 ? ) 1126 (ibuffer-set-mark-1 ? )
1124 nil) 1127 nil)
@@ -1596,9 +1599,9 @@ become unmarked."
1596 1599
1597(defun ibuffer-map-on-mark (mark func) 1600(defun ibuffer-map-on-mark (mark func)
1598 (ibuffer-map-lines 1601 (ibuffer-map-lines
1599 #'(lambda (buf mk beg end) 1602 #'(lambda (buf mk)
1600 (if (char-equal mark mk) 1603 (if (char-equal mark mk)
1601 (funcall func buf mark beg end) 1604 (funcall func buf mark)
1602 nil)))) 1605 nil))))
1603 1606
1604(defun ibuffer-map-lines (function &optional nomodify) 1607(defun ibuffer-map-lines (function &optional nomodify)
@@ -1608,51 +1611,54 @@ Don't set the ibuffer modification flag iff NOMODIFY is non-nil.
1608 FUNCTION is called with four arguments: the buffer object itself, the 1611 FUNCTION is called with four arguments: the buffer object itself, the
1609current mark symbol, and the beginning and ending line positions." 1612current mark symbol, and the beginning and ending line positions."
1610 (assert (eq major-mode 'ibuffer-mode)) 1613 (assert (eq major-mode 'ibuffer-mode))
1611 (let ((curline (count-lines (point-min) 1614 (let ((orig-target-line (count-lines (point-min)
1612 (line-beginning-position))) 1615 (line-beginning-position)))
1613 (deleted-lines-count 0) 1616 (target-buf-count 0)
1614 (ibuffer-map-lines-total 0) 1617 (ibuffer-map-lines-total 0)
1615 (ibuffer-map-lines-count 0)) 1618 (ibuffer-map-lines-count 0))
1616 (unwind-protect 1619 (unwind-protect
1617 (progn 1620 (progn
1618 (setq buffer-read-only nil) 1621 (setq buffer-read-only nil)
1619 (goto-char (point-min)) 1622 (goto-char (point-min))
1620 (while (and (get-text-property (point) 'ibuffer-title) 1623 (ibuffer-forward-line 0)
1621 (not (eobp))) 1624 (setq orig-target-line (1+ (- orig-target-line
1622 (forward-line 1)) 1625 (count-lines (point-min) (point))))
1623 (while (and (not (eobp)) 1626 target-buf-count orig-target-line)
1624 (not (get-text-property (point) 'ibuffer-summary))) 1627 (while (and (not (eobp))
1625 (let ((result 1628 (not (get-text-property (point) 'ibuffer-summary)))
1626 (if (buffer-live-p (ibuffer-current-buffer)) 1629 (let ((result
1627 (save-excursion 1630 (if (buffer-live-p (ibuffer-current-buffer))
1628 (funcall function 1631 (save-excursion
1629 (ibuffer-current-buffer) 1632 (funcall function
1630 (ibuffer-current-mark) 1633 (ibuffer-current-buffer)
1631 (line-beginning-position) 1634 (ibuffer-current-mark)))
1632 (1+ (line-end-position)))) 1635 ;; Kill the line if the buffer is dead
1633 ;; Kill the line if the buffer is dead 1636 'kill)))
1634 'kill))) 1637 ;; A given mapping function should return:
1635 ;; A given mapping function should return: 1638 ;; `nil' if it chose not to affect the buffer
1636 ;; `nil' if it chose not to affect the buffer 1639 ;; `kill' means the remove line from the buffer list
1637 ;; `kill' means the remove line from the buffer list 1640 ;; `t' otherwise
1638 ;; `t' otherwise 1641 (incf ibuffer-map-lines-total)
1639 (incf ibuffer-map-lines-total) 1642 (cond ((null result)
1640 (cond ((null result) 1643 (forward-line 1))
1641 (forward-line 1)) 1644 ((eq result 'kill)
1642 ((eq result 'kill) 1645 (delete-region (line-beginning-position)
1643 (delete-region (line-beginning-position) 1646 (1+ (line-end-position)))
1644 (1+ (line-end-position))) 1647 (incf ibuffer-map-lines-count)
1645 (incf deleted-lines-count) 1648 (when (< ibuffer-map-lines-total
1646 (incf ibuffer-map-lines-count)) 1649 orig-target-line)
1647 (t 1650 (decf target-buf-count)))
1648 (incf ibuffer-map-lines-count) 1651 (t
1649 (forward-line 1))))) 1652 (incf ibuffer-map-lines-count)
1650 ibuffer-map-lines-count) 1653 (forward-line 1)))))
1654 ibuffer-map-lines-count)
1651 (progn 1655 (progn
1652 (setq buffer-read-only t) 1656 (setq buffer-read-only t)
1653 (unless nomodify 1657 (unless nomodify
1654 (set-buffer-modified-p nil)) 1658 (set-buffer-modified-p nil))
1655 (goto-line (- (1+ curline) deleted-lines-count)))))) 1659 (goto-char (point-min))
1660 (ibuffer-forward-line 0)
1661 (ibuffer-forward-line (1- target-buf-count))))))
1656 1662
1657(defun ibuffer-get-marked-buffers () 1663(defun ibuffer-get-marked-buffers ()
1658 "Return a list of buffer objects currently marked." 1664 "Return a list of buffer objects currently marked."
@@ -1662,21 +1668,15 @@ current mark symbol, and the beginning and ending line positions."
1662 (car e))) 1668 (car e)))
1663 (ibuffer-current-state-list)))) 1669 (ibuffer-current-state-list))))
1664 1670
1665(defun ibuffer-current-state-list (&optional include-lines) 1671(defun ibuffer-current-state-list ()
1666 "Return a list like (BUF . MARK) of all buffers in an ibuffer. 1672 "Return a list like (BUF . MARK) of all buffers in an ibuffer."
1667If optional argument INCLUDE-LINES is non-nil, return a list like
1668 (BUF MARK BEGPOS)."
1669 (let ((ibuffer-current-state-list-tmp '())) 1673 (let ((ibuffer-current-state-list-tmp '()))
1670 ;; ah, if only we had closures. I bet this will mysteriously 1674 ;; ah, if only we had closures. I bet this will mysteriously
1671 ;; break later. Don't blame me. 1675 ;; break later. Don't blame me.
1672 (ibuffer-map-lines-nomodify 1676 (ibuffer-map-lines-nomodify
1673 (if include-lines 1677 #'(lambda (buf mark)
1674 #'(lambda (buf mark beg end) 1678 (when (buffer-live-p buf)
1675 (when (buffer-live-p buf) 1679 (push (cons buf mark) ibuffer-current-state-list-tmp))))
1676 (push (list buf mark beg) ibuffer-current-state-list-tmp)))
1677 #'(lambda (buf mark beg end)
1678 (when (buffer-live-p buf)
1679 (push (cons buf mark) ibuffer-current-state-list-tmp)))))
1680 (nreverse ibuffer-current-state-list-tmp))) 1680 (nreverse ibuffer-current-state-list-tmp)))
1681 1681
1682(defun ibuffer-current-buffers-with-marks (curbufs) 1682(defun ibuffer-current-buffers-with-marks (curbufs)
@@ -1867,6 +1867,7 @@ This does not show new buffers; use `ibuffer-update' for that.
1867 1867
1868If SILENT is non-`nil', do not generate progress messages." 1868If SILENT is non-`nil', do not generate progress messages."
1869 (interactive) 1869 (interactive)
1870 (ibuffer-forward-line 0)
1870 (unless silent 1871 (unless silent
1871 (message "Redisplaying current buffer list...")) 1872 (message "Redisplaying current buffer list..."))
1872 (let ((blist (ibuffer-current-state-list))) 1873 (let ((blist (ibuffer-current-state-list)))
@@ -1878,7 +1879,8 @@ If SILENT is non-`nil', do not generate progress messages."
1878 (ibuffer-insert-buffers-and-marks blist t) 1879 (ibuffer-insert-buffers-and-marks blist t)
1879 (ibuffer-update-mode-name) 1880 (ibuffer-update-mode-name)
1880 (unless silent 1881 (unless silent
1881 (message "Redisplaying current buffer list...done")))) 1882 (message "Redisplaying current buffer list...done"))
1883 (ibuffer-forward-line 0)))
1882 1884
1883(defun ibuffer-update (arg &optional silent) 1885(defun ibuffer-update (arg &optional silent)
1884 "Regenerate the list of all buffers. 1886 "Regenerate the list of all buffers.
@@ -1888,6 +1890,7 @@ iff arg ARG is non-nil.
1888 1890
1889Do not display messages if SILENT is non-nil." 1891Do not display messages if SILENT is non-nil."
1890 (interactive "P") 1892 (interactive "P")
1893 (ibuffer-forward-line 0)
1891 (let* ((bufs (buffer-list)) 1894 (let* ((bufs (buffer-list))
1892 (blist (ibuffer-filter-buffers 1895 (blist (ibuffer-filter-buffers
1893 (current-buffer) 1896 (current-buffer)