1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-27 10:54:40 +00:00

(ibuffer-backward-line, ibuffer-forward-line)

(ibuffer-mark-interactive): Use `or' instead of `unless'.
(define-ibuffer-column name): Add summarizer.
(define-ibuffer-column size): Likewise.
(define-ibuffer-column filename): Likewise.
(define-ibuffer-column process): Likewise.  Change BODY's output too.
(define-ibuffer-column filename-and-process): Likewise, likewise.
(ibuffer): Remove local vars `already-in' and `need-update'.
This commit is contained in:
John Paul Wallington 2003-07-05 11:24:00 +00:00
parent 2bf1ab7496
commit 34a4faa04b
2 changed files with 91 additions and 31 deletions

View File

@ -1,3 +1,16 @@
2003-07-05 John Paul Wallington <jpw@gnu.org>
* ibuffer.el (ibuffer-backward-line, ibuffer-forward-line)
(ibuffer-mark-interactive): Use `or' instead of `unless'.
(define-ibuffer-column name): Add summarizer.
(define-ibuffer-column size): Likewise.
(define-ibuffer-column filename): Likewise.
(define-ibuffer-column process): Likewise. Change BODY's output too.
(define-ibuffer-column filename-and-process): Likewise, likewise.
(ibuffer): Remove local vars `already-in' and `need-update'.
* ibuf-ext.el: Don't require `derived' at compile-time.
2003-07-05 Kim F. Storm <storm@cua.dk> 2003-07-05 Kim F. Storm <storm@cua.dk>
* info.el: Disable paragraph refilling. * info.el: Disable paragraph refilling.

View File

@ -757,11 +757,13 @@ directory, like `default-directory'."
(define-key ibuffer-mode-groups-popup [kill-filter-group] (define-key ibuffer-mode-groups-popup [kill-filter-group]
'(menu-item "Kill filter group" '(menu-item "Kill filter group"
ibuffer-kill-line ibuffer-kill-line
:enable (and (featurep 'ibuf-ext) ibuffer-filter-groups))) :enable (and (featurep 'ibuf-ext)
ibuffer-filter-groups)))
(define-key ibuffer-mode-groups-popup [yank-filter-group] (define-key ibuffer-mode-groups-popup [yank-filter-group]
'(menu-item "Yank last killed filter group" '(menu-item "Yank last killed filter group"
ibuffer-yank ibuffer-yank
:enable (and (featurep 'ibuf-ext) ibuffer-filter-group-kill-ring))) :enable (and (featurep 'ibuf-ext)
ibuffer-filter-group-kill-ring)))
(defvar ibuffer-name-map (defvar ibuffer-name-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
@ -904,15 +906,15 @@ width and the longest string in LIST."
(defun ibuffer-backward-line (&optional arg skip-group-names) (defun ibuffer-backward-line (&optional arg skip-group-names)
"Move backwards ARG lines, wrapping around the list if necessary." "Move backwards ARG lines, wrapping around the list if necessary."
(interactive "P") (interactive "P")
(unless arg (or arg (setq arg 1))
(setq arg 1))
(beginning-of-line) (beginning-of-line)
(while (> arg 0) (while (> arg 0)
(forward-line -1) (forward-line -1)
(when (and ibuffer-movement-cycle (when (and ibuffer-movement-cycle
(or (get-text-property (point) 'ibuffer-title) (or (get-text-property (point) 'ibuffer-title)
(and skip-group-names (and skip-group-names
(get-text-property (point) 'ibuffer-filter-group-name)))) (get-text-property (point)
'ibuffer-filter-group-name))))
(goto-char (point-max)) (goto-char (point-max))
(beginning-of-line)) (beginning-of-line))
(ibuffer-skip-properties (append '(ibuffer-summary) (ibuffer-skip-properties (append '(ibuffer-summary)
@ -928,8 +930,7 @@ width and the longest string in LIST."
(defun ibuffer-forward-line (&optional arg skip-group-names) (defun ibuffer-forward-line (&optional arg skip-group-names)
"Move forward ARG lines, wrapping around the list if necessary." "Move forward ARG lines, wrapping around the list if necessary."
(interactive "P") (interactive "P")
(unless arg (or arg (setq arg 1))
(setq arg 1))
(beginning-of-line) (beginning-of-line)
(when (and ibuffer-movement-cycle (when (and ibuffer-movement-cycle
(or (eobp) (or (eobp)
@ -1266,8 +1267,7 @@ If point is on a group name, this function operates on that group."
(defun ibuffer-mark-interactive (arg mark movement) (defun ibuffer-mark-interactive (arg mark movement)
(assert (eq major-mode 'ibuffer-mode)) (assert (eq major-mode 'ibuffer-mode))
(unless arg (or arg (setq arg 1))
(setq arg 1))
(ibuffer-forward-line 0) (ibuffer-forward-line 0)
(ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name) (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name)
(progn (progn
@ -1391,7 +1391,7 @@ If point is on a group name, this function operates on that group."
(defun ibuffer-compile-make-format-form (strvar widthform alignment) (defun ibuffer-compile-make-format-form (strvar widthform alignment)
(let* ((left `(make-string tmp2 ? )) (let* ((left `(make-string tmp2 ? ))
(right `(make-string (- tmp1 tmp2) ? ))) (right `(make-string (- tmp1 tmp2) ? )))
`(progn `(progn
(setq tmp1 ,widthform (setq tmp1 ,widthform
tmp2 (/ tmp1 2)) tmp2 (/ tmp1 2))
@ -1602,7 +1602,7 @@ If point is on a group name, this function operates on that group."
(define-ibuffer-column read-only (:name "R" :inline t) (define-ibuffer-column read-only (:name "R" :inline t)
(if buffer-read-only (if buffer-read-only
"%" (string ibuffer-read-only-char)
" ")) " "))
(define-ibuffer-column modified (:name "M" :inline t) (define-ibuffer-column modified (:name "M" :inline t)
@ -1610,16 +1610,33 @@ If point is on a group name, this function operates on that group."
(string ibuffer-modified-char) (string ibuffer-modified-char)
" ")) " "))
(define-ibuffer-column name (:inline t (define-ibuffer-column name
:props (:inline t
('mouse-face 'highlight 'keymap ibuffer-name-map :props
'ibuffer-name-column t ('mouse-face 'highlight 'keymap ibuffer-name-map
'help-echo '(if tooltip-mode 'ibuffer-name-column t
"mouse-1: mark this buffer\nmouse-2: select this buffer\nmouse-3: operate on this buffer" 'help-echo '(if tooltip-mode
"mouse-1: mark buffer mouse-2: select buffer mouse-3: operate"))) "mouse-1: mark this buffer\nmouse-2: select this buffer\nmouse-3: operate on this buffer"
"mouse-1: mark buffer mouse-2: select buffer mouse-3: operate"))
:summarizer
(lambda (strings)
(let ((bufs (length strings)))
(cond ((zerop bufs) "No buffers")
((= 1 bufs) "1 buffer")
(t (format "%s buffers" bufs))))))
(propertize (buffer-name) 'font-lock-face (ibuffer-buffer-name-face buffer mark))) (propertize (buffer-name) 'font-lock-face (ibuffer-buffer-name-face buffer mark)))
(define-ibuffer-column size (:inline t) (define-ibuffer-column size
(:inline t
:summarizer
(lambda (column-strings)
(let ((total 0))
(dolist (string column-strings)
(setq total
;; like, ewww ...
(+ (float (string-to-int string))
total)))
(format "%.0f" total))))
(format "%s" (buffer-size))) (format "%s" (buffer-size)))
(define-ibuffer-column mode (:inline t (define-ibuffer-column mode (:inline t
@ -1629,12 +1646,24 @@ If point is on a group name, this function operates on that group."
'help-echo "mouse-2: filter by this mode")) 'help-echo "mouse-2: filter by this mode"))
(format "%s" mode-name)) (format "%s" mode-name))
(define-ibuffer-column process () (define-ibuffer-column process
(:summarizer
(lambda (strings)
(let ((total (length (delete "" strings))))
(cond ((zerop total) "No processes")
((= 1 total) "1 process")
(t (format "%d processes" total))))))
(ibuffer-aif (get-buffer-process buffer) (ibuffer-aif (get-buffer-process buffer)
(format "(%s %s)" it (process-status it)) (format "(%s %s)" it (process-status it))
"none")) ""))
(define-ibuffer-column filename () (define-ibuffer-column filename
(:summarizer
(lambda (strings)
(let ((total (length (delete "" strings))))
(cond ((zerop total) "No files")
((= 1 total) "1 file")
(t (format "%d files" total))))))
(let ((directory-abbrev-alist ibuffer-directory-abbrev-alist)) (let ((directory-abbrev-alist ibuffer-directory-abbrev-alist))
(abbreviate-file-name (abbreviate-file-name
(or buffer-file-name (or buffer-file-name
@ -1642,13 +1671,34 @@ If point is on a group name, this function operates on that group."
dired-directory) dired-directory)
"")))) ""))))
(define-ibuffer-column filename-and-process (:name "Filename/Process") (define-ibuffer-column filename-and-process
(:name "Filename/Process"
:summarizer
(lambda (strings)
(setq strings (delete "" strings))
(let ((procs 0)
(files 0))
(dolist (string strings)
(if (string-match "\\(\?:\\`(\[\[:ascii:\]\]\+)\\)" string)
(progn (setq procs (1+ procs))
(if (< (match-end 0) (length string))
(setq files (1+ files))))
(setq files (1+ files))))
(concat (cond ((zerop files) "No files")
((= 1 files) "1 file")
(t (format "%d files" files)))
", "
(cond ((zerop procs) "no processes")
((= 1 procs) "1 process")
(t (format "%d processes" procs)))))))
(let ((proc (get-buffer-process buffer)) (let ((proc (get-buffer-process buffer))
(filename (ibuffer-make-column-filename buffer mark))) (filename (ibuffer-make-column-filename buffer mark)))
(if proc (if proc
(concat (propertize (format "(%s %s) " proc (process-status proc)) (concat (propertize (format "(%s %s)" proc (process-status proc))
'font-lock-face 'italic) 'font-lock-face 'italic)
filename) (if (> (length filename) 0)
(format " %s" filename)
""))
filename))) filename)))
(defun ibuffer-format-column (str width alignment) (defun ibuffer-format-column (str width alignment)
@ -2182,9 +2232,7 @@ locally in this buffer."
(interactive "P") (interactive "P")
(when ibuffer-use-other-window (when ibuffer-use-other-window
(setq other-window-p t)) (setq other-window-p t))
(let* ((buf (get-buffer-create (or name "*Ibuffer*"))) (let ((buf (get-buffer-create (or name "*Ibuffer*"))))
(already-in (eq (current-buffer) buf))
(need-update nil))
(if other-window-p (if other-window-p
(funcall (if noselect #'(lambda (buf) (display-buffer buf t)) #'pop-to-buffer) buf) (funcall (if noselect #'(lambda (buf) (display-buffer buf t)) #'pop-to-buffer) buf)
(funcall (if noselect #'display-buffer #'switch-to-buffer) buf)) (funcall (if noselect #'display-buffer #'switch-to-buffer) buf))
@ -2193,9 +2241,8 @@ locally in this buffer."
;; We switch to the buffer's window in order to be able ;; We switch to the buffer's window in order to be able
;; to modify the value of point ;; to modify the value of point
(select-window (get-buffer-window buf)) (select-window (get-buffer-window buf))
(unless (eq major-mode 'ibuffer-mode) (or (eq major-mode 'ibuffer-mode)
(ibuffer-mode) (ibuffer-mode))
(setq need-update t))
(setq ibuffer-delete-window-on-quit other-window-p) (setq ibuffer-delete-window-on-quit other-window-p)
(when shrink (when shrink
(setq ibuffer-shrink-to-minimum-size shrink)) (setq ibuffer-shrink-to-minimum-size shrink))