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

Side by Side Diff: docs/emacs.md

Issue 1314513007: [Docs]: Update to match style guide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months 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
OLDNEW
1 # Emacs
2
3 [TOC]
4
1 ## Debugging 5 ## Debugging
2 6
3 LinuxDebugging has some emacs-specific debugging tips. 7 [Linux Debugging](linux_debugging.md) has some emacs-specific debugging tips.
4 8
5 9
6 ## Blink Style (WebKit) 10 ## Blink Style (WebKit)
7 11
8 Chrome and Blink/WebKit style differ. You can use [directory-local variables](h ttp://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html ) to make the tab key do the right thing. E.g., in `third_party/WebKit`, add a `.dir-locals.el` that contains 12 Chrome and Blink/WebKit style differ. You can use
13 [directory-local variables](http://www.gnu.org/software/emacs/manual/html_node/e macs/Directory-Variables.html)
14 to make the tab key do the right thing. E.g., in `third_party/WebKit`, add a
15 `.dir-locals.el` that contains
9 16
10 ``` 17 ```el
11 ((nil . ((indent-tabs-mode . nil) 18 ((nil . ((indent-tabs-mode . nil)
12 (c-basic-offset . 4) 19 (c-basic-offset . 4)
13 (fill-column . 120)))) 20 (fill-column . 120))))
14 ``` 21 ```
15 22
16 This turns off tabs, sets your indent to four spaces, and makes `M-q` wrap at 12 0 columns (WebKit doesn't define a wrap column, but there's a soft limit somewhe re in that area for comments. Some reviewers do enforce the no wrap limit, which Emacs can deal with gracefully; see below.) 23 This turns off tabs, sets your indent to four spaces, and makes `M-q` wrap at
24 120 columns (WebKit doesn't define a wrap column, but there's a soft limit
25 somewhere in that area for comments. Some reviewers do enforce the no wrap
26 limit, which Emacs can deal with gracefully; see below.)
17 27
18 Be sure to `echo .dir-locals.el >> .git/info/exclude` so `git clean` doesn't del ete your file. 28 Be sure to `echo .dir-locals.el >> .git/info/exclude` so `git clean` doesn't
29 delete your file.
19 30
20 It can be useful to set up a WebKit specific indent style. It's not too much dif ferent so it's easy to base off of the core Google style. Somewhere after you've loaded google.el (most likely in your .emacs file), add: 31 It can be useful to set up a WebKit specific indent style. It's not too much
32 different so it's easy to base off of the core Google style. Somewhere after
33 you've loaded google.el (most likely in your .emacs file), add:
21 34
22 ``` 35 ```el
23 (c-add-style "WebKit" '("Google" 36 (c-add-style "WebKit" '("Google"
24 (c-basic-offset . 4) 37 (c-basic-offset . 4)
25 (c-offsets-alist . ((innamespace . 0) 38 (c-offsets-alist . ((innamespace . 0)
26 (access-label . -) 39 (access-label . -)
27 (case-label . 0) 40 (case-label . 0)
28 (member-init-intro . +) 41 (member-init-intro . +)
29 (topmost-intro . 0) 42 (topmost-intro . 0)
30 (arglist-cont-nonempty . +))))) 43 (arglist-cont-nonempty . +)))))
31 ``` 44 ```
32 45
33 then you can add 46 then you can add
34 47
35 ``` 48 ```el
36 (c-mode . ((c-file-style . "WebKit"))) 49 (c-mode . ((c-file-style . "WebKit")))
37 (c++-mode . ((c-file-style . "WebKit")))) 50 (c++-mode . ((c-file-style . "WebKit"))))
38 ``` 51 ```
39 52
40 to the end of the .dir-locals.el file you created above. Note that this style ma y not yet be complete, but it covers the most common differences. 53 to the end of the .dir-locals.el file you created above. Note that this style
54 may not yet be complete, but it covers the most common differences.
41 55
42 Now that you have a WebKit specific style being applied, and assuming you have f ont locking and it's default jit locking turned on, you can also get Emacs 23 to wrap long lines more intelligently by adding the following to your .emacs file: 56 Now that you have a WebKit specific style being applied, and assuming you have
57 font locking and it's default jit locking turned on, you can also get Emacs 23
58 to wrap long lines more intelligently by adding the following to your .emacs
59 file:
43 60
44 ``` 61 ```el
45 ;; For dealing with WebKit long lines and word wrapping. 62 ;; For dealing with WebKit long lines and word wrapping.
46 (defun c-mode-adaptive-indent (beg end) 63 (defun c-mode-adaptive-indent (beg end)
47 "Set the wrap-prefix for the the region between BEG and END with adaptive fill ing." 64 "Set the wrap-prefix for the the region between BEG and END with adaptive fill ing."
48 (goto-char beg) 65 (goto-char beg)
49 (while 66 (while
50 (let ((lbp (line-beginning-position)) 67 (let ((lbp (line-beginning-position))
51 (lep (line-end-position))) 68 (lep (line-end-position)))
52 (put-text-property lbp lep 'wrap-prefix (concat (fill-context-prefix lbp lep) (make-string c-basic-offset ? ))) 69 (put-text-property lbp lep 'wrap-prefix (concat (fill-context-prefix lbp lep) (make-string c-basic-offset ? )))
53 (search-forward "\n" end t)))) 70 (search-forward "\n" end t))))
54 71
55 (define-minor-mode c-adaptive-wrap-mode 72 (define-minor-mode c-adaptive-wrap-mode
56 "Wrap the buffer text with adaptive filling for c-mode." 73 "Wrap the buffer text with adaptive filling for c-mode."
57 :lighter "" 74 :lighter ""
58 (save-excursion 75 (save-excursion
59 (save-restriction 76 (save-restriction
60 (widen) 77 (widen)
61 (let ((buffer-undo-list t) 78 (let ((buffer-undo-list t)
62 (inhibit-read-only t) 79 (inhibit-read-only t)
63 (mod (buffer-modified-p))) 80 (mod (buffer-modified-p)))
64 (if c-adaptive-wrap-mode 81 (if c-adaptive-wrap-mode
65 (jit-lock-register 'c-mode-adaptive-indent) 82 (jit-lock-register 'c-mode-adaptive-indent)
66 (jit-lock-unregister 'c-mode-adaptive-indent) 83 (jit-lock-unregister 'c-mode-adaptive-indent)
67 (remove-text-properties (point-min) (point-max) '(wrap-prefix pref))) 84 (remove-text-properties (point-min) (point-max) '(wrap-prefix pref)))
68 (restore-buffer-modified-p mod))))) 85 (restore-buffer-modified-p mod)))))
69 86
70 (defun c-adaptive-wrap-mode-for-webkit () 87 (defun c-adaptive-wrap-mode-for-webkit ()
71 "Turn on visual line mode and adaptive wrapping for WebKit source files." 88 "Turn on visual line mode and adaptive wrapping for WebKit source files."
72 (if (or (string-equal "webkit" c-indentation-style) 89 (if (or (string-equal "webkit" c-indentation-style)
73 (string-equal "WebKit" c-indentation-style)) 90 (string-equal "WebKit" c-indentation-style))
74 (progn 91 (progn
75 (visual-line-mode t) 92 (visual-line-mode t)
76 (c-adaptive-wrap-mode t)))) 93 (c-adaptive-wrap-mode t))))
77 94
78 (add-hook 'c-mode-common-hook 'c-adaptive-wrap-mode-for-webkit) 95 (add-hook 'c-mode-common-hook 'c-adaptive-wrap-mode-for-webkit)
79 (add-hook 'hack-local-variables-hook 'c-adaptive-wrap-mode-for-webkit) 96 (add-hook 'hack-local-variables-hook 'c-adaptive-wrap-mode-for-webkit)
80 ``` 97 ```
81 98
82 This turns on visual wrap mode for files using the WebKit c style, and sets up a hook to dynamically set the indent on the wrapped lines. It's not quite as inte lligent as it could be (e.g., what would the wrap be if there really were a newl ine there?), but it's very fast. It makes dealing with long code lines anywhere much more tolerable (not just in WebKit). 99 This turns on visual wrap mode for files using the WebKit c style, and sets up a
100 hook to dynamically set the indent on the wrapped lines. It's not quite as
101 intelligent as it could be (e.g., what would the wrap be if there really were a
102 newline there?), but it's very fast. It makes dealing with long code lines
103 anywhere much more tolerable (not just in WebKit).
83 104
84 ## Syntax-error Highlighting 105 ## Syntax-error Highlighting
85 NinjaBuild users get in-line highlighting of syntax errors using `flymake.el` on each buffer-save: 106
86 ``` 107 [Ninja](ninja_build.md) users get in-line highlighting of syntax errors using
87 (load-file "src/tools/emacs/flymake-chromium.el") 108 `flymake.el` on each buffer-save:
88 ``` 109
110
111 (load-file "src/tools/emacs/flymake-chromium.el")
112
89 113
90 ## [ycmd](https://github.com/Valloric/ycmd) (YouCompleteMe) + flycheck 114 ## [ycmd](https://github.com/Valloric/ycmd) (YouCompleteMe) + flycheck
91 115
92 [emacs-ycmd](https://github.com/abingham/emacs-ycmd) in combination with flychec k provides: 116 [emacs-ycmd](https://github.com/abingham/emacs-ycmd) in combination with
93 * advanced code completion 117 flycheck provides:
94 * syntax checking
95 * navigation to declarations and definitions (using `ycmd-goto`)
96 based on on-the fly processing using clang. A quick demo video showing code comp letion and flycheck highlighting a missing semicolon syntax error:
97 118
98 <a href='http://www.youtube.com/watch?feature=player_embedded&v=a0zMbm4jACk' tar get='_blank'><img src='http://img.youtube.com/vi/a0zMbm4jACk/0.jpg' width='696' height=250 /></a> 119 * advanced code completion
120 * syntax checking
121 * navigation to declarations and definitions (using `ycmd-goto`) based on
122 on-the-fly processing using clang. A quick demo video showing code
123 completion and flycheck highlighting a missing semicolon syntax error:
99 124
100 #### Requirements: 125 [![video preview][img]][video]
126
127 [img]: http://img.youtube.com/vi/a0zMbm4jACk/0.jpg
128 [video]: http://www.youtube.com/watch?feature=player_embedded&v=a0zMbm4jACk
129
130 ### Requirements:
nodir 2015/08/29 00:53:49 replace ":" with "\n"
Bons 2015/08/29 15:29:26 Done.
101 * Your build system is set up for building with clang or wrapper+clang 131 * Your build system is set up for building with clang or wrapper+clang
102 132
103 #### Setup 133 ### Setup
104 134
105 1. Clone, update external git repositories and build.sh ycmd from https://gith ub.com/Valloric/ycmd into a directory, e.g. `~/dev/ycmd` 135 1. Clone, update external git repositories and build.sh ycmd from
106 1. Test `ycmd` by running 136 https://github.com/Valloric/ycmd into a directory, e.g. `~/dev/ycmd`
107 > `~/dev/ycmd$ python ycmd/__main__.py` 137 1. Test `ycmd` by running `~/dev/ycmd$ python ycmd/__main__.py` You should see
138 `KeyError: 'hmac_secret'`
139 1. Install the following packages to emacs, for example from melpa:
140 * `ycmd`
141 * `company-ycmd`
142 * `flycheck-ycmd`
143 1. [More info on configuring emacs-ycmd](https://github.com/abingham/emacs-ycmd #quickstart)
144 1. Assuming your checkout of Chromium is in `~/dev/blink`, i.e. this is the
145 directory in which you find the `src`folder, create a symbolic link as
146 follows:
108 147
109 > You should see `KeyError: 'hmac_secret'` 148 ```shell
110 1. Install the following packages to emacs, for example from melpa: 149 cd ~/dev/blink
111 * `ycmd` 150 ln -s src/tools/vim/chromium.ycm_extra_conf.py .ycm_extra_conf.py
112 * `company-ycmd` 151 ```
113 * `flycheck-ycmd` 152
114 > [More info on configuring emacs-ycmd](https://github.com/abingham/emacs-ycmd#q uickstart) 153 1. Add something like the following to your `init.el`
115 1. Assuming your checkout of Chromium is in `~/dev/blink`, i.e. this is the di rectory in which you find the `src`folder, create a symbolic link as follows 154
116 > `cd ~/dev/blink; ln -s src/tools/vim/chromium.ycm_extra_conf.py .ycm_extra_con f.py` 155 ```el
117 1. Add something like the following to your `init.el`
118 ```
119 ;; ycmd 156 ;; ycmd
120 157
121 ;;; Googlers can replace a lot of this with (require 'google-ycmd). 158 ;;; Googlers can replace a lot of this with (require 'google-ycmd).
122 159
123 (require 'ycmd) 160 (require 'ycmd)
124 (require 'company-ycmd) 161 (require 'company-ycmd)
125 (require 'flycheck-ycmd) 162 (require 'flycheck-ycmd)
126 163
127 (company-ycmd-setup) 164 (company-ycmd-setup)
128 (flycheck-ycmd-setup) 165 (flycheck-ycmd-setup)
(...skipping 12 matching lines...) Expand all
141 ;; Edit according to where you have your Chromium/Blink checkout 178 ;; Edit according to where you have your Chromium/Blink checkout
142 (add-to-list 'ycmd-extra-conf-whitelist (substitute-in-file-name "$HOME/dev/blin k/.ycm_extra_conf.py")) 179 (add-to-list 'ycmd-extra-conf-whitelist (substitute-in-file-name "$HOME/dev/blin k/.ycm_extra_conf.py"))
143 180
144 ;; Show flycheck errors in idle-mode as well 181 ;; Show flycheck errors in idle-mode as well
145 (setq ycmd-parse-conditions '(save new-line mode-enabled idle-change)) 182 (setq ycmd-parse-conditions '(save new-line mode-enabled idle-change))
146 183
147 ;; Makes emacs-ycmd less verbose 184 ;; Makes emacs-ycmd less verbose
148 (setq url-show-status nil) 185 (setq url-show-status nil)
149 ``` 186 ```
150 187
151 #### Troubleshooting 188 ### Troubleshooting
152 189
153 * If no completions show up or emacs reports errors, you can check the `*ycmd- server*` buffer for errors. See the next bullet point for how to handle "OS Erro r: No such file or directory" 190 * If no completions show up or emacs reports errors, you can check the
154 * Launching emacs from an OS menu might result in a different environment so t hat `ycmd` does not find ninja. In that case, you can use a package like [exec-p ath from shell](https://github.com/purcell/exec-path-from-shell) and add the fol lowing to your `init.el`: 191 `*ycmd-server*` buffer for errors. See the next bullet point for how to
155 ``` 192 handle "OS Error: No such file or directory"
193 * Launching emacs from an OS menu might result in a different environment so
194 that `ycmd` does not find ninja. In that case, you can use a package like
195 [exec-path from shell](https://github.com/purcell/exec-path-from-shell) and
196 add the following to your `init.el`:
197
198 ```el
156 (require 'exec-path-from-shell) 199 (require 'exec-path-from-shell)
157 (when (memq window-system '(mac ns x)) 200 (when (memq window-system '(mac ns x))
158 (exec-path-from-shell-initialize)) 201 (exec-path-from-shell-initialize))
159 ``` 202 ```
160 203
161
162 ## ff-get-other-file 204 ## ff-get-other-file
163 205
164 There's a builtin function called `ff-get-other-file` which will get the "other file" based on file extension. I have this bound to C-o in c-mode (`(local-set-k ey "\C-o" 'ff-get-other-file)`). While "other file" is per-mode defined, in c-li ke languages it means jumping between the header and the source file. So I switc h back and forth between the header and the source with C-o. If we had separate include/ and src/ directories, this would be a pain to setup, but this might jus t work out of the box for you. See the documentation for the variable `cc-other- file-alist` for more information. 206 There's a builtin function called `ff-get-other-file` which will get the "other
207 file" based on file extension. I have this bound to C-o in c-mode
208 (`(local-set-key "\C-o" 'ff-get-other-file)`). While "other file" is per-mode
209 defined, in c-like languages it means jumping between the header and the source
210 file. So I switch back and forth between the header and the source with C-o. If
211 we had separate include/ and src/ directories, this would be a pain to setup,
212 but this might just work out of the box for you. See the documentation for the
213 variable `cc-other-file-alist` for more information.
165 214
166 One drawback of ff-get-other-file is that it will always switch to a matching bu ffer, even if the other file is in a different directory, so if you have A.cc,A. h,A.cc(2) then ff-get-other-file will switch to A.h from A.cc(2) rather than loa d A.h(2) from the appropriate directory. If you prefer something (C specific) th at always finds, try this: 215 One drawback of ff-get-other-file is that it will always switch to a matching
167 ``` 216 buffer, even if the other file is in a different directory, so if you have
217 A.cc,A.h,A.cc(2) then ff-get-other-file will switch to A.h from A.cc(2) rather
218 than load A.h(2) from the appropriate directory. If you prefer something (C
219 specific) that always finds, try this:
220
221 ```el
168 (defun cc-other-file() 222 (defun cc-other-file()
169 "Toggles source/header file" 223 "Toggles source/header file"
170 (interactive) 224 (interactive)
171 (let ((buf (current-buffer)) 225 (let ((buf (current-buffer))
172 (name (file-name-sans-extension (buffer-file-name))) 226 (name (file-name-sans-extension (buffer-file-name)))
173 » (other-extens 227 » (other-extens
174 » (cadr (assoc (concat "\\." 228 » (cadr (assoc (concat "\\."
175 (file-name-extension (buffer-file-name)) 229 (file-name-extension (buffer-file-name))
176 » » » "\\'") 230 » » » "\\'")
177 cc-other-file-alist)))) 231 cc-other-file-alist))))
178 (dolist (e other-extens) 232 (dolist (e other-extens)
179 (if (let ((f (concat name e))) 233 (if (let ((f (concat name e)))
180 (and (file-exists-p f) (find-file f))) 234 (and (file-exists-p f) (find-file f)))
181 (return))) 235 (return)))
182 ) 236 )
183 ) 237 )
184 ``` 238 ```
185 _Note: if you know an easy way to change the ff-get-other-file behavior, please replace this hack with that solution! - stevenjb@chromium.org_ 239
240 _Note: if you know an easy way to change the ff-get-other-file behavior, please
241 replace this hack with that solution! - stevenjb@chromium.org_
186 242
187 ## Use Google's C++ style! 243 ## Use Google's C++ style!
188 244
189 We have an emacs module, [google-c-style.el](http://google-styleguide.googlecode .com/svn/trunk/google-c-style.el), which adds c-mode formatting. 245 We have an emacs module,
190 Then add to your .emacs: 246 [google-c-style.el](http://google-styleguide.googlecode.com/svn/trunk/google-c-s tyle.el),
247 which adds c-mode formatting. Then add to your .emacs:
248
249 ```el
250 (load "/<path/to/chromium>/src/buildtools/clang_format/script/clang-format.el")
251 (add-hook 'c-mode-common-hook
252 (function (lambda () (local-set-key (kbd "TAB") 'clang-format-region))))
191 ``` 253 ```
192 (load "/<path/to/chromium>/src/buildtools/clang_format/script/clang-format.e l") 254
193 (add-hook 'c-mode-common-hook (function (lambda () (local-set-key (kbd "TAB" ) 'clang-format-region)))) 255 Now, you can use the
194 ```
195 Now, you can use the
196 256
197 &lt;Tab&gt; 257 &lt;Tab&gt;
198 258
199 key to format the current line (even a long line) or region. 259 key to format the current line (even a long line) or region.
200 260
201 ### Highlight long lines 261 ## Highlight long lines
202 262
203 One nice way to highlight long lines and other style issues: 263 One nice way to highlight long lines and other style issues:
204 ``` 264
265 ```el
205 (require 'whitespace) 266 (require 'whitespace)
206 (setq whitespace-style '(face indentation trailing empty lines-tail)) 267 (setq whitespace-style '(face indentation trailing empty lines-tail))
207 (setq whitespace-line-column nil) 268 (setq whitespace-line-column nil)
208 (set-face-attribute 'whitespace-line nil 269 (set-face-attribute 'whitespace-line nil
209 :background "purple" 270 :background "purple"
210 :foreground "white" 271 :foreground "white"
211 :weight 'bold) 272 :weight 'bold)
212 (global-whitespace-mode 1) 273 (global-whitespace-mode 1)
213 ``` 274 ```
214 275
215 276 Note: You might need to grab the latest version of
216 Note: You might need to grab the latest version of [whitespace.el](http://www.em acswiki.org/emacs-en/download/whitespace.el). 277 [whitespace.el](http://www.emacswiki.org/emacs-en/download/whitespace.el).
217 278
218 ## gyp 279 ## gyp
219 280
220 ### `gyp` style 281 ### `gyp` style
221 There is a gyp mode that provides basic indentation and font-lock (syntax highli ghting) support. The mode derives from python.el (bundled with newer emacsen). 282 There is a gyp mode that provides basic indentation and font-lock (syntax
283 highlighting) support. The mode derives from python.el (bundled with newer
284 emacsen).
222 285
223 You can find it in tools/gyp/tools/emacs or at http://code.google.com/p/gyp/sour ce/browse/trunk/tools/emacs/ 286 You can find it in /src/tools/gyp/tools/emacs
224 287
225 See the README file there for installation instructions. 288 See the README file there for installation instructions.
226 289
227 **Important**: the mode is only tested with `python.el` (bundled with newer emac sen), not with `python-mode.el` (outdated and less maintained these days). 290 **Important**: the mode is only tested with `python.el` (bundled with newer
291 emacsen), not with `python-mode.el` (outdated and less maintained these days).
228 292
229 ### deep nesting 293 ### deep nesting
230 294
231 A couple of helpers that show a summary of where you are; the first by tracing t he indentation hierarchy upwards, the second by only showing `#if`s and `#else`s that are relevant to the current line: 295 A couple of helpers that show a summary of where you are; the first by tracing
296 the indentation hierarchy upwards, the second by only showing `#if`s and
297 `#else`s that are relevant to the current line:
232 298
233 ```el 299 ```el
234
235 (defun ami-summarize-indentation-at-point () 300 (defun ami-summarize-indentation-at-point ()
236 "Echo a summary of how one gets from the left-most column to 301 "Echo a summary of how one gets from the left-most column to
237 POINT in terms of indentation changes." 302 POINT in terms of indentation changes."
238 (interactive) 303 (interactive)
239 (save-excursion 304 (save-excursion
240 (let ((cur-indent most-positive-fixnum) 305 (let ((cur-indent most-positive-fixnum)
241 (trace '())) 306 (trace '()))
242 (while (not (bobp)) 307 (while (not (bobp))
243 (let ((current-line (buffer-substring (line-beginning-position) 308 (let ((current-line (buffer-substring (line-beginning-position)
244 (line-end-position)))) 309 (line-end-position))))
245 (when (and (not (string-match "^\\s-*$" current-line)) 310 (when (and (not (string-match "^\\s-*$" current-line))
246 (< (current-indentation) cur-indent)) 311 (< (current-indentation) cur-indent))
247 (setq cur-indent (current-indentation)) 312 (setq cur-indent (current-indentation))
248 (setq trace (cons current-line trace)) 313 (setq trace (cons current-line trace))
249 (if (or (string-match "^\\s-*}" current-line) 314 (if (or (string-match "^\\s-*}" current-line)
250 (string-match "^\\s-*else " current-line) 315 (string-match "^\\s-*else " current-line)
251 (string-match "^\\s-*elif " current-line)) 316 (string-match "^\\s-*elif " current-line))
252 (setq cur-indent (1+ cur-indent))))) 317 (setq cur-indent (1+ cur-indent)))))
253 (forward-line -1)) 318 (forward-line -1))
254 (message "%s" (mapconcat 'identity trace "\n"))))) 319 (message "%s" (mapconcat 'identity trace "\n")))))
255 320
256 (require 'cl) 321 (require 'cl)
257 (defun ami-summarize-preprocessor-branches-at-point () 322 (defun ami-summarize-preprocessor-branches-at-point ()
258 "Summarize the C preprocessor branches needed to get to point." 323 "Summarize the C preprocessor branches needed to get to point."
259 (interactive) 324 (interactive)
260 (flet ((current-line-text () 325 (flet ((current-line-text ()
261 (buffer-substring (line-beginning-position) (line-end-position)))) 326 (buffer-substring (line-beginning-position) (line-end-position))))
262 (save-excursion 327 (save-excursion
263 (let ((eol (or (end-of-line) (point))) 328 (let ((eol (or (end-of-line) (point)))
264 deactivate-mark directives-stack) 329 deactivate-mark directives-stack)
265 (goto-char (point-min)) 330 (goto-char (point-min))
266 (while (re-search-forward "^#\\(if\\|else\\|endif\\)" eol t) 331 (while (re-search-forward "^#\\(if\\|else\\|endif\\)" eol t)
267 (if (or (string-prefix-p "#if" (match-string 0)) 332 (if (or (string-prefix-p "#if" (match-string 0))
268 (string-prefix-p "#else" (match-string 0))) 333 (string-prefix-p "#else" (match-string 0)))
269 (push (current-line-text) directives-stack) 334 (push (current-line-text) directives-stack)
270 (if (string-prefix-p "#endif" (match-string 0)) 335 (if (string-prefix-p "#endif" (match-string 0))
271 (while (string-prefix-p "#else" (pop directives-stack)) t)))) 336 (while (string-prefix-p "#else" (pop directives-stack)) t))))
272 (message "%s" (mapconcat 'identity (reverse directives-stack) "\n")))))) 337 (message "%s" (mapconcat 'identity (reverse directives-stack) "\n")))) ))
273 ``` 338 ```
274 339
275 ## find-things-fast 340 ## find-things-fast
276 341
277 erg wrote a suite of tools that do common operations from the root of your repos itory, called [Find Things Fast](https://github.com/eglaysher/find-things-fast). It contains ido completion over `git ls-files` (or the svn find equivalent) and `grepsource` that only git greps files with extensions we care about (or the eq uivalent the `find | xargs grep` statement in non-git repos.) 342 erg wrote a suite of tools that do common operations from the root of your
343 repository, called
344 [Find Things Fast](https://github.com/eglaysher/find-things-fast). It contains
345 ido completion over `git ls-files` (or the svn find equivalent) and `grepsource`
346 that only git greps files with extensions we care about (or the equivalent the
347 `find | xargs grep` statement in non-git repos.)
278 348
279 ## vc-mode and find-file performance 349 ## vc-mode and find-file performance
280 350
281 When you first open a file under git control, vc mode kicks in and does a high l evel stat of your git repo. For huge repos, especially WebKit and Chromium, this makes opening a file take literally seconds. This snippet disables VC git for c hrome directories: 351 When you first open a file under git control, vc mode kicks in and does a high
352 level stat of your git repo. For huge repos, especially WebKit and Chromium,
353 this makes opening a file take literally seconds. This snippet disables VC git
354 for chrome directories:
282 355
283 ``` 356 ```el
284
285 ; Turn off VC git for chrome 357 ; Turn off VC git for chrome
286 (when (locate-library "vc") 358 (when (locate-library "vc")
287 (defadvice vc-registered (around nochrome-vc-registered (file)) 359 (defadvice vc-registered (around nochrome-vc-registered (file))
288 (message (format "nochrome-vc-registered %s" file)) 360 (message (format "nochrome-vc-registered %s" file))
289 (if (string-match ".*chrome/src.*" file) 361 (if (string-match ".*chrome/src.*" file)
290 (progn 362 (progn
291 (message (format "Skipping VC mode for %s" % file)) 363 (message (format "Skipping VC mode for %s" % file))
292 (setq ad-return-value nil) 364 (setq ad-return-value nil)
293 ) 365 )
294 ad-do-it) 366 ad-do-it)
295 ) 367 )
296 (ad-activate 'vc-registered) 368 (ad-activate 'vc-registered)
297 ) 369 )
298 ``` 370 ```
299 371
300 ## git tools 372 ## git tools
301 We're collecting Chrome-specific tools under `tools/emacs`. See the files there for details.
302 373
303 * `trybot.el`: import Windows trybot output into a `compilation-mode` buffer. 374 We're collecting Chrome-specific tools under `tools/emacs`. See the files there
375 for details.
376
377 * `trybot.el`: import Windows trybot output into a `compilation-mode` buffer.
304 378
305 ## ERC for IRC 379 ## ERC for IRC
306 380
307 See ErcIrc. 381 See [ErcIrc][erc_irc.md].
308 382
309 ## TODO 383 ## TODO
310 384
311 * Figure out how to make `M-x compile` default to `cd /path/to/chrome/root; ma ke -r chrome`. 385 * Figure out how to make `M-x compile` default to
386 `cd /path/to/chrome/root; make -r chrome`.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698