diff options
| author | Glenn Morris | 2012-12-09 18:00:42 -0800 |
|---|---|---|
| committer | Glenn Morris | 2012-12-09 18:00:42 -0800 |
| commit | 265c2fbf11cb8bf9b805df63ecb9508631f08e35 (patch) | |
| tree | 808684294d7ec600f5300e0a5d5f868740096f7b /doc/lispref | |
| parent | 5f460827dd14fbfae26ac8451cedd4446817d1ec (diff) | |
| parent | f433306af510e86a614e9f9f082b6d2d5f56a968 (diff) | |
| download | emacs-265c2fbf11cb8bf9b805df63ecb9508631f08e35.tar.gz emacs-265c2fbf11cb8bf9b805df63ecb9508631f08e35.zip | |
Merge from emacs-24; up to 2012-11-26T19:56:14Z!monnier@iro.umontreal.ca
Diffstat (limited to 'doc/lispref')
| -rw-r--r-- | doc/lispref/ChangeLog | 69 | ||||
| -rw-r--r-- | doc/lispref/control.texi | 104 | ||||
| -rw-r--r-- | doc/lispref/customize.texi | 4 |
3 files changed, 144 insertions, 33 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 7238d958d8a..05716cd77b3 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-12-10 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * control.texi (Pattern maching case statement): New node. | ||
| 4 | |||
| 5 | * customize.texi (Variable Definitions): Mention the default :group | ||
| 6 | for defcustoms (bug#13093). | ||
| 7 | |||
| 1 | 2012-12-09 Glenn Morris <rgm@gnu.org> | 8 | 2012-12-09 Glenn Morris <rgm@gnu.org> |
| 2 | 9 | ||
| 3 | * customize.texi (Variable Definitions): Mention eval-defun | 10 | * customize.texi (Variable Definitions): Mention eval-defun |
| @@ -27,7 +34,7 @@ | |||
| 27 | * display.texi (Defining Faces): | 34 | * display.texi (Defining Faces): |
| 28 | * sequences.texi (Char-Tables): Fix xref. | 35 | * sequences.texi (Char-Tables): Fix xref. |
| 29 | 36 | ||
| 30 | * keymaps.texi (Key Sequences): kbd is now a function. | 37 | * keymaps.texi (Key Sequences): `kbd' is now a function. |
| 31 | 38 | ||
| 32 | * commands.texi (Using Interactive): Fix index entry. | 39 | * commands.texi (Using Interactive): Fix index entry. |
| 33 | 40 | ||
| @@ -47,16 +54,14 @@ | |||
| 47 | (Windows and Frames): Fix example. Move description of | 54 | (Windows and Frames): Fix example. Move description of |
| 48 | window-in-direction here. | 55 | window-in-direction here. |
| 49 | (Recombining Windows): Fix example. | 56 | (Recombining Windows): Fix example. |
| 50 | (Buffers and Windows): Fix description of | 57 | (Buffers and Windows): Fix description of replace-buffer-in-windows. |
| 51 | replace-buffer-in-windows. | ||
| 52 | (Switching Buffers): Reword. | 58 | (Switching Buffers): Reword. |
| 53 | (Display Action Functions): Minor adjustments. | 59 | (Display Action Functions): Minor adjustments. |
| 54 | (Choosing Window Options): Minor fixes. | 60 | (Choosing Window Options): Minor fixes. |
| 55 | (Window History): Minor rewording. | 61 | (Window History): Minor rewording. |
| 56 | (Dedicated Windows): Correct and reword part describing how | 62 | (Dedicated Windows): Correct and reword part describing how |
| 57 | dedicatedness affects functions removing buffers or windows. | 63 | dedicatedness affects functions removing buffers or windows. |
| 58 | * buffers.texi (The Buffer List): Fix description of | 64 | * buffers.texi (The Buffer List): Fix description of bury-buffer. |
| 59 | bury-buffer. | ||
| 60 | 65 | ||
| 61 | 2012-11-24 Chong Yidong <cyd@gnu.org> | 66 | 2012-11-24 Chong Yidong <cyd@gnu.org> |
| 62 | 67 | ||
| @@ -115,8 +120,8 @@ | |||
| 115 | 120 | ||
| 116 | * windows.texi (Choosing Window): Rewrite description of | 121 | * windows.texi (Choosing Window): Rewrite description of |
| 117 | display-buffer-alist (Bug#12167). | 122 | display-buffer-alist (Bug#12167). |
| 118 | (Display Action Functions): Mention inhibit-switch-frame. Fix | 123 | (Display Action Functions): Mention inhibit-switch-frame. |
| 119 | description of display-buffer-below-selected. Reorder actions. | 124 | Fix description of display-buffer-below-selected. Reorder actions. |
| 120 | Add example (Bug#12848). | 125 | Add example (Bug#12848). |
| 121 | 126 | ||
| 122 | 2012-11-16 Glenn Morris <rgm@gnu.org> | 127 | 2012-11-16 Glenn Morris <rgm@gnu.org> |
| @@ -215,11 +220,11 @@ | |||
| 215 | switch-to-buffer-preserve-window-point. | 220 | switch-to-buffer-preserve-window-point. |
| 216 | (Display Action Functions): Document window-height and | 221 | (Display Action Functions): Document window-height and |
| 217 | window-width alist entries. | 222 | window-width alist entries. |
| 218 | (Display Action Functions): Document | 223 | (Display Action Functions): |
| 219 | display-buffer-below-selected and | 224 | Document display-buffer-below-selected and |
| 220 | display-buffer-in-previous-window. | 225 | display-buffer-in-previous-window. |
| 221 | (Quitting Windows): Document quit-restore-window. Rewrite | 226 | (Quitting Windows): Document quit-restore-window. |
| 222 | section. | 227 | Rewrite section. |
| 223 | (Window Configurations): In window-state-get mention that | 228 | (Window Configurations): In window-state-get mention that |
| 224 | argument window must be valid. | 229 | argument window must be valid. |
| 225 | (Window Parameters): Document quit-restore window parameter | 230 | (Window Parameters): Document quit-restore window parameter |
| @@ -319,8 +324,8 @@ | |||
| 319 | * minibuf.texi (Text from Minibuffer): Document read-regexp | 324 | * minibuf.texi (Text from Minibuffer): Document read-regexp |
| 320 | changes. | 325 | changes. |
| 321 | 326 | ||
| 322 | * nonascii.texi (Selecting a Representation): Document | 327 | * nonascii.texi (Selecting a Representation): |
| 323 | set-buffer-multibyte changes. | 328 | Document set-buffer-multibyte changes. |
| 324 | 329 | ||
| 325 | * keymaps.texi (Toolkit Differences): Node deleted. | 330 | * keymaps.texi (Toolkit Differences): Node deleted. |
| 326 | (Easy Menu): New node. | 331 | (Easy Menu): New node. |
| @@ -1092,8 +1097,8 @@ | |||
| 1092 | 1097 | ||
| 1093 | 2012-04-12 Jari Aalto <jari.aalto@cante.net> | 1098 | 2012-04-12 Jari Aalto <jari.aalto@cante.net> |
| 1094 | 1099 | ||
| 1095 | * processes.texi (Synchronous Processes): Mention | 1100 | * processes.texi (Synchronous Processes): |
| 1096 | `default-directory' (bug#7515). | 1101 | Mention `default-directory' (bug#7515). |
| 1097 | 1102 | ||
| 1098 | 2012-04-09 Chong Yidong <cyd@gnu.org> | 1103 | 2012-04-09 Chong Yidong <cyd@gnu.org> |
| 1099 | 1104 | ||
| @@ -1116,8 +1121,8 @@ | |||
| 1116 | 1121 | ||
| 1117 | * minibuf.texi (Programmed Completion): Remove obsolete variable | 1122 | * minibuf.texi (Programmed Completion): Remove obsolete variable |
| 1118 | completion-annotate-function. | 1123 | completion-annotate-function. |
| 1119 | (Completion Variables): Rename from Completion Styles. Document | 1124 | (Completion Variables): Rename from Completion Styles. |
| 1120 | completion-extra-properties. Document completion-styles-alist | 1125 | Document completion-extra-properties. Document completion-styles-alist |
| 1121 | change. | 1126 | change. |
| 1122 | (Reading File Names): minibuffer-local-filename-must-match-map is | 1127 | (Reading File Names): minibuffer-local-filename-must-match-map is |
| 1123 | not used anymore. | 1128 | not used anymore. |
| @@ -1252,8 +1257,8 @@ | |||
| 1252 | Minor clarifications. | 1257 | Minor clarifications. |
| 1253 | (Defining Faces): Copyedits. Update face example. | 1258 | (Defining Faces): Copyedits. Update face example. |
| 1254 | (Attribute Functions): Mark set-face-foreground etc as commands. | 1259 | (Attribute Functions): Mark set-face-foreground etc as commands. |
| 1255 | (Face Remapping): Mention text-scale-adjust. Clarify | 1260 | (Face Remapping): Mention text-scale-adjust. |
| 1256 | face-remapping-alist and related docs. | 1261 | Clarify face-remapping-alist and related docs. |
| 1257 | (Face Functions): Don't document make-face or copy-face. | 1262 | (Face Functions): Don't document make-face or copy-face. |
| 1258 | 1263 | ||
| 1259 | 2012-03-20 Chong Yidong <cyd@gnu.org> | 1264 | 2012-03-20 Chong Yidong <cyd@gnu.org> |
| @@ -1594,8 +1599,8 @@ | |||
| 1594 | (Syntax Properties): Document syntax-propertize-function and | 1599 | (Syntax Properties): Document syntax-propertize-function and |
| 1595 | syntax-propertize-extend-region-functions. | 1600 | syntax-propertize-extend-region-functions. |
| 1596 | (Motion via Parsing): Clarify scan-lists. Fix indentation. | 1601 | (Motion via Parsing): Clarify scan-lists. Fix indentation. |
| 1597 | (Parser State): Update for the new "c" comment style. Fix | 1602 | (Parser State): Update for the new "c" comment style. |
| 1598 | description of item 7 (comment style). | 1603 | Fix description of item 7 (comment style). |
| 1599 | 1604 | ||
| 1600 | * modes.texi (Minor Modes): Update how mode commands should treat | 1605 | * modes.texi (Minor Modes): Update how mode commands should treat |
| 1601 | arguments now. | 1606 | arguments now. |
| @@ -1673,9 +1678,9 @@ | |||
| 1673 | 1678 | ||
| 1674 | * debugging.texi (Debugging): Copyedits. Describe testcover, ERT. | 1679 | * debugging.texi (Debugging): Copyedits. Describe testcover, ERT. |
| 1675 | (Error Debugging): Note that debug-ignored-errors overrides list | 1680 | (Error Debugging): Note that debug-ignored-errors overrides list |
| 1676 | values of debug-on-error too. Add xref to Signaling Errors. Note | 1681 | values of debug-on-error too. Add xref to Signaling Errors. |
| 1677 | that debug-on-signal is not customizable. Mention | 1682 | Note that debug-on-signal is not customizable. |
| 1678 | condition-case-unless-debug. | 1683 | Mention condition-case-unless-debug. |
| 1679 | (Compilation Errors): Node deleted. | 1684 | (Compilation Errors): Node deleted. |
| 1680 | 1685 | ||
| 1681 | * compile.texi (Compiler Errors): Move a paragraph here from | 1686 | * compile.texi (Compiler Errors): Move a paragraph here from |
| @@ -1791,15 +1796,15 @@ | |||
| 1791 | 2012-02-04 Chong Yidong <cyd@gnu.org> | 1796 | 2012-02-04 Chong Yidong <cyd@gnu.org> |
| 1792 | 1797 | ||
| 1793 | * functions.texi (What Is a Function): Add closures. Mention | 1798 | * functions.texi (What Is a Function): Add closures. Mention |
| 1794 | "return value" terminology. Add xref for command-execute. Remove | 1799 | "return value" terminology. Add xref for command-execute. |
| 1795 | unused "keystroke command" terminology. | 1800 | Remove unused "keystroke command" terminology. |
| 1796 | (Lambda Expressions): Give a different example than in the | 1801 | (Lambda Expressions): Give a different example than in the |
| 1797 | following subsection. Add xref to Anonymous Functions. | 1802 | following subsection. Add xref to Anonymous Functions. |
| 1798 | (Function Documentation): Remove gratuitous markup. | 1803 | (Function Documentation): Remove gratuitous markup. |
| 1799 | (Function Names): Move introductory text to `What Is a Function'. | 1804 | (Function Names): Move introductory text to `What Is a Function'. |
| 1800 | (Defining Functions): Fix defun argument spec. | 1805 | (Defining Functions): Fix defun argument spec. |
| 1801 | (Anonymous Functions): Document lambda macro explicitly. Mention | 1806 | (Anonymous Functions): Document lambda macro explicitly. |
| 1802 | effects on lexical binding. | 1807 | Mention effects on lexical binding. |
| 1803 | (Function Cells): Downplay direct usage of fset. | 1808 | (Function Cells): Downplay direct usage of fset. |
| 1804 | (Closures): New node. | 1809 | (Closures): New node. |
| 1805 | (Inline Functions): Remove "open-code" terminology. | 1810 | (Inline Functions): Remove "open-code" terminology. |
| @@ -1930,8 +1935,8 @@ | |||
| 1930 | * variables.texi (Variables, Local Variables, Void Variables): | 1935 | * variables.texi (Variables, Local Variables, Void Variables): |
| 1931 | Edit to make the descriptions less specific to dynamic binding. | 1936 | Edit to make the descriptions less specific to dynamic binding. |
| 1932 | (Local Variables): Default max-specpdl-size is now 1300. | 1937 | (Local Variables): Default max-specpdl-size is now 1300. |
| 1933 | (Defining Variables): Edits for lexical scoping. Delete | 1938 | (Defining Variables): Edits for lexical scoping. |
| 1934 | information about starting docstrings with *. De-document | 1939 | Delete information about starting docstrings with *. De-document |
| 1935 | user-variable-p. | 1940 | user-variable-p. |
| 1936 | (Tips for Defining): Remove an unimportant discussion of quitting | 1941 | (Tips for Defining): Remove an unimportant discussion of quitting |
| 1937 | in the middle of a load. | 1942 | in the middle of a load. |
| @@ -2019,8 +2024,8 @@ | |||
| 2019 | 2024 | ||
| 2020 | 2012-01-06 Chong Yidong <cyd@gnu.org> | 2025 | 2012-01-06 Chong Yidong <cyd@gnu.org> |
| 2021 | 2026 | ||
| 2022 | * variables.texi (Directory Local Variables): Document | 2027 | * variables.texi (Directory Local Variables): |
| 2023 | hack-dir-local-variables-non-file-buffer. | 2028 | Document hack-dir-local-variables-non-file-buffer. |
| 2024 | 2029 | ||
| 2025 | 2012-01-06 Glenn Morris <rgm@gnu.org> | 2030 | 2012-01-06 Glenn Morris <rgm@gnu.org> |
| 2026 | 2031 | ||
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi index 489e5cc5b22..00b0a75a3e2 100644 --- a/doc/lispref/control.texi +++ b/doc/lispref/control.texi | |||
| @@ -285,6 +285,110 @@ For example: | |||
| 285 | @end group | 285 | @end group |
| 286 | @end example | 286 | @end example |
| 287 | 287 | ||
| 288 | @menu | ||
| 289 | * Pattern maching case statement:: | ||
| 290 | @end menu | ||
| 291 | |||
| 292 | @node Pattern maching case statement | ||
| 293 | @subsection Pattern maching case statement | ||
| 294 | @cindex pcase | ||
| 295 | @cindex pattern matching | ||
| 296 | |||
| 297 | To compare a particular value against various possible cases, the macro | ||
| 298 | @code{pcase} can come handy. It takes the following form: | ||
| 299 | |||
| 300 | @example | ||
| 301 | (pcase @var{exp} @var{branch}1 @var{branch}2 @var{branch}3 @dots{}) | ||
| 302 | @end example | ||
| 303 | |||
| 304 | where each @var{branch} takes the form @code{(@var{upattern} | ||
| 305 | @var{body-forms}@dots{})}. | ||
| 306 | |||
| 307 | It will first evaluate @var{exp} and then compare the value against each | ||
| 308 | @var{upattern} to see which @var{branch} to use, after which it will run the | ||
| 309 | corresponding @var{body-forms}. A common use case is to distinguish | ||
| 310 | between a few different constant values: | ||
| 311 | |||
| 312 | @example | ||
| 313 | (pcase (get-return-code x) | ||
| 314 | (`success (message "Done!")) | ||
| 315 | (`would-block (message "Sorry, can't do it now")) | ||
| 316 | (`read-only (message "The shmliblick is read-only")) | ||
| 317 | (`access-denied (message "You do not have the needed rights")) | ||
| 318 | (code (message "Unknown return code %S" code))) | ||
| 319 | @end example | ||
| 320 | |||
| 321 | In the last clause, @code{code} is a variable that gets bound to the value that | ||
| 322 | was returned by @code{(get-return-code x)}. | ||
| 323 | |||
| 324 | To give a more complex example, a simple interpreter for a little | ||
| 325 | expression language could look like: | ||
| 326 | |||
| 327 | @example | ||
| 328 | (defun evaluate (exp env) | ||
| 329 | (pcase exp | ||
| 330 | (`(add ,x ,y) (+ (evaluate x env) (evaluate y env))) | ||
| 331 | (`(call ,fun ,arg) (funcall (evaluate fun) (evaluate arg env))) | ||
| 332 | (`(fn ,arg ,body) (lambda (val) | ||
| 333 | (evaluate body (cons (cons arg val) env)))) | ||
| 334 | ((pred numberp) exp) | ||
| 335 | ((pred symbolp) (cdr (assq exp env))) | ||
| 336 | (_ (error "Unknown expression %S" exp)))) | ||
| 337 | @end example | ||
| 338 | |||
| 339 | Where @code{`(add ,x ,y)} is a pattern that checks that @code{exp} is a three | ||
| 340 | element list starting with the symbol @code{add}, then extracts the second and | ||
| 341 | third elements and binds them to the variables @code{x} and @code{y}. | ||
| 342 | @code{(pred numberp)} is a pattern that simply checks that @code{exp} | ||
| 343 | is a number, and @code{_} is the catch-all pattern that matches anything. | ||
| 344 | |||
| 345 | There are two kinds of patterns involved in @code{pcase}, called | ||
| 346 | @emph{U-patterns} and @emph{Q-patterns}. The @var{upattern} mentioned above | ||
| 347 | are U-patterns and can take the following forms: | ||
| 348 | |||
| 349 | @table @code | ||
| 350 | @item `@var{qpattern} | ||
| 351 | This is one of the most common form of patterns. The intention is to mimic the | ||
| 352 | backquote macro: this pattern matches those values that could have been built | ||
| 353 | by such a backquote expression. Since we're pattern matching rather than | ||
| 354 | building a value, the unquote does not indicate where to plug an expression, | ||
| 355 | but instead it lets one specify a U-pattern that should match the value at | ||
| 356 | that location. | ||
| 357 | |||
| 358 | More specifically, a Q-pattern can take the following forms: | ||
| 359 | @table @code | ||
| 360 | @item (@var{qpattern1} . @var{qpattern2}) | ||
| 361 | This pattern matches any cons cell whose @code{car} matches @var{QPATTERN1} and | ||
| 362 | whose @code{cdr} matches @var{PATTERN2}. | ||
| 363 | @item @var{atom} | ||
| 364 | This pattern matches any atom @code{equal} to @var{atom}. | ||
| 365 | @item ,@var{upattern} | ||
| 366 | This pattern matches any object that matches the @var{upattern}. | ||
| 367 | @end table | ||
| 368 | |||
| 369 | @item @var{symbol} | ||
| 370 | A mere symbol in a U-pattern matches anything, and additionally let-binds this | ||
| 371 | symbol to the value that it matched, so that you can later refer to it, either | ||
| 372 | in the @var{body-forms} or also later in the pattern. | ||
| 373 | @item _ | ||
| 374 | This so-called @emph{don't care} pattern matches anything, like the previous | ||
| 375 | one, but unless symbol patterns it does not bind any variable. | ||
| 376 | @item (pred @var{pred}) | ||
| 377 | This pattern matches if the function @var{pred} returns non-@code{nil} when | ||
| 378 | called with the object being matched. | ||
| 379 | @item (or @var{upattern1} @var{upattern2}@dots{}) | ||
| 380 | This pattern matches as soon as one of the argument patterns succeeds. | ||
| 381 | All argument patterns should let-bind the same variables. | ||
| 382 | @item (and @var{upattern1} @var{upattern2}@dots{}) | ||
| 383 | This pattern matches only if all the argument patterns succeed. | ||
| 384 | @item (guard @var{exp}) | ||
| 385 | This pattern ignores the object being examined and simply succeeds if @var{exp} | ||
| 386 | evaluates to non-@code{nil} and fails otherwise. It is typically used inside | ||
| 387 | an @code{and} pattern. For example, @code{(and x (guard (< x 10)))} | ||
| 388 | is a pattern which matches any number smaller than 10 and let-binds it to | ||
| 389 | the variable @code{x}. | ||
| 390 | @end table | ||
| 391 | |||
| 288 | @node Combining Conditions | 392 | @node Combining Conditions |
| 289 | @section Constructs for Combining Conditions | 393 | @section Constructs for Combining Conditions |
| 290 | 394 | ||
diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi index c8d09760b53..56e091eabf2 100644 --- a/doc/lispref/customize.texi +++ b/doc/lispref/customize.texi | |||
| @@ -303,7 +303,9 @@ evaluate at any time. | |||
| 303 | The argument @var{doc} specifies the documentation string for the | 303 | The argument @var{doc} specifies the documentation string for the |
| 304 | variable. | 304 | variable. |
| 305 | 305 | ||
| 306 | Every @code{defcustom} should specify @code{:group} at least once. | 306 | If a @code{defcustom} does not specify any @code{:group}, the last group |
| 307 | defined with @code{defgroup} in the same file will be used. This way, most | ||
| 308 | @code{defcustom} do not need an explicit @code{:group}. | ||
| 307 | 309 | ||
| 308 | When you evaluate a @code{defcustom} form with @kbd{C-M-x} in Emacs Lisp | 310 | When you evaluate a @code{defcustom} form with @kbd{C-M-x} in Emacs Lisp |
| 309 | mode (@code{eval-defun}), a special feature of @code{eval-defun} | 311 | mode (@code{eval-defun}), a special feature of @code{eval-defun} |