+ (while (and (consp alist)
+ (or (not (consp (car alist)))
+ (equal (cdr (car alist)) value)))
+ (setq alist (cdr alist)))
+ (if (consp alist)
+ (let ((prev alist)
+ (tail (cdr alist)))
+ (while (consp tail)
+ (if (and (consp (car tail))
+ (equal (cdr (car tail)) value))
+ ;; `(setcdr CELL NEWCDR)' returns NEWCDR.
+ (setq tail (setcdr prev (cdr tail)))
+ (setq prev (cdr prev)
+ tail (cdr tail))))))
+ alist)
+
+;; XEmacs 19.13 and later: (remrassq VALUE ALIST)
+(defun-maybe remrassq (value alist)
+ "Delete by side effect any elements of ALIST whose cdr is `eq' to VALUE.
+The modified ALIST is returned. If the first member of ALIST has a car
+that is `eq' to VALUE, there is no way to remove it by side effect;
+therefore, write `(setq foo (remrassq value foo))' to be sure of changing
+the value of `foo'."
+ (while (and (consp alist)
+ (or (not (consp (car alist)))
+ (eq (cdr (car alist)) value)))
+ (setq alist (cdr alist)))
+ (if (consp alist)
+ (let ((prev alist)
+ (tail (cdr alist)))
+ (while (consp tail)
+ (if (and (consp (car tail))
+ (eq (cdr (car tail)) value))
+ ;; `(setcdr CELL NEWCDR)' returns NEWCDR.
+ (setq tail (setcdr prev (cdr tail)))
+ (setq prev (cdr prev)
+ tail (cdr tail))))))
+ alist)