0

emacs.md: Drop section covering Blink's coding style.

Blink's code no longer follows WebKit's style so the entire section about
different line limits and indentation can be removed.

R=drott

Change-Id: If06ba22acf674d0746d698ce9b7516e6f688d739
Reviewed-on: https://chromium-review.googlesource.com/845621
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Reviewed-by: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526449}
This commit is contained in:
Raphael Kubo da Costa
2017-12-28 15:17:23 +01:00
committed by Commit Bot
parent 585988dafb
commit 6a62346537

@ -6,102 +6,6 @@
[Linux Debugging](linux_debugging.md) has some Emacs-specific debugging tips.
## Blink Style (WebKit)
Chrome and Blink/WebKit style differ. You can use
[directory-local variables](http://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
```el
((nil . ((indent-tabs-mode . nil)
(c-basic-offset . 4)
(fill-column . 120))))
```
This turns off tabs, sets your indent to four spaces, and makes `M-q` wrap at
120 columns (WebKit doesn't define a wrap column, but there's a soft limit
somewhere in that area for comments. Some reviewers do enforce the no wrap
limit, which Emacs can deal with gracefully; see below.)
Be sure to `echo .dir-locals.el >> .git/info/exclude` so `git clean` doesn't
delete your file.
It can be useful to set up a WebKit specific indent style. It's not too much
different 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:
```el
(c-add-style "WebKit" '("Google"
(c-basic-offset . 4)
(c-offsets-alist . ((innamespace . 0)
(access-label . -)
(case-label . 0)
(member-init-intro . +)
(topmost-intro . 0)
(arglist-cont-nonempty . +)))))
```
then you can add
```el
(c-mode . ((c-file-style . "WebKit")))
(c++-mode . ((c-file-style . "WebKit"))))
```
to the end of the .dir-locals.el file you created above. Note that this style
may not yet be complete, but it covers the most common differences.
Now that you have a WebKit specific style being applied, and assuming you have
font 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:
```el
;; For dealing with WebKit long lines and word wrapping.
(defun c-mode-adaptive-indent (beg end)
"Set the wrap-prefix for the region between BEG and END with adaptive filling."
(goto-char beg)
(while
(let ((lbp (line-beginning-position))
(lep (line-end-position)))
(put-text-property lbp lep 'wrap-prefix (concat (fill-context-prefix lbp lep) (make-string c-basic-offset ? )))
(search-forward "\n" end t))))
(define-minor-mode c-adaptive-wrap-mode
"Wrap the buffer text with adaptive filling for c-mode."
:lighter ""
(save-excursion
(save-restriction
(widen)
(let ((buffer-undo-list t)
(inhibit-read-only t)
(mod (buffer-modified-p)))
(if c-adaptive-wrap-mode
(jit-lock-register 'c-mode-adaptive-indent)
(jit-lock-unregister 'c-mode-adaptive-indent)
(remove-text-properties (point-min) (point-max) '(wrap-prefix pref)))
(restore-buffer-modified-p mod)))))
(defun c-adaptive-wrap-mode-for-webkit ()
"Turn on visual line mode and adaptive wrapping for WebKit source files."
(if (or (string-equal "webkit" c-indentation-style)
(string-equal "WebKit" c-indentation-style))
(progn
(visual-line-mode t)
(c-adaptive-wrap-mode t))))
(add-hook 'c-mode-common-hook 'c-adaptive-wrap-mode-for-webkit)
(add-hook 'hack-local-variables-hook 'c-adaptive-wrap-mode-for-webkit)
```
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
intelligent as it could be (e.g., what would the wrap be if there really were a
newline there?), but it's very fast. It makes dealing with long code lines
anywhere much more tolerable (not just in WebKit).
## Syntax-error Highlighting
[Ninja](ninja_build.md) users get in-line highlighting of syntax errors using