aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref
diff options
context:
space:
mode:
authorGlenn Morris2012-12-09 18:00:42 -0800
committerGlenn Morris2012-12-09 18:00:42 -0800
commit265c2fbf11cb8bf9b805df63ecb9508631f08e35 (patch)
tree808684294d7ec600f5300e0a5d5f868740096f7b /doc/lispref
parent5f460827dd14fbfae26ac8451cedd4446817d1ec (diff)
parentf433306af510e86a614e9f9f082b6d2d5f56a968 (diff)
downloademacs-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/ChangeLog69
-rw-r--r--doc/lispref/control.texi104
-rw-r--r--doc/lispref/customize.texi4
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 @@
12012-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
12012-12-09 Glenn Morris <rgm@gnu.org> 82012-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
612012-11-24 Chong Yidong <cyd@gnu.org> 662012-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
1222012-11-16 Glenn Morris <rgm@gnu.org> 1272012-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
10932012-04-12 Jari Aalto <jari.aalto@cante.net> 10982012-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
10982012-04-09 Chong Yidong <cyd@gnu.org> 11032012-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
12592012-03-20 Chong Yidong <cyd@gnu.org> 12642012-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 @@
17912012-02-04 Chong Yidong <cyd@gnu.org> 17962012-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
20202012-01-06 Chong Yidong <cyd@gnu.org> 20252012-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
20252012-01-06 Glenn Morris <rgm@gnu.org> 20302012-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
297To 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
304where each @var{branch} takes the form @code{(@var{upattern}
305@var{body-forms}@dots{})}.
306
307It 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
309corresponding @var{body-forms}. A common use case is to distinguish
310between 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
321In the last clause, @code{code} is a variable that gets bound to the value that
322was returned by @code{(get-return-code x)}.
323
324To give a more complex example, a simple interpreter for a little
325expression 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
339Where @code{`(add ,x ,y)} is a pattern that checks that @code{exp} is a three
340element list starting with the symbol @code{add}, then extracts the second and
341third 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}
343is a number, and @code{_} is the catch-all pattern that matches anything.
344
345There are two kinds of patterns involved in @code{pcase}, called
346@emph{U-patterns} and @emph{Q-patterns}. The @var{upattern} mentioned above
347are U-patterns and can take the following forms:
348
349@table @code
350@item `@var{qpattern}
351This is one of the most common form of patterns. The intention is to mimic the
352backquote macro: this pattern matches those values that could have been built
353by such a backquote expression. Since we're pattern matching rather than
354building a value, the unquote does not indicate where to plug an expression,
355but instead it lets one specify a U-pattern that should match the value at
356that location.
357
358More specifically, a Q-pattern can take the following forms:
359@table @code
360@item (@var{qpattern1} . @var{qpattern2})
361This pattern matches any cons cell whose @code{car} matches @var{QPATTERN1} and
362whose @code{cdr} matches @var{PATTERN2}.
363@item @var{atom}
364This pattern matches any atom @code{equal} to @var{atom}.
365@item ,@var{upattern}
366This pattern matches any object that matches the @var{upattern}.
367@end table
368
369@item @var{symbol}
370A mere symbol in a U-pattern matches anything, and additionally let-binds this
371symbol to the value that it matched, so that you can later refer to it, either
372in the @var{body-forms} or also later in the pattern.
373@item _
374This so-called @emph{don't care} pattern matches anything, like the previous
375one, but unless symbol patterns it does not bind any variable.
376@item (pred @var{pred})
377This pattern matches if the function @var{pred} returns non-@code{nil} when
378called with the object being matched.
379@item (or @var{upattern1} @var{upattern2}@dots{})
380This pattern matches as soon as one of the argument patterns succeeds.
381All argument patterns should let-bind the same variables.
382@item (and @var{upattern1} @var{upattern2}@dots{})
383This pattern matches only if all the argument patterns succeed.
384@item (guard @var{exp})
385This pattern ignores the object being examined and simply succeeds if @var{exp}
386evaluates to non-@code{nil} and fails otherwise. It is typically used inside
387an @code{and} pattern. For example, @code{(and x (guard (< x 10)))}
388is a pattern which matches any number smaller than 10 and let-binds it to
389the 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.
303The argument @var{doc} specifies the documentation string for the 303The argument @var{doc} specifies the documentation string for the
304variable. 304variable.
305 305
306Every @code{defcustom} should specify @code{:group} at least once. 306If a @code{defcustom} does not specify any @code{:group}, the last group
307defined 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
308When you evaluate a @code{defcustom} form with @kbd{C-M-x} in Emacs Lisp 310When you evaluate a @code{defcustom} form with @kbd{C-M-x} in Emacs Lisp
309mode (@code{eval-defun}), a special feature of @code{eval-defun} 311mode (@code{eval-defun}), a special feature of @code{eval-defun}