Function: org-olpath-completing-read

org-olpath-completing-read is a byte-compiled function defined in org-refile.el.gz.

Signature

(org-olpath-completing-read PROMPT COLLECTION &rest ARGS)

Documentation

Read an outline path like a file name.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-refile.el.gz
(defun org-olpath-completing-read (prompt collection &rest args)
  "Read an outline path like a file name."
  (let ((thetable collection))
    (apply #'completing-read
	   prompt
	   (lambda (string predicate &optional flag)
	     (cond
	      ((eq flag nil) (try-completion string thetable))
	      ((eq flag t)
	       (let ((l (length string)))
		 (mapcar (lambda (x)
			   (let ((r (substring x l))
				 (f (if (string-match " ([^)]*)$" x)
					(match-string 0 x)
				      "")))
			     (if (string-match "/" r)
				 (concat string (substring r 0 (match-end 0)) f)
			       x)))
			 (all-completions string thetable predicate))))
              ((eq (car-safe flag) 'boundaries)
               ;; See `completion-file-name-table'.
               (let ((start (or (and (string-match "/" string)
                                     (match-beginning 0))
                                (length string)))
                     (end (and (string-match "/" (cdr flag))
                               (match-beginning 0))))
                 `(boundaries ,start . ,end)))
	      ;; Exact match?
	      ((eq flag 'lambda) (assoc string thetable))))
	   args)))