abingham / emacs-ycmd

Emacs client for ycmd, the code completion system.
MIT License
384 stars 46 forks source link

I was trying to set the server command making use of an environment variable, but its not working. #460

Closed justinjk007 closed 6 years ago

justinjk007 commented 6 years ago

Instead of hard-cording the location of the install path, I thought I would make an environment variable YCMD and then read from it like this

  (set 'ycmd-server-command '("python" "-u" (expand-file-name "ycmd" (getenv "YCMD"))))

evaluating (expand-file-name "ycmd" (getenv "YCMD")) returns "c:/Program Files/ycmd/ycmd" so I don;t know why this is not working.

The error I am getting is

File mode specification error: (wrong-type-argument stringp (expand-file-name ycmd (getenv YCMD)))
abingham commented 6 years ago

Try this:

(set 'ycmd-server-command `("python" "-u" ,(expand-file-name "ycmd" (getenv "YCMD"))))

Basically, what you're doing right now is putting the list (expand-file-name "ycmd" (getenv "YCMD")) inside ycmd-server-command without evaluating it. The "backtick quoting" lets you selectively evaluate elements of the list when building it. You can read more about it in the Emacs documentation.

If this works for you, please close this issue. Good luck!

justinjk007 commented 6 years ago

Yes this worked thank you very much. I tried this

(set 'ycmd-server-command `("python" "-u" (,expand-file-name "ycmd" (getenv "YCMD"))))

instead of

(set 'ycmd-server-command `("python" "-u" ,(expand-file-name "ycmd" (getenv "YCMD"))))

before which did not work.