Fork me on GitHub
#spacemacs
<
2018-06-14
>
Bravi11:06:09

is it possible to locate the project dir inside a defun? i.e.

(defun dotspacemacs/test-fn ()
  "hello"
  (interactive)
  (let* ((project-dir (locate-dominating-file
                       (or (buffer-file-name) default-directory)
                       "src")))
    (message "The result is: %s" project-dir)))
I have this function, and I want to run a shell command inside this function, but from the project root directory

Bravi11:06:49

I have bound this function to SPC A a. so if I open up a file that’s under src/something/ dir, and if I do SPC A a from there, I want to somehow navigate to the root dir, where src folder is and run a shell command there

Pak11:06:02

the projectile-run-shell or projectile-run-shell-command-in-root commands maybe?

Bravi11:06:30

hmm it says wrong number of arguments

Bravi11:06:42

(defun dotspacemacs/test-fn ()
  (interactive)
  (let* ((result (projectile-run-shell "pwd")))
    (message "The result is: %s" result)))

Bravi11:06:52

I tried both commands

Bravi11:06:15

I’m trying to find examples of usage

Pak13:06:20

well, you call it interactively, M-x or <spc<spc> and then the name of the command