diff 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
line wrap: on
line diff
--- a/lisp/ibuf-ext.el	Mon Dec 09 20:24:40 2002 +0000
+++ b/lisp/ibuf-ext.el	Mon Dec 09 23:46:12 2002 +0000
@@ -47,6 +47,17 @@
       (setq alist (delete entry alist)))
     alist))
 
+;; borrowed from Gnus
+(defun ibuffer-remove-duplicates (list)
+  "Return a copy of LIST with duplicate elements removed."
+  (let ((new nil)
+	(tail list))
+    (while tail
+      (or (member (car tail) new)
+	  (setq new (cons (car tail) new)))
+      (setq tail (cdr tail)))
+    (nreverse new)))
+
 (defun ibuffer-split-list (ibuffer-split-list-fn ibuffer-split-list-elts)
   (let ((hip-crowd nil)
 	(lamers nil))
@@ -545,7 +556,7 @@
         (mapcar (lambda (mode)
                   (cons (format "%s" mode) `((mode . ,mode))))
                 (let ((modes
-                       (delete-duplicates
+                       (ibuffer-remove-duplicates
                         (mapcar (lambda (buf) (with-current-buffer buf major-mode))
                                 (buffer-list)))))
                   (if ibuffer-view-ibuffer
@@ -646,13 +657,20 @@
 	       #'kill-line arg)))
 
 (defun ibuffer-insert-filter-group-before (newgroup group)
-  (let ((pos (or (position group (mapcar #'car ibuffer-filter-groups)
-			   :test #'equal)
-		 (length ibuffer-filter-groups))))
-    (cond ((<= pos 0)
+  (let* ((found nil)
+	 (pos (let ((groups (mapcar #'car ibuffer-filter-groups))
+		    (res 0))
+		(while groups
+		  (if (equal (car groups) group)
+		      (setq found t
+			    groups nil)
+		    (incf res)
+		    (setq groups (cdr groups))))
+		res)))
+    (cond ((not found)
+	   (setq ibuffer-filter-groups (nconc ibuffer-filter-groups (list newgroup))))
+	  ((zerop pos)
 	   (push newgroup ibuffer-filter-groups))
-	  ((= pos (length ibuffer-filter-groups))
-	   (setq ibuffer-filter-groups (nconc ibuffer-filter-groups (list newgroup))))
 	  (t
 	   (let ((cell (nthcdr pos ibuffer-filter-groups)))
 	     (setf (cdr cell) (cons (car cell) (cdr cell)))