diff options
| author | Alan Mackenzie | 2018-02-15 20:58:15 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2018-02-15 20:58:15 +0000 |
| commit | aead21d83ed073f179df856a93228202ff9baee0 (patch) | |
| tree | fc0a1735f4c7df95e3c6a4499ae09571cb3e3f83 | |
| parent | b61a87292671c917a4c6c1c146a016f5f544ae36 (diff) | |
| download | emacs-aead21d83ed073f179df856a93228202ff9baee0.tar.gz emacs-aead21d83ed073f179df856a93228202ff9baee0.zip | |
Document open-paren-in-column-0-is-defun-start being of less importance
* doc/emacs/programs.texi (Left Margin Paren): Update to reflect the recent
change in syntax.c, whereby a paren at column 0 is no longer taken as a
beginning of defun in moving backwards over comments.
| -rw-r--r-- | doc/emacs/programs.texi | 62 |
1 files changed, 14 insertions, 48 deletions
diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index 42891245451..d7041a0beb4 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi | |||
| @@ -151,56 +151,22 @@ Emacs we use it for all languages. | |||
| 151 | 151 | ||
| 152 | @cindex open-parenthesis in leftmost column | 152 | @cindex open-parenthesis in leftmost column |
| 153 | @cindex ( in leftmost column | 153 | @cindex ( in leftmost column |
| 154 | Many programming-language modes assume by default that any opening | 154 | Many programming-language modes have traditionally assumed that any |
| 155 | delimiter found at the left margin is the start of a top-level | 155 | opening parenthesis or brace found at the left margin is the start of |
| 156 | definition, or defun. Therefore, @strong{don't put an opening | 156 | a top-level definition, or defun. So, by default, commands which seek |
| 157 | delimiter at the left margin unless it should have that significance}. | 157 | the beginning of a defun accept such a delimiter as signifying that |
| 158 | For instance, never put an open-parenthesis at the left margin in a | 158 | position. |
| 159 | Lisp file unless it is the start of a top-level list. | ||
| 160 | |||
| 161 | The convention speeds up many Emacs operations, which would | ||
| 162 | otherwise have to scan back to the beginning of the buffer to analyze | ||
| 163 | the syntax of the code. | ||
| 164 | |||
| 165 | If you don't follow this convention, not only will you have trouble | ||
| 166 | when you explicitly use the commands for motion by defuns; other | ||
| 167 | features that use them will also give you trouble. This includes the | ||
| 168 | indentation commands (@pxref{Program Indent}) and Font Lock mode | ||
| 169 | (@pxref{Font Lock}). | ||
| 170 | |||
| 171 | The most likely problem case is when you want an opening delimiter | ||
| 172 | at the start of a line inside a string. To avoid trouble, put an | ||
| 173 | escape character (@samp{\}, in C and Emacs Lisp, @samp{/} in some | ||
| 174 | other Lisp dialects) before the opening delimiter. This will not | ||
| 175 | affect the contents of the string, but will prevent that opening | ||
| 176 | delimiter from starting a defun. Here's an example: | ||
| 177 | |||
| 178 | @example | ||
| 179 | (insert "Foo: | ||
| 180 | \(bar) | ||
| 181 | ") | ||
| 182 | @end example | ||
| 183 | |||
| 184 | To help you catch violations of this convention, Font Lock mode | ||
| 185 | highlights confusing opening delimiters (those that ought to be | ||
| 186 | quoted) in bold red. | ||
| 187 | 159 | ||
| 188 | @vindex open-paren-in-column-0-is-defun-start | 160 | @vindex open-paren-in-column-0-is-defun-start |
| 189 | If you need to override this convention, you can do so by setting | 161 | If you want to override this convention, you can do so by setting |
| 190 | the variable @code{open-paren-in-column-0-is-defun-start}. | 162 | the user option @code{open-paren-in-column-0-is-defun-start} to |
| 191 | If this user option is set to @code{t} (the default), opening | 163 | @code{nil}. If this option is set to @code{t} (the default), commands |
| 192 | parentheses or braces at column zero always start defuns. When it is | 164 | seeking the start of a defun will stop at opening parentheses or |
| 193 | @code{nil}, defuns are found by searching for parens or braces at the | 165 | braces at column zero. When it is @code{nil}, defuns are found by |
| 194 | outermost level. | 166 | searching for parens or braces at the outermost level. Since |
| 195 | 167 | low-level Emacs routines no longer depend on this convention, you | |
| 196 | Usually, you should leave this option at its default value of | 168 | usually won't need to change |
| 197 | @code{t}. If your buffer contains parentheses or braces in column | 169 | @code{open-paren-in-column-0-is-defun-start} from its default. |
| 198 | zero which don't start defuns, and it is somehow impractical to remove | ||
| 199 | these parentheses or braces, it might be helpful to set the option to | ||
| 200 | @code{nil}. Be aware that this might make scrolling and display in | ||
| 201 | large buffers quite sluggish. Furthermore, the parentheses and braces | ||
| 202 | must be correctly matched throughout the buffer for it to work | ||
| 203 | properly. | ||
| 204 | 170 | ||
| 205 | @node Moving by Defuns | 171 | @node Moving by Defuns |
| 206 | @subsection Moving by Defuns | 172 | @subsection Moving by Defuns |