Emacs: Fix go-buffer-in-gopath-p when buffer has no file

master
Pierre Neidhardt 2016-07-19 15:30:52 +05:30
parent 2b6594172e
commit 044a9bfc2d
1 changed files with 9 additions and 7 deletions

View File

@ -11,13 +11,15 @@
(setq compile-command compile-command-backup)))
(defun go-buffer-in-gopath-p ()
(let ((dir (expand-file-name (file-name-directory buffer-file-name))) (looping t) (gopath (getenv "GOPATH")))
(while (progn
(if (string= dir gopath)
(setq looping nil)
(setq dir (expand-file-name ".." dir)))
(and looping (not (string= dir "/")))))
(if (string= dir "/") nil t)))
(if (not buffer-file-name)
nil
(let ((dir (expand-file-name (file-name-directory buffer-file-name))) (looping t) (gopath (getenv "GOPATH")))
(while (progn
(if (string= dir gopath)
(setq looping nil)
(setq dir (expand-file-name ".." dir)))
(and looping (not (string= dir "/")))))
(if (string= dir "/") nil t))))
(add-hook
'godoc-mode-hook