From d2bd8a826b779e007b3b3c57279090f11d7e1c41 Mon Sep 17 00:00:00 2001 From: "joi@chromium.org" Date: Thu, 8 Dec 2011 21:33:43 +0000 Subject: Fix for configs where the Chrome checkout is under user's home directory (in which case buffer-file-truename returns a path starting with ~). BUG=none Review URL: http://codereview.chromium.org/8872013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113664 0039d316-1c4b-4281-b951-d872f2087c98 --- tools/emacs/flymake-chromium.el | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/emacs/flymake-chromium.el b/tools/emacs/flymake-chromium.el index 070fada..8adb0db 100644 --- a/tools/emacs/flymake-chromium.el +++ b/tools/emacs/flymake-chromium.el @@ -18,9 +18,17 @@ (defcustom cr-flymake-ninja-executable "ninja" "Ninja executable location; either in $PATH or explicitly given.") +(defun cr-flymake-absbufferpath () + "Return the absolute path to the current buffer, or nil if the + current buffer has no path." + (when buffer-file-truename + (expand-file-name buffer-file-truename))) + (defun cr-flymake-chromium-src () "Return chromium's src/ directory, or nil on failure." - (locate-dominating-file buffer-file-truename cr-flymake-ninja-build-file)) + (let ((srcdir (locate-dominating-file + (cr-flymake-absbufferpath) cr-flymake-ninja-build-file))) + (when srcdir (expand-file-name srcdir)))) (defun cr-flymake-string-prefix-p (prefix str) "Return non-nil if PREFIX is a prefix of STR (23.2 has string-prefix-p but @@ -33,8 +41,8 @@ we're under chromium/src/." (when (and (cr-flymake-chromium-src) (cr-flymake-string-prefix-p - (cr-flymake-chromium-src) buffer-file-truename)) - (substring buffer-file-truename (length (cr-flymake-chromium-src))))) + (cr-flymake-chromium-src) (cr-flymake-absbufferpath))) + (substring (cr-flymake-absbufferpath) (length (cr-flymake-chromium-src))))) (defun cr-flymake-from-build-to-src-root () "Return a path fragment for getting from the build.ninja file to src/." -- cgit v1.1