comparison lisp/ibuf-ext.el @ 48778:d414c281a629

* ibuffer.el (ibuffer-mode): If `show-paren-mode' is enabled, disable it buffer-locally. (ibuffer-mouse-popup-menu): Use `=' instead of `eq' to compare `eventpt' and point. * ibuf-ext.el (ibuffer-remove-duplicates): New function. (ibuffer-set-filter-groups-by-mode): Use it instead of `delete-duplicates' so we don't require cl library at runtime. (ibuffer-insert-filter-group-before): Don't use `position' so we don't require cl library at runtime. * chistory.el (command-history-mode): Add interactive spec. Improve doc string.
author John Paul Wallington <jpw@pobox.com>
date Mon, 09 Dec 2002 23:46:12 +0000
parents c09fefd016a4
children 798119a6859c
comparison
equal deleted inserted replaced
48777:f6687dde33ff 48778:d414c281a629
44 "Delete all entries in ALIST that have a key equal to KEY." 44 "Delete all entries in ALIST that have a key equal to KEY."
45 (let (entry) 45 (let (entry)
46 (while (setq entry (assoc key alist)) 46 (while (setq entry (assoc key alist))
47 (setq alist (delete entry alist))) 47 (setq alist (delete entry alist)))
48 alist)) 48 alist))
49
50 ;; borrowed from Gnus
51 (defun ibuffer-remove-duplicates (list)
52 "Return a copy of LIST with duplicate elements removed."
53 (let ((new nil)
54 (tail list))
55 (while tail
56 (or (member (car tail) new)
57 (setq new (cons (car tail) new)))
58 (setq tail (cdr tail)))
59 (nreverse new)))
49 60
50 (defun ibuffer-split-list (ibuffer-split-list-fn ibuffer-split-list-elts) 61 (defun ibuffer-split-list (ibuffer-split-list-fn ibuffer-split-list-elts)
51 (let ((hip-crowd nil) 62 (let ((hip-crowd nil)
52 (lamers nil)) 63 (lamers nil))
53 (dolist (ibuffer-split-list-elt ibuffer-split-list-elts) 64 (dolist (ibuffer-split-list-elt ibuffer-split-list-elts)
543 (interactive) 554 (interactive)
544 (setq ibuffer-filter-groups 555 (setq ibuffer-filter-groups
545 (mapcar (lambda (mode) 556 (mapcar (lambda (mode)
546 (cons (format "%s" mode) `((mode . ,mode)))) 557 (cons (format "%s" mode) `((mode . ,mode))))
547 (let ((modes 558 (let ((modes
548 (delete-duplicates 559 (ibuffer-remove-duplicates
549 (mapcar (lambda (buf) (with-current-buffer buf major-mode)) 560 (mapcar (lambda (buf) (with-current-buffer buf major-mode))
550 (buffer-list))))) 561 (buffer-list)))))
551 (if ibuffer-view-ibuffer 562 (if ibuffer-view-ibuffer
552 modes 563 modes
553 (delq 'ibuffer-mode modes))))) 564 (delq 'ibuffer-mode modes)))))
644 (ibuffer-kill-filter-group it)) 655 (ibuffer-kill-filter-group it))
645 (funcall (if (interactive-p) #'call-interactively #'funcall) 656 (funcall (if (interactive-p) #'call-interactively #'funcall)
646 #'kill-line arg))) 657 #'kill-line arg)))
647 658
648 (defun ibuffer-insert-filter-group-before (newgroup group) 659 (defun ibuffer-insert-filter-group-before (newgroup group)
649 (let ((pos (or (position group (mapcar #'car ibuffer-filter-groups) 660 (let* ((found nil)
650 :test #'equal) 661 (pos (let ((groups (mapcar #'car ibuffer-filter-groups))
651 (length ibuffer-filter-groups)))) 662 (res 0))
652 (cond ((<= pos 0) 663 (while groups
664 (if (equal (car groups) group)
665 (setq found t
666 groups nil)
667 (incf res)
668 (setq groups (cdr groups))))
669 res)))
670 (cond ((not found)
671 (setq ibuffer-filter-groups (nconc ibuffer-filter-groups (list newgroup))))
672 ((zerop pos)
653 (push newgroup ibuffer-filter-groups)) 673 (push newgroup ibuffer-filter-groups))
654 ((= pos (length ibuffer-filter-groups))
655 (setq ibuffer-filter-groups (nconc ibuffer-filter-groups (list newgroup))))
656 (t 674 (t
657 (let ((cell (nthcdr pos ibuffer-filter-groups))) 675 (let ((cell (nthcdr pos ibuffer-filter-groups)))
658 (setf (cdr cell) (cons (car cell) (cdr cell))) 676 (setf (cdr cell) (cons (car cell) (cdr cell)))
659 (setf (car cell) newgroup)))))) 677 (setf (car cell) newgroup))))))
660 678