Function: ede-auto-add-to-target
ede-auto-add-to-target is a byte-compiled function defined in
ede.el.gz.
Signature
(ede-auto-add-to-target)
Documentation
Look for a target that wants to own the current file.
Follow the preference set with ede-auto-add-method and get the list
of objects with the ede-want-file-p method.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/ede.el.gz
(defun ede-auto-add-to-target ()
"Look for a target that wants to own the current file.
Follow the preference set with `ede-auto-add-method' and get the list
of objects with the `ede-want-file-p' method."
(if ede-object (error "ede-object already defined for %s" (buffer-name)))
(if (or (eq ede-auto-add-method 'never)
(ede-ignore-file (buffer-file-name)))
nil
(let (desires)
(dolist (want (oref (ede-current-project) targets));Find all the objects.
(if (ede-want-file-p want (buffer-file-name))
(push want desires)))
(if desires
(cond ((or (eq ede-auto-add-method 'ask)
(and (eq ede-auto-add-method 'multi-ask)
(< 1 (length desires))))
(let* ((al (append
;; some defaults
'(("none" . nil)
("new target" . new))
;; If we are in an unparented subdir,
;; offer new a subproject
(if (ede-directory-project-p default-directory)
()
'(("create subproject" . project)))
;; Here are the existing objects we want.
(object-assoc-list 'name desires)))
(case-fold-search t)
(ans (completing-read
(format "Add %s to target: " (buffer-file-name))
al nil t)))
(setq ans (assoc ans al))
(cond ((eieio-object-p (cdr ans))
(ede-add-file (cdr ans)))
((eq (cdr ans) 'new)
(ede-new-target))
(t nil))))
((or (eq ede-auto-add-method 'always)
(and (eq ede-auto-add-method 'multi-ask)
(= 1 (length desires))))
(ede-add-file (car desires)))
(t nil))))))