aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLute Kamstra2005-04-21 21:18:29 +0000
committerLute Kamstra2005-04-21 21:18:29 +0000
commit2c7b5da17afabf02cd58a5530dcfbdb4459ed62c (patch)
tree4ea7c59676a6c6974990dbd262e47afa163f2d6b
parente157359534fc85143de54bc8d48a9313515ee3b0 (diff)
downloademacs-2c7b5da17afabf02cd58a5530dcfbdb4459ed62c.tar.gz
emacs-2c7b5da17afabf02cd58a5530dcfbdb4459ed62c.zip
(assq-delete-all): New implementation that is linear, not quadratic.
Suggested by David Kastrup <dak@gnu.org>. (rassq-delete-all): New function.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/subr.el33
2 files changed, 30 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d4a67928ab7..e242caae13f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12005-04-21 Lute Kamstra <lute@gnu.org> 12005-04-21 Lute Kamstra <lute@gnu.org>
2 2
3 * subr.el (assq-delete-all): New implementation that is linear,
4 not quadratic. Suggested by David Kastrup <dak@gnu.org>.
5 (rassq-delete-all): New function.
6
3 * menu-bar.el (menu-bar-options-save, menu-bar-showhide-menu): Add 7 * menu-bar.el (menu-bar-options-save, menu-bar-showhide-menu): Add
4 size-indication-mode. 8 size-indication-mode.
5 9
diff --git a/lisp/subr.el b/lisp/subr.el
index 7330f1d6ddf..f791faffd91 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2376,15 +2376,34 @@ macros."
2376 (eq (car-safe object) 'lambda))) 2376 (eq (car-safe object) 'lambda)))
2377 2377
2378(defun assq-delete-all (key alist) 2378(defun assq-delete-all (key alist)
2379 "Delete from ALIST all elements whose car is KEY. 2379 "Delete from ALIST all elements whose car is `eq' to KEY.
2380Return the modified alist. 2380Return the modified alist.
2381Elements of ALIST that are not conses are ignored." 2381Elements of ALIST that are not conses are ignored."
2382 (let ((tail alist)) 2382 (while (and (consp (car alist))
2383 (while tail 2383 (eq (car (car alist)) key))
2384 (if (and (consp (car tail)) (eq (car (car tail)) key)) 2384 (setq alist (cdr alist)))
2385 (setq alist (delq (car tail) alist))) 2385 (let ((tail alist) tail-cdr)
2386 (setq tail (cdr tail))) 2386 (while (setq tail-cdr (cdr tail))
2387 alist)) 2387 (if (and (consp (car tail-cdr))
2388 (eq (car (car tail-cdr)) key))
2389 (setcdr tail (cdr tail-cdr))
2390 (setq tail tail-cdr))))
2391 alist)
2392
2393(defun rassq-delete-all (value alist)
2394 "Delete from ALIST all elements whose cdr is `eq' to VALUE.
2395Return the modified alist.
2396Elements of ALIST that are not conses are ignored."
2397 (while (and (consp (car alist))
2398 (eq (cdr (car alist)) value))
2399 (setq alist (cdr alist)))
2400 (let ((tail alist) tail-cdr)
2401 (while (setq tail-cdr (cdr tail))
2402 (if (and (consp (car tail-cdr))
2403 (eq (cdr (car tail-cdr)) value))
2404 (setcdr tail (cdr tail-cdr))
2405 (setq tail tail-cdr))))
2406 alist)
2388 2407
2389(defun make-temp-file (prefix &optional dir-flag suffix) 2408(defun make-temp-file (prefix &optional dir-flag suffix)
2390 "Create a temporary file. 2409 "Create a temporary file.