我调用 git get the toplevel dir (根据 Is there a way to get the git root directory in a command? )。
(let ((tmpbuffer (get-buffer-create (make-temp-name "git"))))
(call-process "git" nil tmpbuffer nil "rev-parse" "--show-toplevel")
(with-current-buffer tmpbuffer
(with-output-to-string
(princ (buffer-string))
(kill-buffer))))
但是返回的字符串中有一个尾随换行符。我不知道如何摆脱它。