aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/ChangeLog206
-rw-r--r--doc/lispref/modes.texi668
-rw-r--r--doc/lispref/text.texi2
3 files changed, 771 insertions, 105 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 6efa8466563..b27efdda941 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,9 @@
12010-12-07 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * modes.texi (Auto-Indentation): New section to document SMIE.
4 (Major Mode Conventions):
5 * text.texi (Mode-Specific Indent): Refer to it.
6
12010-12-04 Eli Zaretskii <eliz@gnu.org> 72010-12-04 Eli Zaretskii <eliz@gnu.org>
2 8
3 * display.texi (Other Display Specs): Document left-fringe and 9 * display.texi (Other Display Specs): Document left-fringe and
@@ -12,8 +18,8 @@
12 18
132010-11-21 Chong Yidong <cyd@stupidchicken.com> 192010-11-21 Chong Yidong <cyd@stupidchicken.com>
14 20
15 * nonascii.texi (Converting Representations): Document 21 * nonascii.texi (Converting Representations):
16 byte-to-string. 22 Document byte-to-string.
17 23
18 * strings.texi (Creating Strings): Don't mention semi-obsolete 24 * strings.texi (Creating Strings): Don't mention semi-obsolete
19 function char-to-string. 25 function char-to-string.
@@ -44,8 +50,8 @@
44 50
45 * customize.texi (Composite Types): Lower-case index entry. 51 * customize.texi (Composite Types): Lower-case index entry.
46 52
47 * loading.texi (How Programs Do Loading): Document 53 * loading.texi (How Programs Do Loading):
48 load-file-name. (Bug#7346) 54 Document load-file-name. (Bug#7346)
49 55
502010-11-10 Glenn Morris <rgm@gnu.org> 562010-11-10 Glenn Morris <rgm@gnu.org>
51 57
@@ -152,8 +158,8 @@
152 158
153 * keymaps.texi (Menu Bar): Document :advertised-binding property. 159 * keymaps.texi (Menu Bar): Document :advertised-binding property.
154 160
155 * functions.texi (Obsolete Functions): Document 161 * functions.texi (Obsolete Functions):
156 set-advertised-calling-convention. 162 Document set-advertised-calling-convention.
157 163
158 * minibuf.texi (Basic Completion): Document completion-in-region. 164 * minibuf.texi (Basic Completion): Document completion-in-region.
159 (Programmed Completion): Document completion-annotate-function. 165 (Programmed Completion): Document completion-annotate-function.
@@ -278,8 +284,8 @@
278 * minibuf.texi (Basic Completion): 4th arg to all-completions is 284 * minibuf.texi (Basic Completion): 4th arg to all-completions is
279 obsolete. 285 obsolete.
280 286
281 * processes.texi (Process Buffers): Document 287 * processes.texi (Process Buffers):
282 process-kill-buffer-query-function. 288 Document process-kill-buffer-query-function.
283 289
2842009-12-05 Glenn Morris <rgm@gnu.org> 2902009-12-05 Glenn Morris <rgm@gnu.org>
285 291
@@ -726,8 +732,8 @@
726 (Suspending Emacs): Mark suspend-emacs as a command. 732 (Suspending Emacs): Mark suspend-emacs as a command.
727 (Processor Run Time): Mark emacs-uptime and emacs-init-time as 733 (Processor Run Time): Mark emacs-uptime and emacs-init-time as
728 commands. 734 commands.
729 (Terminal Output): Remove obsolete function baud-rate. Document 735 (Terminal Output): Remove obsolete function baud-rate.
730 TERMINAL arg for send-string-to-terminal. 736 Document TERMINAL arg for send-string-to-terminal.
731 737
732 * nonascii.texi (Terminal I/O Encoding): Document TERMINAL arg for 738 * nonascii.texi (Terminal I/O Encoding): Document TERMINAL arg for
733 terminal-coding-system and set-terminal-coding-system. 739 terminal-coding-system and set-terminal-coding-system.
@@ -831,8 +837,8 @@
8312009-05-09 Eli Zaretskii <eliz@gnu.org> 8372009-05-09 Eli Zaretskii <eliz@gnu.org>
832 838
833 * nonascii.texi (Default Coding Systems): Document 839 * nonascii.texi (Default Coding Systems): Document
834 find-auto-coding, set-auto-coding, and auto-coding-alist. Add 840 find-auto-coding, set-auto-coding, and auto-coding-alist.
835 indexing. 841 Add indexing.
836 (Lisp and Coding Systems): Add index entries. 842 (Lisp and Coding Systems): Add index entries.
837 843
8382009-05-09 Martin Rudalics <rudalics@gmx.at> 8442009-05-09 Martin Rudalics <rudalics@gmx.at>
@@ -874,8 +880,8 @@
874 880
8752009-04-22 Chong Yidong <cyd@stupidchicken.com> 8812009-04-22 Chong Yidong <cyd@stupidchicken.com>
876 882
877 * os.texi (Command-Line Arguments): Document 883 * os.texi (Command-Line Arguments):
878 command-line-args-left. 884 Document command-line-args-left.
879 (Suspending Emacs): Adapt text to multi-tty case. Document use of 885 (Suspending Emacs): Adapt text to multi-tty case. Document use of
880 terminal objects for tty arguments. 886 terminal objects for tty arguments.
881 (Startup Summary): Add xref to Session Management. 887 (Startup Summary): Add xref to Session Management.
@@ -951,13 +957,13 @@
9512009-04-09 Chong Yidong <cyd@stupidchicken.com> 9572009-04-09 Chong Yidong <cyd@stupidchicken.com>
952 958
953 * text.texi (Yank Commands): Note that yank uses push-mark. 959 * text.texi (Yank Commands): Note that yank uses push-mark.
954 (Filling): Clarify REGION argument of fill-paragraph. Document 960 (Filling): Clarify REGION argument of fill-paragraph.
955 fill-forward-paragraph-function. 961 Document fill-forward-paragraph-function.
956 (Special Properties): Remove "new in Emacs 22" declaration. 962 (Special Properties): Remove "new in Emacs 22" declaration.
957 (Clickable Text): Merge with Links and Mouse-1 node. 963 (Clickable Text): Merge with Links and Mouse-1 node.
958 964
959 * display.texi (Button Properties, Button Buffer Commands): Change 965 * display.texi (Button Properties, Button Buffer Commands):
960 xref to Clickable Text. 966 Change xref to Clickable Text.
961 967
962 * tips.texi (Key Binding Conventions): Change xref to Clickable 968 * tips.texi (Key Binding Conventions): Change xref to Clickable
963 Text. 969 Text.
@@ -1019,8 +1025,8 @@
1019 1025
10202009-03-29 Chong Yidong <cyd@stupidchicken.com> 10262009-03-29 Chong Yidong <cyd@stupidchicken.com>
1021 1027
1022 * help.texi (Accessing Documentation, Help Functions): Remove 1028 * help.texi (Accessing Documentation, Help Functions):
1023 information about long-obsolete Emacs versions. 1029 Remove information about long-obsolete Emacs versions.
1024 1030
1025 * modes.texi (Mode Line Variables): The default values of the mode 1031 * modes.texi (Mode Line Variables): The default values of the mode
1026 line variables are now more complicated. 1032 line variables are now more complicated.
@@ -1063,8 +1069,8 @@
10632009-03-23 Chong Yidong <cyd@stupidchicken.com> 10692009-03-23 Chong Yidong <cyd@stupidchicken.com>
1064 1070
1065 * minibuf.texi (Intro to Minibuffers): Remove long-obsolete info 1071 * minibuf.texi (Intro to Minibuffers): Remove long-obsolete info
1066 about minibuffers in old Emacs versions. Copyedits. Emphasize 1072 about minibuffers in old Emacs versions. Copyedits.
1067 that enable-recursive-minibuffers defaults to nil. 1073 Emphasize that enable-recursive-minibuffers defaults to nil.
1068 (Text from Minibuffer): Simplify introduction. 1074 (Text from Minibuffer): Simplify introduction.
1069 1075
10702009-03-22 Alan Mackenzie <acm@muc.de> 10762009-03-22 Alan Mackenzie <acm@muc.de>
@@ -1118,8 +1124,8 @@
1118 * customize.texi (Common Keywords): It's not necessary to use :tag 1124 * customize.texi (Common Keywords): It's not necessary to use :tag
1119 to remove hyphens, as custom-unlispify-tag-name does it 1125 to remove hyphens, as custom-unlispify-tag-name does it
1120 automatically. 1126 automatically.
1121 (Variable Definitions): Link to File Local Variables. Document 1127 (Variable Definitions): Link to File Local Variables.
1122 customized-value symbol property. 1128 Document customized-value symbol property.
1123 (Customization Types): Move menu to end of node. 1129 (Customization Types): Move menu to end of node.
1124 1130
11252009-03-10 Chong Yidong <cyd@stupidchicken.com> 11312009-03-10 Chong Yidong <cyd@stupidchicken.com>
@@ -1230,8 +1236,8 @@
1230 * text.texi (Commands for Insertion): 1236 * text.texi (Commands for Insertion):
1231 * commands.texi (Event Mod): 1237 * commands.texi (Event Mod):
1232 * keymaps.texi (Searching Keymaps): 1238 * keymaps.texi (Searching Keymaps):
1233 * nonascii.texi (Translation of Characters): Reinstate 1239 * nonascii.texi (Translation of Characters):
1234 documentation of translation-table-for-input. 1240 Reinstate documentation of translation-table-for-input.
1235 (Explicit Encoding): Document the `charset' text property produced 1241 (Explicit Encoding): Document the `charset' text property produced
1236 by decode-coding-region and decode-coding-string. 1242 by decode-coding-region and decode-coding-string.
1237 1243
@@ -1260,8 +1266,8 @@
12602009-01-22 Chong Yidong <cyd@stupidchicken.com> 12662009-01-22 Chong Yidong <cyd@stupidchicken.com>
1261 1267
1262 * files.texi (Format Conversion Piecemeal): Clarify behavior of 1268 * files.texi (Format Conversion Piecemeal): Clarify behavior of
1263 write-region-annotate-functions. Document 1269 write-region-annotate-functions.
1264 write-region-post-annotation-function. 1270 Document write-region-post-annotation-function.
1265 1271
12662009-01-19 Chong Yidong <cyd@stupidchicken.com> 12722009-01-19 Chong Yidong <cyd@stupidchicken.com>
1267 1273
@@ -1328,8 +1334,8 @@
1328 1334
1329 * processes.texi (Serial Ports): Improve wording, suggested by RMS. 1335 * processes.texi (Serial Ports): Improve wording, suggested by RMS.
1330 1336
1331 * nonascii.texi (Lisp and Coding Systems): Document 1337 * nonascii.texi (Lisp and Coding Systems):
1332 inhibit-null-byte-detection and inhibit-iso-escape-detection. 1338 Document inhibit-null-byte-detection and inhibit-iso-escape-detection.
1333 (Character Properties): Improve wording. 1339 (Character Properties): Improve wording.
1334 1340
13352009-01-09 Chong Yidong <cyd@stupidchicken.com> 13412009-01-09 Chong Yidong <cyd@stupidchicken.com>
@@ -1337,8 +1343,8 @@
1337 * display.texi (Font Lookup): Remove obsolete function 1343 * display.texi (Font Lookup): Remove obsolete function
1338 x-font-family-list. x-list-fonts accepts Fontconfig/GTK syntax. 1344 x-font-family-list. x-list-fonts accepts Fontconfig/GTK syntax.
1339 (Low-Level Font): Rename from Fonts, move to end of Faces section. 1345 (Low-Level Font): Rename from Fonts, move to end of Faces section.
1340 (Font Selection): Reorder order of variable descriptions. Minor 1346 (Font Selection): Reorder order of variable descriptions.
1341 clarifications. 1347 Minor clarifications.
1342 1348
1343 * elisp.texi (Top): Update node listing. 1349 * elisp.texi (Top): Update node listing.
1344 1350
@@ -1359,8 +1365,8 @@
1359 * elisp.texi: Update node listing. 1365 * elisp.texi: Update node listing.
1360 1366
1361 * display.texi (Faces): Put Font Selection node after Auto Faces. 1367 * display.texi (Faces): Put Font Selection node after Auto Faces.
1362 (Face Attributes): Don't link to Font Lookup. Document 1368 (Face Attributes): Don't link to Font Lookup.
1363 font-family-list. 1369 Document font-family-list.
1364 (Fonts): New node. 1370 (Fonts): New node.
1365 1371
13662009-01-08 Jason Rumney <jasonr@gnu.org> 13722009-01-08 Jason Rumney <jasonr@gnu.org>
@@ -1588,8 +1594,8 @@
1588 * windows.texi (Window Hooks): Remove *-end-trigger-functions 1594 * windows.texi (Window Hooks): Remove *-end-trigger-functions
1589 vars, which are obsolete. Mention jit-lock-register. 1595 vars, which are obsolete. Mention jit-lock-register.
1590 1596
1591 * modes.texi (Other Font Lock Variables): Document 1597 * modes.texi (Other Font Lock Variables):
1592 jit-lock-register and jit-lock-unregister. 1598 Document jit-lock-register and jit-lock-unregister.
1593 1599
1594 * frames.texi (Color Parameters): Document alpha parameter. 1600 * frames.texi (Color Parameters): Document alpha parameter.
1595 1601
@@ -1661,8 +1667,8 @@
16612008-11-01 Eli Zaretskii <eliz@gnu.org> 16672008-11-01 Eli Zaretskii <eliz@gnu.org>
1662 1668
1663 * nonascii.texi (Text Representations): Rewrite to make consistent 1669 * nonascii.texi (Text Representations): Rewrite to make consistent
1664 with Emacs 23 internal representation of characters. Document 1670 with Emacs 23 internal representation of characters.
1665 `unibyte-string'. 1671 Document `unibyte-string'.
1666 1672
16672008-10-28 Chong Yidong <cyd@stupidchicken.com> 16732008-10-28 Chong Yidong <cyd@stupidchicken.com>
1668 1674
@@ -1775,8 +1781,8 @@
1775 1781
1776 * processes.texi (Synchronous Processes): Document `process-lines'. 1782 * processes.texi (Synchronous Processes): Document `process-lines'.
1777 1783
1778 * customize.texi (Variable Definitions): Document 1784 * customize.texi (Variable Definitions):
1779 `custom-reevaluate-setting'. 1785 Document `custom-reevaluate-setting'.
1780 1786
17812008-10-18 Martin Rudalics <rudalics@gmx.at> 17872008-10-18 Martin Rudalics <rudalics@gmx.at>
1782 1788
@@ -1792,13 +1798,13 @@
1792 * maps.texi (Standard Keymaps): Document `multi-query-replace-map' 1798 * maps.texi (Standard Keymaps): Document `multi-query-replace-map'
1793 and `search-map'. 1799 and `search-map'.
1794 1800
1795 * searching.texi (Search and Replace): Document 1801 * searching.texi (Search and Replace):
1796 `replace-search-function' and `replace-re-search-function'. 1802 Document `replace-search-function' and `replace-re-search-function'.
1797 Document `multi-query-replace-map'. 1803 Document `multi-query-replace-map'.
1798 1804
1799 * minibuf.texi (Text from Minibuffer): Document `read-regexp'. 1805 * minibuf.texi (Text from Minibuffer): Document `read-regexp'.
1800 (Completion Commands, Reading File Names): Rename 1806 (Completion Commands, Reading File Names):
1801 `minibuffer-local-must-match-filename-map' to 1807 Rename `minibuffer-local-must-match-filename-map' to
1802 `minibuffer-local-filename-must-match-map'. 1808 `minibuffer-local-filename-must-match-map'.
1803 (Minibuffer Completion): The `require-match' argument to 1809 (Minibuffer Completion): The `require-match' argument to
1804 `completing-read' can now have the value `confirm-only'. 1810 `completing-read' can now have the value `confirm-only'.
@@ -2143,7 +2149,7 @@
2143 2149
21442007-12-30 Richard Stallman <rms@gnu.org> 21502007-12-30 Richard Stallman <rms@gnu.org>
2145 2151
2146 * commands.texi (Accessing Mouse): Renamed from Accessing Events. 2152 * commands.texi (Accessing Mouse): Rename from Accessing Events.
2147 (Accessing Scroll): New node broken out of Accessing Mouse. 2153 (Accessing Scroll): New node broken out of Accessing Mouse.
2148 2154
21492007-12-28 Richard Stallman <rms@gnu.org> 21552007-12-28 Richard Stallman <rms@gnu.org>
@@ -2187,8 +2193,8 @@
2187 2193
21882007-11-29 Glenn Morris <rgm@gnu.org> 21942007-11-29 Glenn Morris <rgm@gnu.org>
2189 2195
2190 * functions.texi (Declaring Functions): Add findex. Mention 2196 * functions.texi (Declaring Functions): Add findex.
2191 `external' files. 2197 Mention `external' files.
2192 2198
21932007-11-26 Juanma Barranquero <lekktu@gmail.com> 21992007-11-26 Juanma Barranquero <lekktu@gmail.com>
2194 2200
@@ -2315,8 +2321,8 @@
2315 * display.texi (Display Property): Explain some display specs 2321 * display.texi (Display Property): Explain some display specs
2316 don't let you move point in. 2322 don't let you move point in.
2317 2323
2318 * frames.texi (Cursor Parameters): Describe 2324 * frames.texi (Cursor Parameters):
2319 cursor-in-non-selected-windows here. Explain more values. 2325 Describe cursor-in-non-selected-windows here. Explain more values.
2320 2326
2321 * windows.texi (Basic Windows): Don't describe 2327 * windows.texi (Basic Windows): Don't describe
2322 cursor-in-non-selected-windows here. 2328 cursor-in-non-selected-windows here.
@@ -2395,8 +2401,8 @@
2395 2401
23962007-08-16 Richard Stallman <rms@gnu.org> 24022007-08-16 Richard Stallman <rms@gnu.org>
2397 2403
2398 * processes.texi (Asynchronous Processes): Clarify 2404 * processes.texi (Asynchronous Processes):
2399 doc of start-file-process. 2405 Clarify doc of start-file-process.
2400 2406
24012007-08-08 Martin Rudalics <rudalics@gmx.at> 24072007-08-08 Martin Rudalics <rudalics@gmx.at>
2402 2408
@@ -2463,8 +2469,8 @@
2463 2469
24642007-06-27 Richard Stallman <rms@gnu.org> 24702007-06-27 Richard Stallman <rms@gnu.org>
2465 2471
2466 * files.texi (Format Conversion Piecemeal): Clarify 2472 * files.texi (Format Conversion Piecemeal):
2467 `after-insert-file-functions' calling convention. 2473 Clarify `after-insert-file-functions' calling convention.
2468 2474
24692007-06-27 Michael Albinus <michael.albinus@gmx.de> 24752007-06-27 Michael Albinus <michael.albinus@gmx.de>
2470 2476
@@ -2519,8 +2525,8 @@
2519 2525
25202007-05-30 Nick Roberts <nickrob@snap.net.nz> 25262007-05-30 Nick Roberts <nickrob@snap.net.nz>
2521 2527
2522 * commands.texi (Click Events): Layout more logically. Describe 2528 * commands.texi (Click Events): Layout more logically.
2523 width and height. 2529 Describe width and height.
2524 (Drag Events, Motion Events): Update to new format for position. 2530 (Drag Events, Motion Events): Update to new format for position.
2525 2531
25262007-06-02 Richard Stallman <rms@gnu.org> 25322007-06-02 Richard Stallman <rms@gnu.org>
@@ -2926,8 +2932,8 @@
2926 2932
29272007-03-05 Richard Stallman <rms@gnu.org> 29332007-03-05 Richard Stallman <rms@gnu.org>
2928 2934
2929 * variables.texi (File Local Variables): Update 2935 * variables.texi (File Local Variables):
2930 enable-local-variables values. 2936 Update enable-local-variables values.
2931 2937
29322007-03-04 Richard Stallman <rms@gnu.org> 29382007-03-04 Richard Stallman <rms@gnu.org>
2933 2939
@@ -2998,8 +3004,8 @@
29982007-02-03 Eli Zaretskii <eliz@gnu.org> 30042007-02-03 Eli Zaretskii <eliz@gnu.org>
2999 3005
3000 * elisp.texi (Top): Make the detailed menu headers compliant with 3006 * elisp.texi (Top): Make the detailed menu headers compliant with
3001 Texinfo guidelines and with what texnfo-upd.el expects. Add 3007 Texinfo guidelines and with what texnfo-upd.el expects.
3002 comments to prevent people from inadvertently modifying the key 3008 Add comments to prevent people from inadvertently modifying the key
3003 parts needed by `texinfo-multiple-files-update'. 3009 parts needed by `texinfo-multiple-files-update'.
3004 3010
30052007-02-02 Eli Zaretskii <eliz@gnu.org> 30112007-02-02 Eli Zaretskii <eliz@gnu.org>
@@ -3086,8 +3092,8 @@
3086 3092
30872006-12-24 Richard Stallman <rms@gnu.org> 30932006-12-24 Richard Stallman <rms@gnu.org>
3088 3094
3089 * customize.texi (Variable Definitions): Document 3095 * customize.texi (Variable Definitions):
3090 new name custom-add-frequent-value. 3096 Document new name custom-add-frequent-value.
3091 3097
30922006-12-19 Kim F. Storm <storm@cua.dk> 30982006-12-19 Kim F. Storm <storm@cua.dk>
3093 3099
@@ -3386,8 +3392,8 @@
3386 3392
33872006-09-01 Chong Yidong <cyd@stupidchicken.com> 33932006-09-01 Chong Yidong <cyd@stupidchicken.com>
3388 3394
3389 * buffers.texi (Buffer Modification): Document 3395 * buffers.texi (Buffer Modification):
3390 buffer-chars-modified-tick. 3396 Document buffer-chars-modified-tick.
3391 3397
33922006-08-31 Richard Stallman <rms@gnu.org> 33982006-08-31 Richard Stallman <rms@gnu.org>
3393 3399
@@ -3449,7 +3455,7 @@
34492006-08-12 Chong Yidong <cyd@stupidchicken.com> 34552006-08-12 Chong Yidong <cyd@stupidchicken.com>
3450 3456
3451 * text.texi (Near Point): Say "cursor" not "terminal cursor". 3457 * text.texi (Near Point): Say "cursor" not "terminal cursor".
3452 (Commands for Insertion): Removed split-line since it's not 3458 (Commands for Insertion): Remove split-line since it's not
3453 relevant for Lisp programming. 3459 relevant for Lisp programming.
3454 (Yank Commands): Rewrite introduction. 3460 (Yank Commands): Rewrite introduction.
3455 (Undo): Clarify. 3461 (Undo): Clarify.
@@ -3480,7 +3486,7 @@
3480 (Major Mode Basics): Mention define-derived-mode explicitly. 3486 (Major Mode Basics): Mention define-derived-mode explicitly.
3481 (Major Mode Conventions): Rebinding RET is OK for some modes. 3487 (Major Mode Conventions): Rebinding RET is OK for some modes.
3482 Mention change-major-mode-hook and after-change-major-mode-hook. 3488 Mention change-major-mode-hook and after-change-major-mode-hook.
3483 (Example Major Modes): Moved to end of Modes section. 3489 (Example Major Modes): Move to end of Modes section.
3484 (Mode Line Basics): Clarify. 3490 (Mode Line Basics): Clarify.
3485 (Mode Line Data): Mention help-echo and local-map in strings. 3491 (Mode Line Data): Mention help-echo and local-map in strings.
3486 Explain reason for treatment of non-risky variables. 3492 Explain reason for treatment of non-risky variables.
@@ -3979,7 +3985,7 @@
3979 3985
39802006-05-25 Chong Yidong <cyd@stupidchicken.com> 39862006-05-25 Chong Yidong <cyd@stupidchicken.com>
3981 3987
3982 * keymaps.texi (Key Sequences): Renamed from Keymap Terminology. 3988 * keymaps.texi (Key Sequences): Rename from Keymap Terminology.
3983 Explain string and vector representations of key sequences. 3989 Explain string and vector representations of key sequences.
3984 3990
3985 * keymaps.texi (Changing Key Bindings): 3991 * keymaps.texi (Changing Key Bindings):
@@ -4028,8 +4034,8 @@
4028 4034
40292006-05-15 Oliver Scholz <epameinondas@gmx.de> (tiny change) 40352006-05-15 Oliver Scholz <epameinondas@gmx.de> (tiny change)
4030 4036
4031 * nonascii.texi (Explicit Encoding): Fix 4037 * nonascii.texi (Explicit Encoding):
4032 typo (encoding<->decoding). 4038 Fix typo (encoding<->decoding).
4033 4039
40342006-05-14 Richard Stallman <rms@gnu.org> 40402006-05-14 Richard Stallman <rms@gnu.org>
4035 4041
@@ -4079,8 +4085,8 @@
4079 4085
40802006-05-09 Richard Stallman <rms@gnu.org> 40862006-05-09 Richard Stallman <rms@gnu.org>
4081 4087
4082 * variables.texi (File Local Variables): Document 4088 * variables.texi (File Local Variables):
4083 safe-local-eval-forms and safe-local-eval-function. 4089 Document safe-local-eval-forms and safe-local-eval-function.
4084 4090
40852006-05-07 Kim F. Storm <storm@cua.dk> 40912006-05-07 Kim F. Storm <storm@cua.dk>
4086 4092
@@ -4564,8 +4570,8 @@
4564 4570
45652005-12-03 Eli Zaretskii <eliz@gnu.org> 45712005-12-03 Eli Zaretskii <eliz@gnu.org>
4566 4572
4567 * hooks.texi (Standard Hooks): Add index entries. Mention 4573 * hooks.texi (Standard Hooks): Add index entries.
4568 `compilation-finish-functions'. 4574 Mention `compilation-finish-functions'.
4569 4575
45702005-11-27 Richard M. Stallman <rms@gnu.org> 45762005-11-27 Richard M. Stallman <rms@gnu.org>
4571 4577
@@ -4788,8 +4794,8 @@
4788 buffer-local. 4794 buffer-local.
4789 (Undo): Note that buffer-undo-list is buffer-local. 4795 (Undo): Note that buffer-undo-list is buffer-local.
4790 4796
4791 * windows.texi (Buffers and Windows): Document 4797 * windows.texi (Buffers and Windows):
4792 buffer-display-count. 4798 Document buffer-display-count.
4793 4799
47942005-09-06 Richard M. Stallman <rms@gnu.org> 48002005-09-06 Richard M. Stallman <rms@gnu.org>
4795 4801
@@ -5030,7 +5036,7 @@
5030 5036
5031 * display.texi (Displaying Messages): New node, with most 5037 * display.texi (Displaying Messages): New node, with most
5032 of what was in The Echo Area. 5038 of what was in The Echo Area.
5033 (Progress): Moved under The Echo Area. 5039 (Progress): Move under The Echo Area.
5034 (Logging Messages): New node with new text. 5040 (Logging Messages): New node with new text.
5035 (Echo Area Customization): New node, the rest of what was 5041 (Echo Area Customization): New node, the rest of what was
5036 in The Echo Area. Document message-truncate-lines with @defvar. 5042 in The Echo Area. Document message-truncate-lines with @defvar.
@@ -6345,8 +6351,8 @@
6345 (Scroll Bars): Add scroll-bar-mode and scroll-bar-width. 6351 (Scroll Bars): Add scroll-bar-mode and scroll-bar-width.
6346 (Usual Display): Move tab-width up. 6352 (Usual Display): Move tab-width up.
6347 6353
6348 * customize.texi (Variable Definitions): Replace 6354 * customize.texi (Variable Definitions):
6349 show-paren-mode example with tooltip-mode. 6355 Replace show-paren-mode example with tooltip-mode.
6350 (Simple Types, Composite Types, Defining New Types): 6356 (Simple Types, Composite Types, Defining New Types):
6351 Minor cleanups. 6357 Minor cleanups.
6352 6358
@@ -6582,8 +6588,8 @@
6582 (Display Fringe Bitmaps): New node. 6588 (Display Fringe Bitmaps): New node.
6583 (Images): Add 'Image Slices' to menu. 6589 (Images): Add 'Image Slices' to menu.
6584 (Image Descriptors): Add `:pointer' and `:map' properties. 6590 (Image Descriptors): Add `:pointer' and `:map' properties.
6585 (Showing Images): Add slice arg to `insert-image'. Add 6591 (Showing Images): Add slice arg to `insert-image'.
6586 'insert-sliced-image'. 6592 Add 'insert-sliced-image'.
6587 6593
65882004-09-20 Richard M. Stallman <rms@gnu.org> 65942004-09-20 Richard M. Stallman <rms@gnu.org>
6589 6595
@@ -6596,8 +6602,8 @@
6596 6602
65972004-09-07 Luc Teirlinck <teirllm@auburn.edu> 66032004-09-07 Luc Teirlinck <teirllm@auburn.edu>
6598 6604
6599 * locals.texi (Standard Buffer-Local Variables): Add 6605 * locals.texi (Standard Buffer-Local Variables):
6600 `buffer-auto-save-file-format'. 6606 Add `buffer-auto-save-file-format'.
6601 * internals.texi (Buffer Internals): Describe new 6607 * internals.texi (Buffer Internals): Describe new
6602 auto_save_file_format field of the buffer structure. 6608 auto_save_file_format field of the buffer structure.
6603 * files.texi (Format Conversion): `auto-save-file-format' has been 6609 * files.texi (Format Conversion): `auto-save-file-format' has been
@@ -6985,8 +6991,8 @@
6985 6991
69862004-04-05 Jesper Harder <harder@ifa.au.dk> 69922004-04-05 Jesper Harder <harder@ifa.au.dk>
6987 6993
6988 * variables.texi (Variable Aliases): Mention 6994 * variables.texi (Variable Aliases):
6989 cyclic-variable-indirection. 6995 Mention cyclic-variable-indirection.
6990 6996
6991 * errors.texi (Standard Errors): Ditto. 6997 * errors.texi (Standard Errors): Ditto.
6992 6998
@@ -7165,7 +7171,7 @@
7165 7171
71662004-02-07 Jan Djärv <jan.h.d@swipnet.se> 71722004-02-07 Jan Djärv <jan.h.d@swipnet.se>
7167 7173
7168 * positions.texi (Text Lines): Added missing end defun. 7174 * positions.texi (Text Lines): Add missing end defun.
7169 7175
71702004-02-07 Kim F. Storm <storm@cua.dk> 71762004-02-07 Kim F. Storm <storm@cua.dk>
7171 7177
@@ -7188,12 +7194,12 @@
7188 read-minibuffer. 7194 read-minibuffer.
7189 (Minibuffer History): Clarify description of cons values for 7195 (Minibuffer History): Clarify description of cons values for
7190 HISTORY arguments. 7196 HISTORY arguments.
7191 (Basic Completion): Various corrections and clarifications. Add 7197 (Basic Completion): Various corrections and clarifications.
7192 completion-regexp-list. 7198 Add completion-regexp-list.
7193 (Minibuffer Completion): Correct and clarify description of 7199 (Minibuffer Completion): Correct and clarify description of
7194 completing-read. 7200 completing-read.
7195 (Completion Commands): Mention Partial Completion mode. Various 7201 (Completion Commands): Mention Partial Completion mode.
7196 other minor changes. 7202 Various other minor changes.
7197 (High-Level Completion): Various corrections and clarifications. 7203 (High-Level Completion): Various corrections and clarifications.
7198 (Reading File Names): Ditto. 7204 (Reading File Names): Ditto.
7199 (Minibuffer Misc): Ditto. 7205 (Minibuffer Misc): Ditto.
@@ -7268,8 +7274,8 @@
7268 7274
7269 * functions.texi: Various small changes in addition to the 7275 * functions.texi: Various small changes in addition to the
7270 following. 7276 following.
7271 (What Is a Function): `functionp' returns nil for macros. Clarify 7277 (What Is a Function): `functionp' returns nil for macros.
7272 behavior of this and following functions for symbol arguments. 7278 Clarify behavior of this and following functions for symbol arguments.
7273 (Function Documentation): Add `\' in front of (fn @var{arglist}) 7279 (Function Documentation): Add `\' in front of (fn @var{arglist})
7274 and explain why. 7280 and explain why.
7275 (Defining Functions): Mention DOCSTRING argument to `defalias'. 7281 (Defining Functions): Mention DOCSTRING argument to `defalias'.
@@ -8065,7 +8071,7 @@
8065 8071
80662003-01-31 Joe Buehler <jhpb@draco.hekimian.com> 80722003-01-31 Joe Buehler <jhpb@draco.hekimian.com>
8067 8073
8068 * os.texi (System Environment): Added cygwin system-type. 8074 * os.texi (System Environment): Add cygwin system-type.
8069 8075
80702003-01-25 Richard M. Stallman <rms@gnu.org> 80762003-01-25 Richard M. Stallman <rms@gnu.org>
8071 8077
@@ -8098,7 +8104,7 @@
8098 8104
8099 * README: Target for Info file is `make info'. 8105 * README: Target for Info file is `make info'.
8100 8106
8101 * files.texi (File Name Components): Fixed typos in 8107 * files.texi (File Name Components): Fix typos in
8102 `file-name-sans-extension'. 8108 `file-name-sans-extension'.
8103 (Magic File Names): Complete list of operations for magic file 8109 (Magic File Names): Complete list of operations for magic file
8104 name handlers. 8110 name handlers.
@@ -8114,7 +8120,7 @@
8114 8120
81152002-08-05 Per Abrahamsen <abraham@dina.kvl.dk> 81212002-08-05 Per Abrahamsen <abraham@dina.kvl.dk>
8116 8122
8117 * customize.texi (Splicing into Lists): Fixed example. 8123 * customize.texi (Splicing into Lists): Fix example.
8118 Reported by Fabrice Bauzac <fabrice.bauzac@wanadoo.fr>. 8124 Reported by Fabrice Bauzac <fabrice.bauzac@wanadoo.fr>.
8119 8125
81202002-06-17 Juanma Barranquero <lektu@terra.es> 81262002-06-17 Juanma Barranquero <lektu@terra.es>
@@ -8154,8 +8160,8 @@
8154 8160
81552001-11-17 Eli Zaretskii <eliz@is.elta.co.il> 81612001-11-17 Eli Zaretskii <eliz@is.elta.co.il>
8156 8162
8157 * permute-index: Don't depend on csh-specific features. Replace 8163 * permute-index: Don't depend on csh-specific features.
8158 the interpreter name with /bin/sh. 8164 Replace the interpreter name with /bin/sh.
8159 8165
8160 * two-volume-cross-refs.txt: New file. 8166 * two-volume-cross-refs.txt: New file.
8161 * two.el: New file. 8167 * two.el: New file.
@@ -8293,8 +8299,8 @@
8293 * numbers.texi (Integer Basics): Document CL style read syntax for 8299 * numbers.texi (Integer Basics): Document CL style read syntax for
8294 integers in bases other than 10. 8300 integers in bases other than 10.
8295 8301
8296 * positions.texi (List Motion): Document 8302 * positions.texi (List Motion):
8297 open-paren-in-column-0-is-defun-start. 8303 Document open-paren-in-column-0-is-defun-start.
8298 8304
8299 * lists.texi (Sets And Lists): Document member-ignore-case. 8305 * lists.texi (Sets And Lists): Document member-ignore-case.
8300 8306
@@ -8489,7 +8495,7 @@
84891995-06-19 Richard Stallman <rms@mole.gnu.ai.mit.edu> 84951995-06-19 Richard Stallman <rms@mole.gnu.ai.mit.edu>
8490 8496
8491 * Makefile (VERSION): Update version number. 8497 * Makefile (VERSION): Update version number.
8492 (maintainer-clean): Renamed from realclean. 8498 (maintainer-clean): Rename from realclean.
8493 8499
84941995-06-07 Karl Heuer <kwzh@nutrimat.gnu.ai.mit.edu> 85001995-06-07 Karl Heuer <kwzh@nutrimat.gnu.ai.mit.edu>
8495 8501
@@ -8561,11 +8567,11 @@
8561 8567
85621991-11-26 Richard Stallman (rms@mole.gnu.ai.mit.edu) 85681991-11-26 Richard Stallman (rms@mole.gnu.ai.mit.edu)
8563 8569
8564 * Makefile (srcs): Added index.perm. 8570 * Makefile (srcs): Add index.perm.
8565 (elisp.dvi): Remove erroneous shell comment. 8571 (elisp.dvi): Remove erroneous shell comment.
8566 Expect output of permute-index in permuted.fns. 8572 Expect output of permute-index in permuted.fns.
8567 Save old elisp.aux in elisp.oaux. 8573 Save old elisp.aux in elisp.oaux.
8568 (clean): Added index.texi to be deleted. 8574 (clean): Add index.texi to be deleted.
8569 8575
85701990-08-11 Richard Stallman (rms@sugar-bombs.ai.mit.edu) 85761990-08-11 Richard Stallman (rms@sugar-bombs.ai.mit.edu)
8571 8577
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 0ccb4ae04ed..0b6547177e0 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -24,10 +24,11 @@ user. For related topics such as keymaps and syntax tables, see
24* Major Modes:: Defining major modes. 24* Major Modes:: Defining major modes.
25* Minor Modes:: Defining minor modes. 25* Minor Modes:: Defining minor modes.
26* Mode Line Format:: Customizing the text that appears in the mode line. 26* Mode Line Format:: Customizing the text that appears in the mode line.
27* Imenu:: How a mode can provide a menu 27* Imenu:: How a mode can provide a menu
28 of definitions in the buffer. 28 of definitions in the buffer.
29* Font Lock Mode:: How modes can highlight text according to syntax. 29* Font Lock Mode:: How modes can highlight text according to syntax.
30* Desktop Save Mode:: How modes can have buffer state saved between 30* Auto-Indentation:: How to teach Emacs to indent for a major mode.
31* Desktop Save Mode:: How modes can have buffer state saved between
31 Emacs sessions. 32 Emacs sessions.
32@end menu 33@end menu
33 34
@@ -332,7 +333,7 @@ In a major mode for editing some kind of structured text, such as a
332programming language, indentation of text according to structure is 333programming language, indentation of text according to structure is
333probably useful. So the mode should set @code{indent-line-function} 334probably useful. So the mode should set @code{indent-line-function}
334to a suitable function, and probably customize other variables 335to a suitable function, and probably customize other variables
335for indentation. 336for indentation. @xref{Auto-Indentation}.
336 337
337@item 338@item
338@cindex keymaps in modes 339@cindex keymaps in modes
@@ -3214,6 +3215,665 @@ Since this function is called after every buffer change, it should be
3214reasonably fast. 3215reasonably fast.
3215@end defvar 3216@end defvar
3216 3217
3218@node Auto-Indentation
3219@section Auto-indention of code
3220
3221For programming languages, an important feature of a major mode is to
3222provide automatic indentation. This is controlled in Emacs by
3223@code{indent-line-function} (@pxref{Mode-Specific Indent}).
3224Writing a good indentation function can be difficult and to a large
3225extent it is still a black art.
3226
3227Many major mode authors will start by writing a simple indentation
3228function that works for simple cases, for example by comparing with the
3229indentation of the previous text line. For most programming languages
3230that are not really line-based, this tends to scale very poorly:
3231improving such a function to let it handle more diverse situations tends
3232to become more and more difficult, resulting in the end with a large,
3233complex, unmaintainable indentation function which nobody dares to touch.
3234
3235A good indentation function will usually need to actually parse the
3236text, according to the syntax of the language. Luckily, it is not
3237necessary to parse the text in as much detail as would be needed
3238for a compiler, but on the other hand, the parser embedded in the
3239indentation code will want to be somewhat friendly to syntactically
3240incorrect code.
3241
3242Good maintainable indentation functions usually fall into 2 categories:
3243either parsing forward from some ``safe'' starting point until the
3244position of interest, or parsing backward from the position of interest.
3245Neither of the two is a clearly better choice than the other: parsing
3246backward is often more difficult than parsing forward because
3247programming languages are designed to be parsed forward, but for the
3248purpose of indentation it has the advantage of not needing to
3249guess a ``safe'' starting point, and it generally enjoys the property
3250that only a minimum of text will be analyzed to decide the indentation
3251of a line, so indentation will tend to be unaffected by syntax errors in
3252some earlier unrelated piece of code. Parsing forward on the other hand
3253is usually easier and has the advantage of making it possible to
3254reindent efficiently a whole region at a time, with a single parse.
3255
3256Rather than write your own indentation function from scratch, it is
3257often preferable to try and reuse some existing ones or to rely
3258on a generic indentation engine. There are sadly few such
3259engines. The CC-mode indentation code (used with C, C++, Java, Awk
3260and a few other such modes) has been made more generic over the years,
3261so if your language seems somewhat similar to one of those languages,
3262you might try to use that engine. @c FIXME: documentation?
3263Another one is SMIE which takes an approach in the spirit
3264of Lisp sexps and adapts it to non-Lisp languages.
3265
3266@menu
3267* SMIE:: A simple minded indentation engine
3268@end menu
3269
3270@node SMIE
3271@subsection Simple Minded Indentation Engine
3272
3273SMIE is a package that provides a generic navigation and indentation
3274engine. Based on a very simple parser using an ``operator precedence
3275grammar'', it lets major modes extend the sexp-based navigation of Lisp
3276to non-Lisp languages as well as provide a simple to use but reliable
3277auto-indentation.
3278
3279Operator precedence grammar is a very primitive technology for parsing
3280compared to some of the more common techniques used in compilers.
3281It has the following characteristics: its parsing power is very limited,
3282and it is largely unable to detect syntax errors, but it has the
3283advantage of being algorithmically efficient and able to parse forward
3284just as well as backward. In practice that means that SMIE can use it
3285for indentation based on backward parsing, that it can provide both
3286@code{forward-sexp} and @code{backward-sexp} functionality, and that it
3287will naturally work on syntactically incorrect code without any extra
3288effort. The downside is that it also means that most programming
3289languages cannot be parsed correctly using SMIE, at least not without
3290resorting to some special tricks (@pxref{SMIE Tricks}).
3291
3292@menu
3293* SMIE setup:: SMIE setup and features
3294* Operator Precedence Grammars:: A very simple parsing technique
3295* SMIE Grammar:: Defining the grammar of a language
3296* SMIE Lexer:: Defining tokens
3297* SMIE Tricks:: Working around the parser's limitations
3298* SMIE Indentation:: Specifying indentation rules
3299* SMIE Indentation Helpers:: Helper functions for indentation rules
3300* SMIE Indentation Example:: Sample indentation rules
3301@end menu
3302
3303@node SMIE setup
3304@subsubsection SMIE Setup and Features
3305
3306SMIE is meant to be a one-stop shop for structural navigation and
3307various other features which rely on the syntactic structure of code, in
3308particular automatic indentation. The main entry point is
3309@code{smie-setup} which is a function typically called while setting
3310up a major mode.
3311
3312@defun smie-setup grammar rules-function &rest keywords
3313Setup SMIE navigation and indentation.
3314@var{grammar} is a grammar table generated by @code{smie-prec2->grammar}.
3315@var{rules-function} is a set of indentation rules for use on
3316@code{smie-rules-function}.
3317@var{keywords} are additional arguments, which can include the following
3318keywords:
3319@itemize
3320@item
3321@code{:forward-token} @var{fun}: Specify the forward lexer to use.
3322@item
3323@code{:backward-token} @var{fun}: Specify the backward lexer to use.
3324@end itemize
3325@end defun
3326
3327Calling this function is sufficient to make commands such as
3328@code{forward-sexp}, @code{backward-sexp}, and @code{transpose-sexps} be
3329able to properly handle structural elements other than just the paired
3330parentheses already handled by syntax tables. For example, if the
3331provided grammar is precise enough, @code{transpose-sexps} can correctly
3332transpose the two arguments of a @code{+} operator, taking into account
3333the precedence rules of the language.
3334
3335Calling `smie-setup' is also sufficient to make TAB indentation work in
3336the expected way, and provides some commands that you can bind in the
3337major mode keymap.
3338
3339@deffn Command smie-close-block
3340This command closes the most recently opened (and not yet closed) block.
3341@end deffn
3342
3343@deffn Command smie-down-list &optional arg
3344This command is like @code{down-list} but it also pays attention to
3345nesting of tokens other than parentheses, such as @code{begin...end}.
3346@end deffn
3347
3348@node Operator Precedence Grammars
3349@subsubsection Operator Precedence Grammars
3350
3351SMIE's precedence grammars simply give to each token a pair of
3352precedences: the left-precedence and the right-precedence. We say
3353@code{T1 < T2} if the right-precedence of token @code{T1} is less than
3354the left-precedence of token @code{T2}. A good way to read this
3355@code{<} is as a kind of parenthesis: if we find @code{... T1 something
3356T2 ...} then that should be parsed as @code{... T1 (something T2 ...}
3357rather than as @code{... T1 something) T2 ...}. The latter
3358interpretation would be the case if we had @code{T1 > T2}. If we have
3359@code{T1 = T2}, it means that token T2 follows token T1 in the same
3360syntactic construction, so typically we have @code{"begin" = "end"}.
3361Such pairs of precedences are sufficient to express left-associativity
3362or right-associativity of infix operators, nesting of tokens like
3363parentheses and many other cases.
3364
3365@c ¡Let's leave this undocumented to leave it more open for change!
3366@c @defvar smie-grammar
3367@c The value of this variable is an alist specifying the left and right
3368@c precedence of each token. It is meant to be initialized by using one of
3369@c the functions below.
3370@c @end defvar
3371
3372@defun smie-prec2->grammar table
3373This function takes a @emph{prec2} grammar @var{table} and returns an
3374alist suitable for use in @code{smie-setup}. The @emph{prec2}
3375@var{table} is itself meant to be built by one of the functions below.
3376@end defun
3377
3378@defun smie-merge-prec2s &rest tables
3379This function takes several @emph{prec2} @var{tables} and merges them
3380into a new @emph{prec2} table.
3381@end defun
3382
3383@defun smie-precs->prec2 precs
3384This function builds a @emph{prec2} table from a table of precedences
3385@var{precs}. @var{precs} should be a list, sorted by precedence (for
3386example @code{"+"} will come before @code{"*"}), of elements of the form
3387@code{(@var{assoc} @var{op} ...)}, where each @var{op} is a token that
3388acts as an operator; @var{assoc} is their associativity, which can be
3389either @code{left}, @code{right}, @code{assoc}, or @code{nonassoc}.
3390All operators in a given element share the same precedence level
3391and associativity.
3392@end defun
3393
3394@defun smie-bnf->prec2 bnf &rest resolvers
3395This function lets you specify the grammar using a BNF notation.
3396It accepts a @var{bnf} description of the grammar along with a set of
3397conflict resolution rules @var{resolvers}, and
3398returns a @emph{prec2} table.
3399
3400@var{bnf} is a list of nonterminal definitions of the form
3401@code{(@var{nonterm} @var{rhs1} @var{rhs2} ...)} where each @var{rhs}
3402is a (non-empty) list of terminals (aka tokens) or non-terminals.
3403
3404Not all grammars are accepted:
3405@itemize
3406@item
3407An @var{rhs} cannot be an empty list (an empty list is never needed,
3408since SMIE allows all non-terminals to match the empty string anyway).
3409@item
3410An @var{rhs} cannot have 2 consecutive non-terminals: each pair of
3411non-terminals needs to be separated by a terminal (aka token).
3412This is a fundamental limitation of operator precedence grammars.
3413@end itemize
3414
3415Additionally, conflicts can occur:
3416@itemize
3417@item
3418The returned @emph{prec2} table holds constraints between pairs of tokens, and
3419for any given pair only one constraint can be present: T1 < T2,
3420T1 = T2, or T1 > T2.
3421@item
3422A token can be an @code{opener} (something similar to an open-paren),
3423a @code{closer} (like a close-paren), or @code{neither} of the two
3424(e.g. an infix operator, or an inner token like @code{"else"}).
3425@end itemize
3426
3427Precedence conflicts can be resolved via @var{resolvers}, which
3428is a list of @emph{precs} tables (see @code{smie-precs->prec2}): for
3429each precedence conflict, if those @code{precs} tables
3430specify a particular constraint, then the conflict is resolved by using
3431this constraint instead, else a conflict is reported and one of the
3432conflicting constraints is picked arbitrarily and the others are
3433simply ignored.
3434@end defun
3435
3436@node SMIE Grammar
3437@subsubsection Defining the Grammar of a Language
3438
3439The usual way to define the SMIE grammar of a language is by
3440defining a new global variable that holds the precedence table by
3441giving a set of BNF rules.
3442For example, the grammar definition for a small Pascal-like language
3443could look like:
3444@example
3445@group
3446(require 'smie)
3447(defvar sample-smie-grammar
3448 (smie-prec2->grammar
3449 (smie-bnf->prec2
3450@end group
3451@group
3452 '((id)
3453 (inst ("begin" insts "end")
3454 ("if" exp "then" inst "else" inst)
3455 (id ":=" exp)
3456 (exp))
3457 (insts (insts ";" insts) (inst))
3458 (exp (exp "+" exp)
3459 (exp "*" exp)
3460 ("(" exps ")"))
3461 (exps (exps "," exps) (exp)))
3462@end group
3463@group
3464 '((assoc ";"))
3465 '((assoc ","))
3466 '((assoc "+") (assoc "*")))))
3467@end group
3468@end example
3469
3470@noindent
3471A few things to note:
3472
3473@itemize
3474@item
3475The above grammar does not explicitly mention the syntax of function
3476calls: SMIE will automatically allow any sequence of sexps, such as
3477identifiers, balanced parentheses, or @code{begin ... end} blocks
3478to appear anywhere anyway.
3479@item
3480The grammar category @code{id} has no right hand side: this does not
3481mean that it can match only the empty string, since as mentioned any
3482sequence of sexps can appear anywhere anyway.
3483@item
3484Because non terminals cannot appear consecutively in the BNF grammar, it
3485is difficult to correctly handle tokens that act as terminators, so the
3486above grammar treats @code{";"} as a statement @emph{separator} instead,
3487which SMIE can handle very well.
3488@item
3489Separators used in sequences (such as @code{","} and @code{";"} above)
3490are best defined with BNF rules such as @code{(foo (foo "separator" foo) ...)}
3491which generate precedence conflicts which are then resolved by giving
3492them an explicit @code{(assoc "separator")}.
3493@item
3494The @code{("(" exps ")")} rule was not needed to pair up parens, since
3495SMIE will pair up any characters that are marked as having paren syntax
3496in the syntax table. What this rule does instead (together with the
3497definition of @code{exps}) is to make it clear that @code{","} should
3498not appear outside of parentheses.
3499@item
3500Rather than have a single @emph{precs} table to resolve conflicts, it is
3501preferable to have several tables, so as to let the BNF part of the
3502grammar specify relative precedences where possible.
3503@item
3504Unless there is a very good reason to prefer @code{left} or
3505@code{right}, it is usually preferable to mark operators as associative,
3506using @code{assoc}. For that reason @code{"+"} and @code{"*"} are
3507defined above as @code{assoc}, although the language defines them
3508formally as left associative.
3509@end itemize
3510
3511@node SMIE Lexer
3512@subsubsection Defining Tokens
3513
3514SMIE comes with a predefined lexical analyzer which uses syntax tables
3515in the following way: any sequence of characters that have word or
3516symbol syntax is considered a token, and so is any sequence of
3517characters that have punctuation syntax. This default lexer is
3518often a good starting point but is rarely actually correct for any given
3519language. For example, it will consider @code{"2,+3"} to be composed
3520of 3 tokens: @code{"2"}, @code{",+"}, and @code{"3"}.
3521
3522To describe the lexing rules of your language to SMIE, you need
35232 functions, one to fetch the next token, and another to fetch the
3524previous token. Those functions will usually first skip whitespace and
3525comments and then look at the next chunk of text to see if it
3526is a special token. If so it should skip the token and
3527return a description of this token. Usually this is simply the string
3528extracted from the buffer, but it can be anything you want.
3529For example:
3530@example
3531@group
3532(defvar sample-keywords-regexp
3533 (regexp-opt '("+" "*" "," ";" ">" ">=" "<" "<=" ":=" "=")))
3534@end group
3535@group
3536(defun sample-smie-forward-token ()
3537 (forward-comment (point-max))
3538 (cond
3539 ((looking-at sample-keywords-regexp)
3540 (goto-char (match-end 0))
3541 (match-string-no-properties 0))
3542 (t (buffer-substring-no-properties
3543 (point)
3544 (progn (skip-syntax-forward "w_")
3545 (point))))))
3546@end group
3547@group
3548(defun sample-smie-backward-token ()
3549 (forward-comment (- (point)))
3550 (cond
3551 ((looking-back sample-keywords-regexp (- (point) 2) t)
3552 (goto-char (match-beginning 0))
3553 (match-string-no-properties 0))
3554 (t (buffer-substring-no-properties
3555 (point)
3556 (progn (skip-syntax-backward "w_")
3557 (point))))))
3558@end group
3559@end example
3560
3561Notice how those lexers return the empty string when in front of
3562parentheses. This is because SMIE automatically takes care of the
3563parentheses defined in the syntax table. More specifically if the lexer
3564returns nil or an empty string, SMIE tries to handle the corresponding
3565text as a sexp according to syntax tables.
3566
3567@node SMIE Tricks
3568@subsubsection Living With a Weak Parser
3569
3570The parsing technique used by SMIE does not allow tokens to behave
3571differently in different contexts. For most programming languages, this
3572manifests itself by precedence conflicts when converting the
3573BNF grammar.
3574
3575Sometimes, those conflicts can be worked around by expressing the
3576grammar slightly differently. For example, for Modula-2 it might seem
3577natural to have a BNF grammar that looks like this:
3578
3579@example
3580 ...
3581 (inst ("IF" exp "THEN" insts "ELSE" insts "END")
3582 ("CASE" exp "OF" cases "END")
3583 ...)
3584 (cases (cases "|" cases) (caselabel ":" insts) ("ELSE" insts))
3585 ...
3586@end example
3587
3588But this will create conflicts for @code{"ELSE"}: on the one hand, the
3589IF rule implies (among many other things) that @code{"ELSE" = "END"};
3590but on the other hand, since @code{"ELSE"} appears within @code{cases},
3591which appears left of @code{"END"}, we also have @code{"ELSE" > "END"}.
3592We can solve the conflict either by using:
3593@example
3594 ...
3595 (inst ("IF" exp "THEN" insts "ELSE" insts "END")
3596 ("CASE" exp "OF" cases "END")
3597 ("CASE" exp "OF" cases "ELSE" insts "END")
3598 ...)
3599 (cases (cases "|" cases) (caselabel ":" insts))
3600 ...
3601@end example
3602or
3603@example
3604 ...
3605 (inst ("IF" exp "THEN" else "END")
3606 ("CASE" exp "OF" cases "END")
3607 ...)
3608 (else (insts "ELSE" insts))
3609 (cases (cases "|" cases) (caselabel ":" insts) (else))
3610 ...
3611@end example
3612
3613Reworking the grammar to try and solve conflicts has its downsides, tho,
3614because SMIE assumes that the grammar reflects the logical structure of
3615the code, so it is preferable to keep the BNF closer to the intended
3616abstract syntax tree.
3617
3618Other times, after careful consideration you may conclude that those
3619conflicts are not serious and simply resolve them via the
3620@var{resolvers} argument of @code{smie-bnf->prec2}. Usually this is
3621because the grammar is simply ambiguous: the conflict does not affect
3622the set of programs described by the grammar, but only the way those
3623programs are parsed. This is typically the case for separators and
3624associative infix operators, where you want to add a resolver like
3625@code{'((assoc "|"))}. Another case where this can happen is for the
3626classic @emph{dangling else} problem, where you will use @code{'((assoc
3627"else" "then"))}. It can also happen for cases where the conflict is
3628real and cannot really be resolved, but it is unlikely to pose a problem
3629in practice.
3630
3631Finally, in many cases some conflicts will remain despite all efforts to
3632restructure the grammar. Do not despair: while the parser cannot be
3633made more clever, you can make the lexer as smart as you want. So, the
3634solution is then to look at the tokens involved in the conflict and to
3635split one of those tokens into 2 (or more) different tokens. E.g. if
3636the grammar needs to distinguish between two incompatible uses of the
3637token @code{"begin"}, make the lexer return different tokens (say
3638@code{"begin-fun"} and @code{"begin-plain"}) depending on which kind of
3639@code{"begin"} it finds. This pushes the work of distinguishing the
3640different cases to the lexer, which will thus have to look at the
3641surrounding text to find ad-hoc clues.
3642
3643@node SMIE Indentation
3644@subsubsection Specifying Indentation Rules
3645
3646Based on the provided grammar, SMIE will be able to provide automatic
3647indentation without any extra effort. But in practice, this default
3648indentation style will probably not be good enough. You will want to
3649tweak it in many different cases.
3650
3651SMIE indentation is based on the idea that indentation rules should be
3652as local as possible. To this end, it relies on the idea of
3653@emph{virtual} indentation, which is the indentation that a particular
3654program point would have if it were at the beginning of a line.
3655Of course, if that program point is indeed at the beginning of a line,
3656its virtual indentation is its current indentation. But if not, then
3657SMIE uses the indentation algorithm to compute the virtual indentation
3658of that point. Now in practice, the virtual indentation of a program
3659point does not have to be identical to the indentation it would have if
3660we inserted a newline before it. To see how this works, the SMIE rule
3661for indentation after a @code{@{} in C does not care whether the
3662@code{@{} is standing on a line of its own or is at the end of the
3663preceding line. Instead, these different cases are handled in the
3664indentation rule that decides how to indent before a @code{@{}.
3665
3666Another important concept is the notion of @emph{parent}: The
3667@emph{parent} of a token, is the head token of the nearest enclosing
3668syntactic construct. For example, the parent of an @code{else} is the
3669@code{if} to which it belongs, and the parent of an @code{if}, in turn,
3670is the lead token of the surrounding construct. The command
3671@code{backward-sexp} jumps from a token to its parent, but there are
3672some caveats: for @emph{openers} (tokens which start a construct, like
3673@code{if}), you need to start with point before the token, while for
3674others you need to start with point after the token.
3675@code{backward-sexp} stops with point before the parent token if that is
3676the @emph{opener} of the token of interest, and otherwise it stops with
3677point after the parent token.
3678
3679SMIE indentation rules are specified using a function that takes two
3680arguments @var{method} and @var{arg} where the meaning of @var{arg} and the
3681expected return value depend on @var{method}.
3682
3683@var{method} can be:
3684@itemize
3685@item
3686@code{:after}, in which case @var{arg} is a token and the function
3687should return the @var{offset} to use for indentation after @var{arg}.
3688@item
3689@code{:before}, in which case @var{arg} is a token and the function
3690should return the @var{offset} to use to indent @var{arg} itself.
3691@item
3692@code{:elem}, in which case the function should return either the offset
3693to use to indent function arguments (if @var{arg} is the symbol
3694@code{arg}) or the basic indentation step (if @var{arg} is the symbol
3695@code{basic}).
3696@item
3697@code{:list-intro}, in which case @var{arg} is a token and the function
3698should return non-@code{nil} if the token is followed by a list of
3699expressions (not separated by any token) rather than an expression.
3700@end itemize
3701
3702When @var{arg} is a token, the function is called with point just before
3703that token. A return value of nil always means to fallback on the
3704default behavior, so the function should return nil for arguments it
3705does not expect.
3706
3707@var{offset} can be:
3708@itemize
3709@item
3710@code{nil}: use the default indentation rule.
3711@item
3712@code{(column . @var{column})}: indent to column @var{column}.
3713@item
3714@var{number}: offset by @var{number}, relative to a base token which is
3715the current token for @code{:after} and its parent for @code{:before}.
3716@end itemize
3717
3718@node SMIE Indentation Helpers
3719@subsubsection Helper Functions for Indentation Rules
3720
3721SMIE provides various functions designed specifically for use in the
3722indentation rules function (several of those functions break if used in
3723another context). These functions all start with the prefix
3724@code{smie-rule-}.
3725
3726@defun smie-rule-bolp
3727Return non-@code{nil} if the current token is the first on the line.
3728@end defun
3729
3730@defun smie-rule-hanging-p
3731Return non-@code{nil} if the current token is @emph{hanging}.
3732A token is @emph{hanging} if it is the last token on the line
3733and if it is preceded by other tokens: a lone token on a line is not
3734hanging.
3735@end defun
3736
3737@defun smie-rule-next-p &rest tokens
3738Return non-@code{nil} if the next token is among @var{tokens}.
3739@end defun
3740
3741@defun smie-rule-prev-p &rest tokens
3742Return non-@code{nil} if the previous token is among @var{tokens}.
3743@end defun
3744
3745@defun smie-rule-parent-p &rest parents
3746Return non-@code{nil} if the current token's parent is among @var{parents}.
3747@end defun
3748
3749@defun smie-rule-sibling-p
3750Return non-nil if the current token's parent is actually a sibling.
3751This is the case for example when the parent of a @code{","} is just the
3752previous @code{","}.
3753@end defun
3754
3755@defun smie-rule-parent &optional offset
3756Return the proper offset to align the current token with the parent.
3757If non-@code{nil}, @var{offset} should be an integer giving an
3758additional offset to apply.
3759@end defun
3760
3761@defun smie-rule-separator method
3762Indent current token as a @emph{separator}.
3763
3764By @emph{separator}, we mean here a token whose sole purpose is to
3765separate various elements within some enclosing syntactic construct, and
3766which does not have any semantic significance in itself (i.e. it would
3767typically not exist as a node in an abstract syntax tree).
3768
3769Such a token is expected to have an associative syntax and be closely
3770tied to its syntactic parent. Typical examples are @code{","} in lists
3771of arguments (enclosed inside parentheses), or @code{";"} in sequences
3772of instructions (enclosed in a @code{@{...@}} or @code{begin...end}
3773block).
3774
3775@var{method} should be the method name that was passed to
3776`smie-rules-function'.
3777@end defun
3778
3779@node SMIE Indentation Example
3780@subsubsection Sample Indentation Rules
3781
3782Here is an example of an indentation function:
3783
3784@example
3785(eval-when-compile (require 'cl)) ;For the `case' macro.
3786(defun sample-smie-rules (kind token)
3787 (case kind
3788 (:elem (case token
3789 (basic sample-indent-basic)))
3790 (:after
3791 (cond
3792 ((equal token ",") (smie-rule-separator kind))
3793 ((equal token ":=") sample-indent-basic)))
3794 (:before
3795 (cond
3796 ((equal token ",") (smie-rule-separator kind))
3797 ((member token '("begin" "(" "@{"))
3798 (if (smie-rule-hanging-p) (smie-rule-parent)))
3799 ((equal token "if")
3800 (and (not (smie-rule-bolp)) (smie-rule-prev-p "else")
3801 (smie-rule-parent)))))))
3802@end example
3803
3804@noindent
3805A few things to note:
3806
3807@itemize
3808@item
3809The first case indicates the basic indentation increment to use.
3810If @code{sample-indent-basic} is nil, then SMIE uses the global
3811setting @code{smie-indent-basic}. The major mode could have set
3812@code{smie-indent-basic} buffer-locally instead, but that
3813is discouraged.
3814
3815@item
3816The two (identical) rules for the token @code{","} make SMIE try to be
3817more clever when the comma separator is placed at the beginning of
3818lines. It tries to outdent the separator so as to align the code after
3819the comma; for example:
3820
3821@example
3822x = longfunctionname (
3823 arg1
3824 , arg2
3825 );
3826@end example
3827
3828@item
3829The rule for indentation after @code{":="} exists because otherwise
3830SMIE would treat @code{":="} as an infix operator and would align the
3831right argument with the left one.
3832
3833@item
3834The rule for indentation before @code{"begin"} is an example of the use
3835of virtual indentation: This rule is used only when @code{"begin"} is
3836hanging, which can happen only when @code{"begin"} is not at the
3837beginning of a line. So this is not used when indenting
3838@code{"begin"} itself but only when indenting something relative to this
3839@code{"begin"}. Concretely, this rule changes the indentation from:
3840
3841@example
3842 if x > 0 then begin
3843 dosomething(x);
3844 end
3845@end example
3846to
3847@example
3848 if x > 0 then begin
3849 dosomething(x);
3850 end
3851@end example
3852
3853@item
3854The rule for indentation before @code{"if"} is similar to the one for
3855@code{"begin"}, but where the purpose is to treat @code{"else if"}
3856as a single unit, so as to align a sequence of tests rather than indent
3857each test further to the right. This function does this only in the
3858case where the @code{"if"} is not placed on a separate line, hence the
3859@code{smie-rule-bolp} test.
3860
3861If we know that the @code{"else"} is always aligned with its @code{"if"}
3862and is always at the beginning of a line, we can use a more efficient
3863rule:
3864@example
3865((equal token "if")
3866 (and (not (smie-rule-bolp)) (smie-rule-prev-p "else")
3867 (save-excursion
3868 (sample-smie-backward-token) ;Jump before the "else".
3869 (cons 'column (current-column)))))
3870@end example
3871
3872The advantage of this formulation is that it reuses the indentation of
3873the previous @code{"else"}, rather than going all the way back to the
3874first @code{"if"} of the sequence.
3875@end itemize
3876
3217@node Desktop Save Mode 3877@node Desktop Save Mode
3218@section Desktop Save Mode 3878@section Desktop Save Mode
3219@cindex desktop save mode 3879@cindex desktop save mode
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 4da94dacd71..3b08b472b06 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -2209,7 +2209,7 @@ various commands) to indent the current line. The command
2209 2209
2210In Lisp mode, the value is the symbol @code{lisp-indent-line}; in C 2210In Lisp mode, the value is the symbol @code{lisp-indent-line}; in C
2211mode, @code{c-indent-line}; in Fortran mode, @code{fortran-indent-line}. 2211mode, @code{c-indent-line}; in Fortran mode, @code{fortran-indent-line}.
2212The default value is @code{indent-relative}. 2212The default value is @code{indent-relative}. @xref{Auto-Indentation}.
2213@end defvar 2213@end defvar
2214 2214
2215@deffn Command indent-according-to-mode 2215@deffn Command indent-according-to-mode