Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: tools/emacs/flymake-chromium.el

Issue 8872013: Fix flymake to work with my Emacs, and hopefully not break others. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ;; Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 ;; Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 ;; Use of this source code is governed by a BSD-style license that can be 2 ;; Use of this source code is governed by a BSD-style license that can be
3 ;; found in the LICENSE file. 3 ;; found in the LICENSE file.
4 4
5 ;; Set up flymake for use with chromium code. Uses ninja (since none of the 5 ;; Set up flymake for use with chromium code. Uses ninja (since none of the
6 ;; other chromium build systems have latency that allows interactive use). 6 ;; other chromium build systems have latency that allows interactive use).
7 ;; 7 ;;
8 ;; Requires a modern emacs (GNU Emacs >= 23) and that gyp has already generated 8 ;; Requires a modern emacs (GNU Emacs >= 23) and that gyp has already generated
9 ;; the build.ninja file(s). See defcustoms below for settable knobs. 9 ;; the build.ninja file(s). See defcustoms below for settable knobs.
10 10
11 11
12 (require 'flymake) 12 (require 'flymake)
13 13
14 (defcustom cr-flymake-ninja-build-file "out/Debug/build.ninja" 14 (defcustom cr-flymake-ninja-build-file "out/Debug/build.ninja"
15 "Relative path from chromium's src/ directory to the 15 "Relative path from chromium's src/ directory to the
16 build.ninja file to use.") 16 build.ninja file to use.")
17 17
18 (defcustom cr-flymake-ninja-executable "ninja" 18 (defcustom cr-flymake-ninja-executable "ninja"
19 "Ninja executable location; either in $PATH or explicitly given.") 19 "Ninja executable location; either in $PATH or explicitly given.")
20 20
21 (defun cr-flymake-absbufferpath ()
22 "Return the absolute path to the current buffer, or nil if the
23 current buffer has no path."
24 (when buffer-file-truename
25 (expand-file-name buffer-file-truename)))
26
21 (defun cr-flymake-chromium-src () 27 (defun cr-flymake-chromium-src ()
22 "Return chromium's src/ directory, or nil on failure." 28 "Return chromium's src/ directory, or nil on failure."
23 (locate-dominating-file buffer-file-truename cr-flymake-ninja-build-file)) 29 (let ((srcdir (locate-dominating-file
30 (cr-flymake-absbufferpath) cr-flymake-ninja-build-file)))
31 (when srcdir (expand-file-name srcdir))))
24 32
25 (defun cr-flymake-string-prefix-p (prefix str) 33 (defun cr-flymake-string-prefix-p (prefix str)
26 "Return non-nil if PREFIX is a prefix of STR (23.2 has string-prefix-p but 34 "Return non-nil if PREFIX is a prefix of STR (23.2 has string-prefix-p but
27 that's case insensitive and also 23.1 doesn't have it)." 35 that's case insensitive and also 23.1 doesn't have it)."
28 (string= prefix (substring str 0 (length prefix)))) 36 (string= prefix (substring str 0 (length prefix))))
29 37
30 (defun cr-flymake-current-file-name () 38 (defun cr-flymake-current-file-name ()
31 "Return the relative path from chromium's src/ directory to the 39 "Return the relative path from chromium's src/ directory to the
32 file backing the current buffer or nil if it doesn't look like 40 file backing the current buffer or nil if it doesn't look like
33 we're under chromium/src/." 41 we're under chromium/src/."
34 (when (and (cr-flymake-chromium-src) 42 (when (and (cr-flymake-chromium-src)
35 (cr-flymake-string-prefix-p 43 (cr-flymake-string-prefix-p
36 (cr-flymake-chromium-src) buffer-file-truename)) 44 (cr-flymake-chromium-src) (cr-flymake-absbufferpath)))
37 (substring buffer-file-truename (length (cr-flymake-chromium-src))))) 45 (substring (cr-flymake-absbufferpath) (length (cr-flymake-chromium-src)))))
38 46
39 (defun cr-flymake-from-build-to-src-root () 47 (defun cr-flymake-from-build-to-src-root ()
40 "Return a path fragment for getting from the build.ninja file to src/." 48 "Return a path fragment for getting from the build.ninja file to src/."
41 (replace-regexp-in-string 49 (replace-regexp-in-string
42 "[^/]+" ".." 50 "[^/]+" ".."
43 (substring 51 (substring
44 (file-name-directory 52 (file-name-directory
45 (file-truename (or (and (cr-flymake-string-prefix-p 53 (file-truename (or (and (cr-flymake-string-prefix-p
46 "/" cr-flymake-ninja-build-file) 54 "/" cr-flymake-ninja-build-file)
47 cr-flymake-ninja-build-file) 55 cr-flymake-ninja-build-file)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 (kill-local-variable 'flymake-allowed-file-name-masks)))) 113 (kill-local-variable 'flymake-allowed-file-name-masks))))
106 114
107 (add-hook 'find-file-hook 'cr-flymake-find-file 'append) 115 (add-hook 'find-file-hook 'cr-flymake-find-file 'append)
108 (add-hook 'after-save-hook 'cr-flymake-kick-off-check-after-save) 116 (add-hook 'after-save-hook 'cr-flymake-kick-off-check-after-save)
109 117
110 ;; Show flymake infrastructure ERRORs in hopes of fixing them. Set to 3 for 118 ;; Show flymake infrastructure ERRORs in hopes of fixing them. Set to 3 for
111 ;; DEBUG-level output from flymake.el. 119 ;; DEBUG-level output from flymake.el.
112 (setq flymake-log-level 0) 120 (setq flymake-log-level 0)
113 121
114 (provide 'flymake-chromium) 122 (provide 'flymake-chromium)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698