* elmo-imap4.el (elmo-folder-open): Fix.
[elisp/wanderlust.git] / elmo / elmo-util.el
index 6fe0b61..90cc8be 100644 (file)
@@ -335,17 +335,12 @@ Return value is a cons cell of (STRUCTURE . REST)"
   lst)
 
 (defun elmo-list-insert (list element after)
-  "Insert an ELEMENT to the LIST, just after AFTER."
-  (let ((li list)
-       (curn 0)
-       p pn)
-    (while li
-      (if (eq (car li) after)
-         (setq p li pn curn li nil)
-       (incf curn))
-      (setq li (cdr li)))
-    (if pn
-       (setcdr (nthcdr pn list) (cons element (cdr p)))
+  (let* ((match (memq after list))
+        (rest (and match (cdr (memq after list)))))
+    (if match
+       (progn
+         (setcdr match (list element))
+         (nconc list rest))
       (nconc list (list element)))))
 
 (defun elmo-string-partial-p (string)