Function: woman-topic-all-completions-merge

woman-topic-all-completions-merge is a byte-compiled function defined in woman.el.gz.

Signature

(woman-topic-all-completions-merge ALIST)

Documentation

Merge the alist ALIST so that the keys are unique.

Also make each path-info component into a list.
(Note that this function changes the value of ALIST.)

Source Code

;; Defined in /usr/src/emacs/lisp/woman.el.gz
(defun woman-topic-all-completions-merge (alist)
  "Merge the alist ALIST so that the keys are unique.
Also make each path-info component into a list.
\(Note that this function changes the value of ALIST.)"
  ;; Replaces unreadably "optimized" O(n^2) implementation.
  ;; Instead we use sorting to merge stuff efficiently.  -- dak
  (let (newalist)
    ;; Sort list into reverse order
    (setq alist (sort alist (lambda(x y) (string< (car y) (car x)))))
    ;; merge duplicate keys.
    (if (> woman-cache-level 1)
	(dolist (elt alist)
	  (if (equal (car elt) (caar newalist))
	      (unless (member (cdr elt) (cdar newalist))
		(setcdr (car newalist) (cons (cdr elt)
					     (cdar newalist))))
	    (setcdr elt (list (cdr elt)))
	    (push elt newalist)))
      ;; woman-cache-level = 1 => elements are single-element lists ...
      (dolist (elt alist)
	(unless (equal (car elt) (caar newalist))
	  (push elt newalist))))
    newalist))