Question

I'm trying to get root of project from ede object. I read interessting discussion about this issue. I used an example from David which seems to work perfectly except it works only for buffers with opened files from project. I would like to have this returning root of project from dired mode or from any other mode I decide. Is it possible? Here's code I used:

(defun my-get-project-root ()
(interactive)
(let ((proj ede-object-root-project))
  (if proj
  (message "Project root: %s"
           (ede-project-root-directory proj))
    (message "No project for this buffer."))))

So when running this for instance from dired mode I get: "No project for this buffer" message.

I'm aware it can be achieved with some other tools but I'm already using cedet for my projects management.

Was it helpful?

Solution

you can use something like:

(defun get-project-root-dir ()
  (interactive)
  (let* ((fname (or (buffer-file-name (current-buffer)) default-directory))
     (current-dir (file-name-directory fname))
         (prj (ede-current-project current-dir)))
    (when prj
      (ede-project-root-directory prj))))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top