diff options
| author | Stefan Monnier | 2010-12-07 14:44:38 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2010-12-07 14:44:38 -0500 |
| commit | 5dcb4c4e5d757099766f7147eace43f0b00c7fe4 (patch) | |
| tree | 0946d18220c48c9ba792ee2f4ce1b50726e9de17 /doc | |
| parent | 2b815743b24c79ae63863bd0f0ffcaf822d400a1 (diff) | |
| download | emacs-5dcb4c4e5d757099766f7147eace43f0b00c7fe4.tar.gz emacs-5dcb4c4e5d757099766f7147eace43f0b00c7fe4.zip | |
* doc/lispref/modes.texi (Auto-Indentation): New section to document SMIE.
(Major Mode Conventions):
* doc/lispref/text.texi (Mode-Specific Indent): Refer to it.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/ChangeLog | 206 | ||||
| -rw-r--r-- | doc/lispref/modes.texi | 668 | ||||
| -rw-r--r-- | doc/lispref/text.texi | 2 |
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 @@ | |||
| 1 | 2010-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 | |||
| 1 | 2010-12-04 Eli Zaretskii <eliz@gnu.org> | 7 | 2010-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 | ||
| 13 | 2010-11-21 Chong Yidong <cyd@stupidchicken.com> | 19 | 2010-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 | ||
| 50 | 2010-11-10 Glenn Morris <rgm@gnu.org> | 56 | 2010-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 | ||
| 284 | 2009-12-05 Glenn Morris <rgm@gnu.org> | 290 | 2009-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 @@ | |||
| 831 | 2009-05-09 Eli Zaretskii <eliz@gnu.org> | 837 | 2009-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 | ||
| 838 | 2009-05-09 Martin Rudalics <rudalics@gmx.at> | 844 | 2009-05-09 Martin Rudalics <rudalics@gmx.at> |
| @@ -874,8 +880,8 @@ | |||
| 874 | 880 | ||
| 875 | 2009-04-22 Chong Yidong <cyd@stupidchicken.com> | 881 | 2009-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 @@ | |||
| 951 | 2009-04-09 Chong Yidong <cyd@stupidchicken.com> | 957 | 2009-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 | ||
| 1020 | 2009-03-29 Chong Yidong <cyd@stupidchicken.com> | 1026 | 2009-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 @@ | |||
| 1063 | 2009-03-23 Chong Yidong <cyd@stupidchicken.com> | 1069 | 2009-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 | ||
| 1070 | 2009-03-22 Alan Mackenzie <acm@muc.de> | 1076 | 2009-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 | ||
| 1125 | 2009-03-10 Chong Yidong <cyd@stupidchicken.com> | 1131 | 2009-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 @@ | |||
| 1260 | 2009-01-22 Chong Yidong <cyd@stupidchicken.com> | 1266 | 2009-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 | ||
| 1266 | 2009-01-19 Chong Yidong <cyd@stupidchicken.com> | 1272 | 2009-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 | ||
| 1335 | 2009-01-09 Chong Yidong <cyd@stupidchicken.com> | 1341 | 2009-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 | ||
| 1366 | 2009-01-08 Jason Rumney <jasonr@gnu.org> | 1372 | 2009-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 @@ | |||
| 1661 | 2008-11-01 Eli Zaretskii <eliz@gnu.org> | 1667 | 2008-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 | ||
| 1667 | 2008-10-28 Chong Yidong <cyd@stupidchicken.com> | 1673 | 2008-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 | ||
| 1781 | 2008-10-18 Martin Rudalics <rudalics@gmx.at> | 1787 | 2008-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 | ||
| 2144 | 2007-12-30 Richard Stallman <rms@gnu.org> | 2150 | 2007-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 | ||
| 2149 | 2007-12-28 Richard Stallman <rms@gnu.org> | 2155 | 2007-12-28 Richard Stallman <rms@gnu.org> |
| @@ -2187,8 +2193,8 @@ | |||
| 2187 | 2193 | ||
| 2188 | 2007-11-29 Glenn Morris <rgm@gnu.org> | 2194 | 2007-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 | ||
| 2193 | 2007-11-26 Juanma Barranquero <lekktu@gmail.com> | 2199 | 2007-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 | ||
| 2396 | 2007-08-16 Richard Stallman <rms@gnu.org> | 2402 | 2007-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 | ||
| 2401 | 2007-08-08 Martin Rudalics <rudalics@gmx.at> | 2407 | 2007-08-08 Martin Rudalics <rudalics@gmx.at> |
| 2402 | 2408 | ||
| @@ -2463,8 +2469,8 @@ | |||
| 2463 | 2469 | ||
| 2464 | 2007-06-27 Richard Stallman <rms@gnu.org> | 2470 | 2007-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 | ||
| 2469 | 2007-06-27 Michael Albinus <michael.albinus@gmx.de> | 2475 | 2007-06-27 Michael Albinus <michael.albinus@gmx.de> |
| 2470 | 2476 | ||
| @@ -2519,8 +2525,8 @@ | |||
| 2519 | 2525 | ||
| 2520 | 2007-05-30 Nick Roberts <nickrob@snap.net.nz> | 2526 | 2007-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 | ||
| 2526 | 2007-06-02 Richard Stallman <rms@gnu.org> | 2532 | 2007-06-02 Richard Stallman <rms@gnu.org> |
| @@ -2926,8 +2932,8 @@ | |||
| 2926 | 2932 | ||
| 2927 | 2007-03-05 Richard Stallman <rms@gnu.org> | 2933 | 2007-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 | ||
| 2932 | 2007-03-04 Richard Stallman <rms@gnu.org> | 2938 | 2007-03-04 Richard Stallman <rms@gnu.org> |
| 2933 | 2939 | ||
| @@ -2998,8 +3004,8 @@ | |||
| 2998 | 2007-02-03 Eli Zaretskii <eliz@gnu.org> | 3004 | 2007-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 | ||
| 3005 | 2007-02-02 Eli Zaretskii <eliz@gnu.org> | 3011 | 2007-02-02 Eli Zaretskii <eliz@gnu.org> |
| @@ -3086,8 +3092,8 @@ | |||
| 3086 | 3092 | ||
| 3087 | 2006-12-24 Richard Stallman <rms@gnu.org> | 3093 | 2006-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 | ||
| 3092 | 2006-12-19 Kim F. Storm <storm@cua.dk> | 3098 | 2006-12-19 Kim F. Storm <storm@cua.dk> |
| 3093 | 3099 | ||
| @@ -3386,8 +3392,8 @@ | |||
| 3386 | 3392 | ||
| 3387 | 2006-09-01 Chong Yidong <cyd@stupidchicken.com> | 3393 | 2006-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 | ||
| 3392 | 2006-08-31 Richard Stallman <rms@gnu.org> | 3398 | 2006-08-31 Richard Stallman <rms@gnu.org> |
| 3393 | 3399 | ||
| @@ -3449,7 +3455,7 @@ | |||
| 3449 | 2006-08-12 Chong Yidong <cyd@stupidchicken.com> | 3455 | 2006-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 | ||
| 3980 | 2006-05-25 Chong Yidong <cyd@stupidchicken.com> | 3986 | 2006-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 | ||
| 4029 | 2006-05-15 Oliver Scholz <epameinondas@gmx.de> (tiny change) | 4035 | 2006-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 | ||
| 4034 | 2006-05-14 Richard Stallman <rms@gnu.org> | 4040 | 2006-05-14 Richard Stallman <rms@gnu.org> |
| 4035 | 4041 | ||
| @@ -4079,8 +4085,8 @@ | |||
| 4079 | 4085 | ||
| 4080 | 2006-05-09 Richard Stallman <rms@gnu.org> | 4086 | 2006-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 | ||
| 4085 | 2006-05-07 Kim F. Storm <storm@cua.dk> | 4091 | 2006-05-07 Kim F. Storm <storm@cua.dk> |
| 4086 | 4092 | ||
| @@ -4564,8 +4570,8 @@ | |||
| 4564 | 4570 | ||
| 4565 | 2005-12-03 Eli Zaretskii <eliz@gnu.org> | 4571 | 2005-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 | ||
| 4570 | 2005-11-27 Richard M. Stallman <rms@gnu.org> | 4576 | 2005-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 | ||
| 4794 | 2005-09-06 Richard M. Stallman <rms@gnu.org> | 4800 | 2005-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 | ||
| 6588 | 2004-09-20 Richard M. Stallman <rms@gnu.org> | 6594 | 2004-09-20 Richard M. Stallman <rms@gnu.org> |
| 6589 | 6595 | ||
| @@ -6596,8 +6602,8 @@ | |||
| 6596 | 6602 | ||
| 6597 | 2004-09-07 Luc Teirlinck <teirllm@auburn.edu> | 6603 | 2004-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 | ||
| 6986 | 2004-04-05 Jesper Harder <harder@ifa.au.dk> | 6992 | 2004-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 | ||
| 7166 | 2004-02-07 Jan Djärv <jan.h.d@swipnet.se> | 7172 | 2004-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 | ||
| 7170 | 2004-02-07 Kim F. Storm <storm@cua.dk> | 7176 | 2004-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 | ||
| 8066 | 2003-01-31 Joe Buehler <jhpb@draco.hekimian.com> | 8072 | 2003-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 | ||
| 8070 | 2003-01-25 Richard M. Stallman <rms@gnu.org> | 8076 | 2003-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 | ||
| 8115 | 2002-08-05 Per Abrahamsen <abraham@dina.kvl.dk> | 8121 | 2002-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 | ||
| 8120 | 2002-06-17 Juanma Barranquero <lektu@terra.es> | 8126 | 2002-06-17 Juanma Barranquero <lektu@terra.es> |
| @@ -8154,8 +8160,8 @@ | |||
| 8154 | 8160 | ||
| 8155 | 2001-11-17 Eli Zaretskii <eliz@is.elta.co.il> | 8161 | 2001-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 @@ | |||
| 8489 | 1995-06-19 Richard Stallman <rms@mole.gnu.ai.mit.edu> | 8495 | 1995-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 | ||
| 8494 | 1995-06-07 Karl Heuer <kwzh@nutrimat.gnu.ai.mit.edu> | 8500 | 1995-06-07 Karl Heuer <kwzh@nutrimat.gnu.ai.mit.edu> |
| 8495 | 8501 | ||
| @@ -8561,11 +8567,11 @@ | |||
| 8561 | 8567 | ||
| 8562 | 1991-11-26 Richard Stallman (rms@mole.gnu.ai.mit.edu) | 8568 | 1991-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 | ||
| 8570 | 1990-08-11 Richard Stallman (rms@sugar-bombs.ai.mit.edu) | 8576 | 1990-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 | |||
| 332 | programming language, indentation of text according to structure is | 333 | programming language, indentation of text according to structure is |
| 333 | probably useful. So the mode should set @code{indent-line-function} | 334 | probably useful. So the mode should set @code{indent-line-function} |
| 334 | to a suitable function, and probably customize other variables | 335 | to a suitable function, and probably customize other variables |
| 335 | for indentation. | 336 | for 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 | |||
| 3214 | reasonably fast. | 3215 | reasonably fast. |
| 3215 | @end defvar | 3216 | @end defvar |
| 3216 | 3217 | ||
| 3218 | @node Auto-Indentation | ||
| 3219 | @section Auto-indention of code | ||
| 3220 | |||
| 3221 | For programming languages, an important feature of a major mode is to | ||
| 3222 | provide automatic indentation. This is controlled in Emacs by | ||
| 3223 | @code{indent-line-function} (@pxref{Mode-Specific Indent}). | ||
| 3224 | Writing a good indentation function can be difficult and to a large | ||
| 3225 | extent it is still a black art. | ||
| 3226 | |||
| 3227 | Many major mode authors will start by writing a simple indentation | ||
| 3228 | function that works for simple cases, for example by comparing with the | ||
| 3229 | indentation of the previous text line. For most programming languages | ||
| 3230 | that are not really line-based, this tends to scale very poorly: | ||
| 3231 | improving such a function to let it handle more diverse situations tends | ||
| 3232 | to become more and more difficult, resulting in the end with a large, | ||
| 3233 | complex, unmaintainable indentation function which nobody dares to touch. | ||
| 3234 | |||
| 3235 | A good indentation function will usually need to actually parse the | ||
| 3236 | text, according to the syntax of the language. Luckily, it is not | ||
| 3237 | necessary to parse the text in as much detail as would be needed | ||
| 3238 | for a compiler, but on the other hand, the parser embedded in the | ||
| 3239 | indentation code will want to be somewhat friendly to syntactically | ||
| 3240 | incorrect code. | ||
| 3241 | |||
| 3242 | Good maintainable indentation functions usually fall into 2 categories: | ||
| 3243 | either parsing forward from some ``safe'' starting point until the | ||
| 3244 | position of interest, or parsing backward from the position of interest. | ||
| 3245 | Neither of the two is a clearly better choice than the other: parsing | ||
| 3246 | backward is often more difficult than parsing forward because | ||
| 3247 | programming languages are designed to be parsed forward, but for the | ||
| 3248 | purpose of indentation it has the advantage of not needing to | ||
| 3249 | guess a ``safe'' starting point, and it generally enjoys the property | ||
| 3250 | that only a minimum of text will be analyzed to decide the indentation | ||
| 3251 | of a line, so indentation will tend to be unaffected by syntax errors in | ||
| 3252 | some earlier unrelated piece of code. Parsing forward on the other hand | ||
| 3253 | is usually easier and has the advantage of making it possible to | ||
| 3254 | reindent efficiently a whole region at a time, with a single parse. | ||
| 3255 | |||
| 3256 | Rather than write your own indentation function from scratch, it is | ||
| 3257 | often preferable to try and reuse some existing ones or to rely | ||
| 3258 | on a generic indentation engine. There are sadly few such | ||
| 3259 | engines. The CC-mode indentation code (used with C, C++, Java, Awk | ||
| 3260 | and a few other such modes) has been made more generic over the years, | ||
| 3261 | so if your language seems somewhat similar to one of those languages, | ||
| 3262 | you might try to use that engine. @c FIXME: documentation? | ||
| 3263 | Another one is SMIE which takes an approach in the spirit | ||
| 3264 | of 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 | |||
| 3273 | SMIE is a package that provides a generic navigation and indentation | ||
| 3274 | engine. Based on a very simple parser using an ``operator precedence | ||
| 3275 | grammar'', it lets major modes extend the sexp-based navigation of Lisp | ||
| 3276 | to non-Lisp languages as well as provide a simple to use but reliable | ||
| 3277 | auto-indentation. | ||
| 3278 | |||
| 3279 | Operator precedence grammar is a very primitive technology for parsing | ||
| 3280 | compared to some of the more common techniques used in compilers. | ||
| 3281 | It has the following characteristics: its parsing power is very limited, | ||
| 3282 | and it is largely unable to detect syntax errors, but it has the | ||
| 3283 | advantage of being algorithmically efficient and able to parse forward | ||
| 3284 | just as well as backward. In practice that means that SMIE can use it | ||
| 3285 | for indentation based on backward parsing, that it can provide both | ||
| 3286 | @code{forward-sexp} and @code{backward-sexp} functionality, and that it | ||
| 3287 | will naturally work on syntactically incorrect code without any extra | ||
| 3288 | effort. The downside is that it also means that most programming | ||
| 3289 | languages cannot be parsed correctly using SMIE, at least not without | ||
| 3290 | resorting 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 | |||
| 3306 | SMIE is meant to be a one-stop shop for structural navigation and | ||
| 3307 | various other features which rely on the syntactic structure of code, in | ||
| 3308 | particular automatic indentation. The main entry point is | ||
| 3309 | @code{smie-setup} which is a function typically called while setting | ||
| 3310 | up a major mode. | ||
| 3311 | |||
| 3312 | @defun smie-setup grammar rules-function &rest keywords | ||
| 3313 | Setup 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 | ||
| 3318 | keywords: | ||
| 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 | |||
| 3327 | Calling this function is sufficient to make commands such as | ||
| 3328 | @code{forward-sexp}, @code{backward-sexp}, and @code{transpose-sexps} be | ||
| 3329 | able to properly handle structural elements other than just the paired | ||
| 3330 | parentheses already handled by syntax tables. For example, if the | ||
| 3331 | provided grammar is precise enough, @code{transpose-sexps} can correctly | ||
| 3332 | transpose the two arguments of a @code{+} operator, taking into account | ||
| 3333 | the precedence rules of the language. | ||
| 3334 | |||
| 3335 | Calling `smie-setup' is also sufficient to make TAB indentation work in | ||
| 3336 | the expected way, and provides some commands that you can bind in the | ||
| 3337 | major mode keymap. | ||
| 3338 | |||
| 3339 | @deffn Command smie-close-block | ||
| 3340 | This command closes the most recently opened (and not yet closed) block. | ||
| 3341 | @end deffn | ||
| 3342 | |||
| 3343 | @deffn Command smie-down-list &optional arg | ||
| 3344 | This command is like @code{down-list} but it also pays attention to | ||
| 3345 | nesting 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 | |||
| 3351 | SMIE's precedence grammars simply give to each token a pair of | ||
| 3352 | precedences: the left-precedence and the right-precedence. We say | ||
| 3353 | @code{T1 < T2} if the right-precedence of token @code{T1} is less than | ||
| 3354 | the 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 | ||
| 3356 | T2 ...} then that should be parsed as @code{... T1 (something T2 ...} | ||
| 3357 | rather than as @code{... T1 something) T2 ...}. The latter | ||
| 3358 | interpretation 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 | ||
| 3360 | syntactic construction, so typically we have @code{"begin" = "end"}. | ||
| 3361 | Such pairs of precedences are sufficient to express left-associativity | ||
| 3362 | or right-associativity of infix operators, nesting of tokens like | ||
| 3363 | parentheses 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 | ||
| 3373 | This function takes a @emph{prec2} grammar @var{table} and returns an | ||
| 3374 | alist 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 | ||
| 3379 | This function takes several @emph{prec2} @var{tables} and merges them | ||
| 3380 | into a new @emph{prec2} table. | ||
| 3381 | @end defun | ||
| 3382 | |||
| 3383 | @defun smie-precs->prec2 precs | ||
| 3384 | This function builds a @emph{prec2} table from a table of precedences | ||
| 3385 | @var{precs}. @var{precs} should be a list, sorted by precedence (for | ||
| 3386 | example @code{"+"} will come before @code{"*"}), of elements of the form | ||
| 3387 | @code{(@var{assoc} @var{op} ...)}, where each @var{op} is a token that | ||
| 3388 | acts as an operator; @var{assoc} is their associativity, which can be | ||
| 3389 | either @code{left}, @code{right}, @code{assoc}, or @code{nonassoc}. | ||
| 3390 | All operators in a given element share the same precedence level | ||
| 3391 | and associativity. | ||
| 3392 | @end defun | ||
| 3393 | |||
| 3394 | @defun smie-bnf->prec2 bnf &rest resolvers | ||
| 3395 | This function lets you specify the grammar using a BNF notation. | ||
| 3396 | It accepts a @var{bnf} description of the grammar along with a set of | ||
| 3397 | conflict resolution rules @var{resolvers}, and | ||
| 3398 | returns 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} | ||
| 3402 | is a (non-empty) list of terminals (aka tokens) or non-terminals. | ||
| 3403 | |||
| 3404 | Not all grammars are accepted: | ||
| 3405 | @itemize | ||
| 3406 | @item | ||
| 3407 | An @var{rhs} cannot be an empty list (an empty list is never needed, | ||
| 3408 | since SMIE allows all non-terminals to match the empty string anyway). | ||
| 3409 | @item | ||
| 3410 | An @var{rhs} cannot have 2 consecutive non-terminals: each pair of | ||
| 3411 | non-terminals needs to be separated by a terminal (aka token). | ||
| 3412 | This is a fundamental limitation of operator precedence grammars. | ||
| 3413 | @end itemize | ||
| 3414 | |||
| 3415 | Additionally, conflicts can occur: | ||
| 3416 | @itemize | ||
| 3417 | @item | ||
| 3418 | The returned @emph{prec2} table holds constraints between pairs of tokens, and | ||
| 3419 | for any given pair only one constraint can be present: T1 < T2, | ||
| 3420 | T1 = T2, or T1 > T2. | ||
| 3421 | @item | ||
| 3422 | A token can be an @code{opener} (something similar to an open-paren), | ||
| 3423 | a @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 | |||
| 3427 | Precedence conflicts can be resolved via @var{resolvers}, which | ||
| 3428 | is a list of @emph{precs} tables (see @code{smie-precs->prec2}): for | ||
| 3429 | each precedence conflict, if those @code{precs} tables | ||
| 3430 | specify a particular constraint, then the conflict is resolved by using | ||
| 3431 | this constraint instead, else a conflict is reported and one of the | ||
| 3432 | conflicting constraints is picked arbitrarily and the others are | ||
| 3433 | simply ignored. | ||
| 3434 | @end defun | ||
| 3435 | |||
| 3436 | @node SMIE Grammar | ||
| 3437 | @subsubsection Defining the Grammar of a Language | ||
| 3438 | |||
| 3439 | The usual way to define the SMIE grammar of a language is by | ||
| 3440 | defining a new global variable that holds the precedence table by | ||
| 3441 | giving a set of BNF rules. | ||
| 3442 | For example, the grammar definition for a small Pascal-like language | ||
| 3443 | could 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 | ||
| 3471 | A few things to note: | ||
| 3472 | |||
| 3473 | @itemize | ||
| 3474 | @item | ||
| 3475 | The above grammar does not explicitly mention the syntax of function | ||
| 3476 | calls: SMIE will automatically allow any sequence of sexps, such as | ||
| 3477 | identifiers, balanced parentheses, or @code{begin ... end} blocks | ||
| 3478 | to appear anywhere anyway. | ||
| 3479 | @item | ||
| 3480 | The grammar category @code{id} has no right hand side: this does not | ||
| 3481 | mean that it can match only the empty string, since as mentioned any | ||
| 3482 | sequence of sexps can appear anywhere anyway. | ||
| 3483 | @item | ||
| 3484 | Because non terminals cannot appear consecutively in the BNF grammar, it | ||
| 3485 | is difficult to correctly handle tokens that act as terminators, so the | ||
| 3486 | above grammar treats @code{";"} as a statement @emph{separator} instead, | ||
| 3487 | which SMIE can handle very well. | ||
| 3488 | @item | ||
| 3489 | Separators used in sequences (such as @code{","} and @code{";"} above) | ||
| 3490 | are best defined with BNF rules such as @code{(foo (foo "separator" foo) ...)} | ||
| 3491 | which generate precedence conflicts which are then resolved by giving | ||
| 3492 | them an explicit @code{(assoc "separator")}. | ||
| 3493 | @item | ||
| 3494 | The @code{("(" exps ")")} rule was not needed to pair up parens, since | ||
| 3495 | SMIE will pair up any characters that are marked as having paren syntax | ||
| 3496 | in the syntax table. What this rule does instead (together with the | ||
| 3497 | definition of @code{exps}) is to make it clear that @code{","} should | ||
| 3498 | not appear outside of parentheses. | ||
| 3499 | @item | ||
| 3500 | Rather than have a single @emph{precs} table to resolve conflicts, it is | ||
| 3501 | preferable to have several tables, so as to let the BNF part of the | ||
| 3502 | grammar specify relative precedences where possible. | ||
| 3503 | @item | ||
| 3504 | Unless there is a very good reason to prefer @code{left} or | ||
| 3505 | @code{right}, it is usually preferable to mark operators as associative, | ||
| 3506 | using @code{assoc}. For that reason @code{"+"} and @code{"*"} are | ||
| 3507 | defined above as @code{assoc}, although the language defines them | ||
| 3508 | formally as left associative. | ||
| 3509 | @end itemize | ||
| 3510 | |||
| 3511 | @node SMIE Lexer | ||
| 3512 | @subsubsection Defining Tokens | ||
| 3513 | |||
| 3514 | SMIE comes with a predefined lexical analyzer which uses syntax tables | ||
| 3515 | in the following way: any sequence of characters that have word or | ||
| 3516 | symbol syntax is considered a token, and so is any sequence of | ||
| 3517 | characters that have punctuation syntax. This default lexer is | ||
| 3518 | often a good starting point but is rarely actually correct for any given | ||
| 3519 | language. For example, it will consider @code{"2,+3"} to be composed | ||
| 3520 | of 3 tokens: @code{"2"}, @code{",+"}, and @code{"3"}. | ||
| 3521 | |||
| 3522 | To describe the lexing rules of your language to SMIE, you need | ||
| 3523 | 2 functions, one to fetch the next token, and another to fetch the | ||
| 3524 | previous token. Those functions will usually first skip whitespace and | ||
| 3525 | comments and then look at the next chunk of text to see if it | ||
| 3526 | is a special token. If so it should skip the token and | ||
| 3527 | return a description of this token. Usually this is simply the string | ||
| 3528 | extracted from the buffer, but it can be anything you want. | ||
| 3529 | For 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 | |||
| 3561 | Notice how those lexers return the empty string when in front of | ||
| 3562 | parentheses. This is because SMIE automatically takes care of the | ||
| 3563 | parentheses defined in the syntax table. More specifically if the lexer | ||
| 3564 | returns nil or an empty string, SMIE tries to handle the corresponding | ||
| 3565 | text as a sexp according to syntax tables. | ||
| 3566 | |||
| 3567 | @node SMIE Tricks | ||
| 3568 | @subsubsection Living With a Weak Parser | ||
| 3569 | |||
| 3570 | The parsing technique used by SMIE does not allow tokens to behave | ||
| 3571 | differently in different contexts. For most programming languages, this | ||
| 3572 | manifests itself by precedence conflicts when converting the | ||
| 3573 | BNF grammar. | ||
| 3574 | |||
| 3575 | Sometimes, those conflicts can be worked around by expressing the | ||
| 3576 | grammar slightly differently. For example, for Modula-2 it might seem | ||
| 3577 | natural 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 | |||
| 3588 | But this will create conflicts for @code{"ELSE"}: on the one hand, the | ||
| 3589 | IF rule implies (among many other things) that @code{"ELSE" = "END"}; | ||
| 3590 | but on the other hand, since @code{"ELSE"} appears within @code{cases}, | ||
| 3591 | which appears left of @code{"END"}, we also have @code{"ELSE" > "END"}. | ||
| 3592 | We 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 | ||
| 3602 | or | ||
| 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 | |||
| 3613 | Reworking the grammar to try and solve conflicts has its downsides, tho, | ||
| 3614 | because SMIE assumes that the grammar reflects the logical structure of | ||
| 3615 | the code, so it is preferable to keep the BNF closer to the intended | ||
| 3616 | abstract syntax tree. | ||
| 3617 | |||
| 3618 | Other times, after careful consideration you may conclude that those | ||
| 3619 | conflicts are not serious and simply resolve them via the | ||
| 3620 | @var{resolvers} argument of @code{smie-bnf->prec2}. Usually this is | ||
| 3621 | because the grammar is simply ambiguous: the conflict does not affect | ||
| 3622 | the set of programs described by the grammar, but only the way those | ||
| 3623 | programs are parsed. This is typically the case for separators and | ||
| 3624 | associative infix operators, where you want to add a resolver like | ||
| 3625 | @code{'((assoc "|"))}. Another case where this can happen is for the | ||
| 3626 | classic @emph{dangling else} problem, where you will use @code{'((assoc | ||
| 3627 | "else" "then"))}. It can also happen for cases where the conflict is | ||
| 3628 | real and cannot really be resolved, but it is unlikely to pose a problem | ||
| 3629 | in practice. | ||
| 3630 | |||
| 3631 | Finally, in many cases some conflicts will remain despite all efforts to | ||
| 3632 | restructure the grammar. Do not despair: while the parser cannot be | ||
| 3633 | made more clever, you can make the lexer as smart as you want. So, the | ||
| 3634 | solution is then to look at the tokens involved in the conflict and to | ||
| 3635 | split one of those tokens into 2 (or more) different tokens. E.g. if | ||
| 3636 | the grammar needs to distinguish between two incompatible uses of the | ||
| 3637 | token @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 | ||
| 3640 | different cases to the lexer, which will thus have to look at the | ||
| 3641 | surrounding text to find ad-hoc clues. | ||
| 3642 | |||
| 3643 | @node SMIE Indentation | ||
| 3644 | @subsubsection Specifying Indentation Rules | ||
| 3645 | |||
| 3646 | Based on the provided grammar, SMIE will be able to provide automatic | ||
| 3647 | indentation without any extra effort. But in practice, this default | ||
| 3648 | indentation style will probably not be good enough. You will want to | ||
| 3649 | tweak it in many different cases. | ||
| 3650 | |||
| 3651 | SMIE indentation is based on the idea that indentation rules should be | ||
| 3652 | as local as possible. To this end, it relies on the idea of | ||
| 3653 | @emph{virtual} indentation, which is the indentation that a particular | ||
| 3654 | program point would have if it were at the beginning of a line. | ||
| 3655 | Of course, if that program point is indeed at the beginning of a line, | ||
| 3656 | its virtual indentation is its current indentation. But if not, then | ||
| 3657 | SMIE uses the indentation algorithm to compute the virtual indentation | ||
| 3658 | of that point. Now in practice, the virtual indentation of a program | ||
| 3659 | point does not have to be identical to the indentation it would have if | ||
| 3660 | we inserted a newline before it. To see how this works, the SMIE rule | ||
| 3661 | for 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 | ||
| 3663 | preceding line. Instead, these different cases are handled in the | ||
| 3664 | indentation rule that decides how to indent before a @code{@{}. | ||
| 3665 | |||
| 3666 | Another important concept is the notion of @emph{parent}: The | ||
| 3667 | @emph{parent} of a token, is the head token of the nearest enclosing | ||
| 3668 | syntactic 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, | ||
| 3670 | is the lead token of the surrounding construct. The command | ||
| 3671 | @code{backward-sexp} jumps from a token to its parent, but there are | ||
| 3672 | some caveats: for @emph{openers} (tokens which start a construct, like | ||
| 3673 | @code{if}), you need to start with point before the token, while for | ||
| 3674 | others you need to start with point after the token. | ||
| 3675 | @code{backward-sexp} stops with point before the parent token if that is | ||
| 3676 | the @emph{opener} of the token of interest, and otherwise it stops with | ||
| 3677 | point after the parent token. | ||
| 3678 | |||
| 3679 | SMIE indentation rules are specified using a function that takes two | ||
| 3680 | arguments @var{method} and @var{arg} where the meaning of @var{arg} and the | ||
| 3681 | expected 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 | ||
| 3687 | should 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 | ||
| 3690 | should 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 | ||
| 3693 | to 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 | ||
| 3698 | should return non-@code{nil} if the token is followed by a list of | ||
| 3699 | expressions (not separated by any token) rather than an expression. | ||
| 3700 | @end itemize | ||
| 3701 | |||
| 3702 | When @var{arg} is a token, the function is called with point just before | ||
| 3703 | that token. A return value of nil always means to fallback on the | ||
| 3704 | default behavior, so the function should return nil for arguments it | ||
| 3705 | does 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 | ||
| 3715 | the 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 | |||
| 3721 | SMIE provides various functions designed specifically for use in the | ||
| 3722 | indentation rules function (several of those functions break if used in | ||
| 3723 | another context). These functions all start with the prefix | ||
| 3724 | @code{smie-rule-}. | ||
| 3725 | |||
| 3726 | @defun smie-rule-bolp | ||
| 3727 | Return non-@code{nil} if the current token is the first on the line. | ||
| 3728 | @end defun | ||
| 3729 | |||
| 3730 | @defun smie-rule-hanging-p | ||
| 3731 | Return non-@code{nil} if the current token is @emph{hanging}. | ||
| 3732 | A token is @emph{hanging} if it is the last token on the line | ||
| 3733 | and if it is preceded by other tokens: a lone token on a line is not | ||
| 3734 | hanging. | ||
| 3735 | @end defun | ||
| 3736 | |||
| 3737 | @defun smie-rule-next-p &rest tokens | ||
| 3738 | Return non-@code{nil} if the next token is among @var{tokens}. | ||
| 3739 | @end defun | ||
| 3740 | |||
| 3741 | @defun smie-rule-prev-p &rest tokens | ||
| 3742 | Return non-@code{nil} if the previous token is among @var{tokens}. | ||
| 3743 | @end defun | ||
| 3744 | |||
| 3745 | @defun smie-rule-parent-p &rest parents | ||
| 3746 | Return non-@code{nil} if the current token's parent is among @var{parents}. | ||
| 3747 | @end defun | ||
| 3748 | |||
| 3749 | @defun smie-rule-sibling-p | ||
| 3750 | Return non-nil if the current token's parent is actually a sibling. | ||
| 3751 | This is the case for example when the parent of a @code{","} is just the | ||
| 3752 | previous @code{","}. | ||
| 3753 | @end defun | ||
| 3754 | |||
| 3755 | @defun smie-rule-parent &optional offset | ||
| 3756 | Return the proper offset to align the current token with the parent. | ||
| 3757 | If non-@code{nil}, @var{offset} should be an integer giving an | ||
| 3758 | additional offset to apply. | ||
| 3759 | @end defun | ||
| 3760 | |||
| 3761 | @defun smie-rule-separator method | ||
| 3762 | Indent current token as a @emph{separator}. | ||
| 3763 | |||
| 3764 | By @emph{separator}, we mean here a token whose sole purpose is to | ||
| 3765 | separate various elements within some enclosing syntactic construct, and | ||
| 3766 | which does not have any semantic significance in itself (i.e. it would | ||
| 3767 | typically not exist as a node in an abstract syntax tree). | ||
| 3768 | |||
| 3769 | Such a token is expected to have an associative syntax and be closely | ||
| 3770 | tied to its syntactic parent. Typical examples are @code{","} in lists | ||
| 3771 | of arguments (enclosed inside parentheses), or @code{";"} in sequences | ||
| 3772 | of instructions (enclosed in a @code{@{...@}} or @code{begin...end} | ||
| 3773 | block). | ||
| 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 | |||
| 3782 | Here 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 | ||
| 3805 | A few things to note: | ||
| 3806 | |||
| 3807 | @itemize | ||
| 3808 | @item | ||
| 3809 | The first case indicates the basic indentation increment to use. | ||
| 3810 | If @code{sample-indent-basic} is nil, then SMIE uses the global | ||
| 3811 | setting @code{smie-indent-basic}. The major mode could have set | ||
| 3812 | @code{smie-indent-basic} buffer-locally instead, but that | ||
| 3813 | is discouraged. | ||
| 3814 | |||
| 3815 | @item | ||
| 3816 | The two (identical) rules for the token @code{","} make SMIE try to be | ||
| 3817 | more clever when the comma separator is placed at the beginning of | ||
| 3818 | lines. It tries to outdent the separator so as to align the code after | ||
| 3819 | the comma; for example: | ||
| 3820 | |||
| 3821 | @example | ||
| 3822 | x = longfunctionname ( | ||
| 3823 | arg1 | ||
| 3824 | , arg2 | ||
| 3825 | ); | ||
| 3826 | @end example | ||
| 3827 | |||
| 3828 | @item | ||
| 3829 | The rule for indentation after @code{":="} exists because otherwise | ||
| 3830 | SMIE would treat @code{":="} as an infix operator and would align the | ||
| 3831 | right argument with the left one. | ||
| 3832 | |||
| 3833 | @item | ||
| 3834 | The rule for indentation before @code{"begin"} is an example of the use | ||
| 3835 | of virtual indentation: This rule is used only when @code{"begin"} is | ||
| 3836 | hanging, which can happen only when @code{"begin"} is not at the | ||
| 3837 | beginning 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 | ||
| 3846 | to | ||
| 3847 | @example | ||
| 3848 | if x > 0 then begin | ||
| 3849 | dosomething(x); | ||
| 3850 | end | ||
| 3851 | @end example | ||
| 3852 | |||
| 3853 | @item | ||
| 3854 | The 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"} | ||
| 3856 | as a single unit, so as to align a sequence of tests rather than indent | ||
| 3857 | each test further to the right. This function does this only in the | ||
| 3858 | case where the @code{"if"} is not placed on a separate line, hence the | ||
| 3859 | @code{smie-rule-bolp} test. | ||
| 3860 | |||
| 3861 | If we know that the @code{"else"} is always aligned with its @code{"if"} | ||
| 3862 | and is always at the beginning of a line, we can use a more efficient | ||
| 3863 | rule: | ||
| 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 | |||
| 3872 | The advantage of this formulation is that it reuses the indentation of | ||
| 3873 | the previous @code{"else"}, rather than going all the way back to the | ||
| 3874 | first @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 | ||
| 2210 | In Lisp mode, the value is the symbol @code{lisp-indent-line}; in C | 2210 | In Lisp mode, the value is the symbol @code{lisp-indent-line}; in C |
| 2211 | mode, @code{c-indent-line}; in Fortran mode, @code{fortran-indent-line}. | 2211 | mode, @code{c-indent-line}; in Fortran mode, @code{fortran-indent-line}. |
| 2212 | The default value is @code{indent-relative}. | 2212 | The 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 |