Function: org-id-find-id-in-file

org-id-find-id-in-file is a byte-compiled function defined in org-id.el.gz.

Signature

(org-id-find-id-in-file ID FILE &optional MARKERP)

Documentation

Return the position of the entry ID in FILE.

If that files does not exist, or if it does not contain this ID, return nil.

The position is returned as a cons cell (file-name . position). With optional argument MARKERP, return the position as a new marker.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-id.el.gz
(defun org-id-find-id-in-file (id file &optional markerp)
  "Return the position of the entry ID in FILE.

If that files does not exist, or if it does not contain this ID,
return nil.

The position is returned as a cons cell (file-name . position).  With
optional argument MARKERP, return the position as a new marker."
  (cond
   ((not file) nil)
   ((not (file-exists-p file)) nil)
   (t
    (let* ((visiting (find-buffer-visiting file))
	   (buffer (or visiting (find-file-noselect file))))
      (unwind-protect
	  (with-current-buffer buffer
	    (let ((pos (org-find-entry-with-id id)))
	      (cond
	       ((null pos) nil)
	       (markerp (move-marker (make-marker) pos buffer))
	       (t (cons file pos)))))
	;; Remove opened buffer in the process.
	(unless (or visiting markerp) (kill-buffer buffer)))))))