diff options
| author | Karoly Lorentey | 2006-10-14 16:56:21 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2006-10-14 16:56:21 +0000 |
| commit | 3f87f67ee215ffeecbd2f53bd7f342cdf03f47df (patch) | |
| tree | 16f2af9111af08a94d608d96a957f5c3ec5effcc /lispref | |
| parent | 350e4fb815d7413ef6d339dd664014706f742927 (diff) | |
| parent | 7a210b69c7f92650c524766d1b9d3f3eefdd67c7 (diff) | |
| download | emacs-3f87f67ee215ffeecbd2f53bd7f342cdf03f47df.tar.gz emacs-3f87f67ee215ffeecbd2f53bd7f342cdf03f47df.zip | |
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-371
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-372
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-373
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-374
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-375
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-376
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-377
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-378
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-379
Merge from erc--emacs--21
* emacs@sv.gnu.org/emacs--devo--0--patch-380
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-381
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-382
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-383
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-384
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-385
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-386
Update from erc--emacs--22
* emacs@sv.gnu.org/emacs--devo--0--patch-387
Fix ERC bug introduced in last patch
* emacs@sv.gnu.org/emacs--devo--0--patch-388
Update from erc--emacs--22
* emacs@sv.gnu.org/emacs--devo--0--patch-389
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-390
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-391
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-392
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-393
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-394
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-395
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-396
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-397
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-398
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-399
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-400
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-401
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-402
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-403
Rcirc update from Ryan Yeske
* emacs@sv.gnu.org/emacs--devo--0--patch-404
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-405
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-406
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-407
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-408
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-409
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-410
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-411
Miscellaneous tq-related fixes.
* emacs@sv.gnu.org/emacs--devo--0--patch-412
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-121
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-122
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-123
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-124
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-125
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-126
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-127
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-581
Diffstat (limited to 'lispref')
| -rw-r--r-- | lispref/ChangeLog | 146 | ||||
| -rw-r--r-- | lispref/Makefile.in | 3 | ||||
| -rw-r--r-- | lispref/commands.texi | 98 | ||||
| -rw-r--r-- | lispref/customize.texi | 60 | ||||
| -rw-r--r-- | lispref/display.texi | 40 | ||||
| -rw-r--r-- | lispref/elisp.texi | 6 | ||||
| -rw-r--r-- | lispref/keymaps.texi | 133 | ||||
| -rw-r--r-- | lispref/lists.texi | 2 | ||||
| -rw-r--r-- | lispref/maps.texi | 4 | ||||
| -rw-r--r-- | lispref/modes.texi | 842 | ||||
| -rw-r--r-- | lispref/os.texi | 299 | ||||
| -rw-r--r-- | lispref/processes.texi | 2 | ||||
| -rw-r--r-- | lispref/strings.texi | 15 | ||||
| -rw-r--r-- | lispref/text.texi | 187 |
14 files changed, 1060 insertions, 777 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog index 09757fca10b..cc3ccac3c7a 100644 --- a/lispref/ChangeLog +++ b/lispref/ChangeLog | |||
| @@ -1,3 +1,129 @@ | |||
| 1 | 2006-08-27 Michael Olson <mwolson@gnu.org> | ||
| 2 | |||
| 3 | * processes.texi (Transaction Queues): Remove stray quote | ||
| 4 | character. | ||
| 5 | |||
| 6 | 2006-08-25 Richard Stallman <rms@gnu.org> | ||
| 7 | |||
| 8 | * os.texi (Idle Timers): run-with-idle-timer allows Lisp time value. | ||
| 9 | Add xref. | ||
| 10 | |||
| 11 | 2006-08-24 Chong Yidong <cyd@stupidchicken.com> | ||
| 12 | |||
| 13 | * os.texi (Timers): Avoid waiting inside timers. | ||
| 14 | |||
| 15 | 2006-08-21 Lute Kamstra <lute@gnu.org> | ||
| 16 | |||
| 17 | * Makefile.in: Use ../man/texinfo.tex to build elisp.dvi. | ||
| 18 | |||
| 19 | 2006-08-20 Richard Stallman <rms@gnu.org> | ||
| 20 | |||
| 21 | * os.texi (Idle Timers): New node, split out from Timers. | ||
| 22 | Document current-idle-time. | ||
| 23 | * commands.texi (Reading One Event): Update xref. | ||
| 24 | * elisp.texi (Top): Update subnode menu. | ||
| 25 | |||
| 26 | 2006-08-16 Richard Stallman <rms@gnu.org> | ||
| 27 | |||
| 28 | * keymaps.texi (Extended Menu Items): Show format of cached | ||
| 29 | bindings in extended menu items. | ||
| 30 | |||
| 31 | * customize.texi (Variable Definitions): Explain when the | ||
| 32 | standard value expression is evaluated. | ||
| 33 | |||
| 34 | 2006-08-15 Chong Yidong <cyd@stupidchicken.com> | ||
| 35 | |||
| 36 | * commands.texi (Reading One Event): Explain idleness in | ||
| 37 | `read-event'. | ||
| 38 | |||
| 39 | 2006-08-12 Chong Yidong <cyd@stupidchicken.com> | ||
| 40 | |||
| 41 | * text.texi (Near Point): Say "cursor" not "terminal cursor". | ||
| 42 | (Commands for Insertion): Removed split-line since it's not | ||
| 43 | relevant for Lisp programming. | ||
| 44 | (Yank Commands): Rewrite introduction. | ||
| 45 | (Undo): Clarify. | ||
| 46 | (Maintaining Undo): Clarify. Document undo-ask-before-discard. | ||
| 47 | (Filling): Remove redundant comment. Clarify return value of | ||
| 48 | current-justification. | ||
| 49 | (Margins): Minor clarifications. | ||
| 50 | (Adaptive Fill): Update default value of adaptive-fill-regexp. | ||
| 51 | (Sorting): Update definition of sort-lines. | ||
| 52 | (Columns): Clarify behavior of sort-columns. | ||
| 53 | (Indent Tabs): Link to Tab Stops in Emacs manual. | ||
| 54 | (Special Properties): Clarify. | ||
| 55 | (Clickable Text): Mention Buttons package. | ||
| 56 | |||
| 57 | 2006-08-12 Kevin Ryde <user42@zip.com.au> | ||
| 58 | |||
| 59 | * os.texi (Time Parsing): Add %z to description of | ||
| 60 | format-time-string, as per docstring. Add cross reference to | ||
| 61 | glibc manual for strftime. | ||
| 62 | |||
| 63 | 2006-08-08 Richard Stallman <rms@gnu.org> | ||
| 64 | |||
| 65 | * modes.texi: Clean up wording in previous change. | ||
| 66 | |||
| 67 | 2006-08-07 Chong Yidong <cyd@stupidchicken.com> | ||
| 68 | |||
| 69 | * modes.texi (Hooks): Clarify. | ||
| 70 | (Major Mode Basics): Mention define-derived-mode explicitly. | ||
| 71 | (Major Mode Conventions): Rebinding RET is OK for some modes. | ||
| 72 | Mention change-major-mode-hook and after-change-major-mode-hook. | ||
| 73 | (Example Major Modes): Moved to end of Modes section. | ||
| 74 | (Mode Line Basics): Clarify. | ||
| 75 | (Mode Line Data): Mention help-echo and local-map in strings. | ||
| 76 | Explain reason for treatment of non-risky variables. | ||
| 77 | (Properties in Mode): Clarify. | ||
| 78 | (Faces for Font Lock): Add font-lock-negation-char-face. | ||
| 79 | |||
| 80 | 2006-08-04 Eli Zaretskii <eliz@gnu.org> | ||
| 81 | |||
| 82 | * strings.texi (Formatting Strings): Warn against arbitrary | ||
| 83 | strings as first arg to `format'. | ||
| 84 | |||
| 85 | 2006-07-31 Thien-Thi Nguyen <ttn@gnu.org> | ||
| 86 | |||
| 87 | * text.texi (Clickable Text): Mention `help-echo' text property. | ||
| 88 | Update intro, examples and associated explanations. | ||
| 89 | |||
| 90 | 2006-07-31 Richard Stallman <rms@gnu.org> | ||
| 91 | |||
| 92 | * commands.texi: Update xrefs. | ||
| 93 | (Event Mod): New node, cut out from old Translating Input. | ||
| 94 | |||
| 95 | * maps.texi: Update xrefs. | ||
| 96 | |||
| 97 | * keymaps.texi (Translation Keymaps): New node. | ||
| 98 | Update xrefs from Translating Input to Translation Keymaps. | ||
| 99 | |||
| 100 | * elisp.texi (Top): Update subnode menu. | ||
| 101 | |||
| 102 | * display.texi (Face Functions): Fix explanations of FRAME=t or nil. | ||
| 103 | |||
| 104 | * os.texi (System Interface): Fix menu descriptions of some nodes. | ||
| 105 | (Translating Input): Node deleted. | ||
| 106 | |||
| 107 | 2006-07-31 Nick Roberts <nickrob@snap.net.nz> | ||
| 108 | |||
| 109 | * modes.texi (Minor Mode Conventions): Update link for add-to-list. | ||
| 110 | |||
| 111 | * lists.texi (Sets And Lists): Likewise. | ||
| 112 | |||
| 113 | 2006-07-30 Thien-Thi Nguyen <ttn@gnu.org> | ||
| 114 | |||
| 115 | * text.texi (Fields): Mention POS | ||
| 116 | requirement when narrowing is in effect. | ||
| 117 | |||
| 118 | 2006-07-28 Richard Stallman <rms@gnu.org> | ||
| 119 | |||
| 120 | * display.texi (Face Attributes): Simplify wording. | ||
| 121 | (Attribute Functions): Clarify meaning of new-frame default | ||
| 122 | attribute settings. | ||
| 123 | |||
| 124 | * customize.texi (Common Keywords): Document how to use | ||
| 125 | :package-version in a package not in Emacs. | ||
| 126 | |||
| 1 | 2006-07-28 Kim F. Storm <storm@cua.dk> | 127 | 2006-07-28 Kim F. Storm <storm@cua.dk> |
| 2 | 128 | ||
| 3 | * commands.texi (Reading One Event): Fix last change. | 129 | * commands.texi (Reading One Event): Fix last change. |
| @@ -248,7 +374,7 @@ | |||
| 248 | 374 | ||
| 249 | * anti.texi, customize.texi, display.texi, internals.texi: | 375 | * anti.texi, customize.texi, display.texi, internals.texi: |
| 250 | * minibuf.texi, modes.texi, tips.texi: | 376 | * minibuf.texi, modes.texi, tips.texi: |
| 251 | Fix overfull/underfull boxes. | 377 | Fix overfull/underfull boxes. |
| 252 | 378 | ||
| 253 | 2006-07-05 Thien-Thi Nguyen <ttn@gnu.org> | 379 | 2006-07-05 Thien-Thi Nguyen <ttn@gnu.org> |
| 254 | 380 | ||
| @@ -325,7 +451,7 @@ | |||
| 325 | 451 | ||
| 326 | 2006-06-09 Aidan Kehoe <kehoea@parhasard.net> | 452 | 2006-06-09 Aidan Kehoe <kehoea@parhasard.net> |
| 327 | 453 | ||
| 328 | * objects.texi (Character Type): Describe the\uABCD and \U00ABCDEF | 454 | * objects.texi (Character Type): Describe the \uABCD and \U00ABCDEF |
| 329 | syntax. | 455 | syntax. |
| 330 | 456 | ||
| 331 | 2006-06-07 Eli Zaretskii <eliz@gnu.org> | 457 | 2006-06-07 Eli Zaretskii <eliz@gnu.org> |
| @@ -637,7 +763,7 @@ | |||
| 637 | 2006-04-13 Bill Wohler <wohler@newt.com> | 763 | 2006-04-13 Bill Wohler <wohler@newt.com> |
| 638 | 764 | ||
| 639 | * customize.texi (Common Keywords): Use dotted notation for | 765 | * customize.texi (Common Keywords): Use dotted notation for |
| 640 | :package-version value. Specify its values. Improve documentation | 766 | :package-version value. Specify its values. Improve documentation |
| 641 | for customize-package-emacs-version-alist. | 767 | for customize-package-emacs-version-alist. |
| 642 | 768 | ||
| 643 | 2006-04-12 Bill Wohler <wohler@newt.com> | 769 | 2006-04-12 Bill Wohler <wohler@newt.com> |
| @@ -1682,7 +1808,7 @@ | |||
| 1682 | (Jumping): Clarify description of `h' command. | 1808 | (Jumping): Clarify description of `h' command. |
| 1683 | Eliminate redundant @ref. | 1809 | Eliminate redundant @ref. |
| 1684 | (Breaks): New node. | 1810 | (Breaks): New node. |
| 1685 | (Breakpoints): is now a subsubsection. | 1811 | (Breakpoints): Is now a subsubsection. |
| 1686 | (Global Break Condition): Mention `C-x X X'. | 1812 | (Global Break Condition): Mention `C-x X X'. |
| 1687 | (Edebug Views): Clarify `v' and `p'. Mention `C-x X w'. | 1813 | (Edebug Views): Clarify `v' and `p'. Mention `C-x X w'. |
| 1688 | (Trace Buffer): Clarify STRING arg of `edebug-tracing'. | 1814 | (Trace Buffer): Clarify STRING arg of `edebug-tracing'. |
| @@ -2932,7 +3058,7 @@ | |||
| 2932 | 3058 | ||
| 2933 | 2004-10-24 Jason Rumney <jasonr@gnu.org> | 3059 | 2004-10-24 Jason Rumney <jasonr@gnu.org> |
| 2934 | 3060 | ||
| 2935 | * commands.texi (Misc Events): Remove mouse-wheel. Add wheel-up | 3061 | * commands.texi (Misc Events): Remove mouse-wheel. Add wheel-up |
| 2936 | and wheel-down. | 3062 | and wheel-down. |
| 2937 | 3063 | ||
| 2938 | 2004-10-24 Kai Grossjohann <kai.grossjohann@gmx.net> | 3064 | 2004-10-24 Kai Grossjohann <kai.grossjohann@gmx.net> |
| @@ -3161,7 +3287,7 @@ | |||
| 3161 | except while processing `frame-title-format' or `icon-title-format'. | 3287 | except while processing `frame-title-format' or `icon-title-format'. |
| 3162 | (Deleting Frames): Correct description of `delete-frame'. | 3288 | (Deleting Frames): Correct description of `delete-frame'. |
| 3163 | Non-nil return values of `frame-live-p' are like those of `framep'. | 3289 | Non-nil return values of `frame-live-p' are like those of `framep'. |
| 3164 | (Frames and Windows): mention return value of | 3290 | (Frames and Windows): Mention return value of |
| 3165 | `set-frame-selected-window'. | 3291 | `set-frame-selected-window'. |
| 3166 | (Visibility of Frames): Mention `force' argument to | 3292 | (Visibility of Frames): Mention `force' argument to |
| 3167 | `make-frame-invisible'. `frame-visible-p' returns t for all | 3293 | `make-frame-invisible'. `frame-visible-p' returns t for all |
| @@ -3488,7 +3614,7 @@ | |||
| 3488 | 3614 | ||
| 3489 | 2004-03-07 Thien-Thi Nguyen <ttn@gnu.org> | 3615 | 2004-03-07 Thien-Thi Nguyen <ttn@gnu.org> |
| 3490 | 3616 | ||
| 3491 | * customize.texi: Fix typo. Remove eol whitespace. | 3617 | * customize.texi: Fix typo. Remove eol whitespace. |
| 3492 | 3618 | ||
| 3493 | 2004-03-04 Richard M. Stallman <rms@gnu.org> | 3619 | 2004-03-04 Richard M. Stallman <rms@gnu.org> |
| 3494 | 3620 | ||
| @@ -3524,7 +3650,7 @@ | |||
| 3524 | * text.texi: Various small changes in addition to the following: | 3650 | * text.texi: Various small changes in addition to the following: |
| 3525 | (User-Level Deletion): Mention optional BACKWARD-ONLY argument | 3651 | (User-Level Deletion): Mention optional BACKWARD-ONLY argument |
| 3526 | to delete-horizontal-space. | 3652 | to delete-horizontal-space. |
| 3527 | (Kill Functions, Yanking, Low-Level Kill Ring): clarify and correct | 3653 | (Kill Functions, Yanking, Low-Level Kill Ring): Clarify and correct |
| 3528 | description of yank-handler text property at various places. | 3654 | description of yank-handler text property at various places. |
| 3529 | 3655 | ||
| 3530 | * frames.texi (Window System Selections): Add anchor. | 3656 | * frames.texi (Window System Selections): Add anchor. |
| @@ -4551,7 +4677,7 @@ | |||
| 4551 | * loading.texi (Unloading): Fix recent change for load-history. | 4677 | * loading.texi (Unloading): Fix recent change for load-history. |
| 4552 | 4678 | ||
| 4553 | * customize.texi (Simple Types): Clarify description of custom | 4679 | * customize.texi (Simple Types): Clarify description of custom |
| 4554 | type 'number. Describe new custom type 'float. | 4680 | type 'number. Describe new custom type 'float. |
| 4555 | 4681 | ||
| 4556 | 2002-12-04 Markus Rost <rost@math.ohio-state.edu> | 4682 | 2002-12-04 Markus Rost <rost@math.ohio-state.edu> |
| 4557 | 4683 | ||
| @@ -5081,7 +5207,7 @@ Mon Apr 17 18:56:50 1989 Robert J. Chassell (bob@rice-chex.ai.mit.edu) | |||
| 5081 | Tue Apr 11 12:23:28 1989 Robert J. Chassell (bob@rice-chex.ai.mit.edu) | 5207 | Tue Apr 11 12:23:28 1989 Robert J. Chassell (bob@rice-chex.ai.mit.edu) |
| 5082 | 5208 | ||
| 5083 | * Applied Karl Berry's patches to *.texinfo files, but not to | 5209 | * Applied Karl Berry's patches to *.texinfo files, but not to |
| 5084 | texinfo.tex; those diffs are in `berry-texinfo-tex-diffs'. (Karl's | 5210 | texinfo.tex; those diffs are in `berry-texinfo-tex-diffs'. (Karl's |
| 5085 | new title page format is also not applied, since it requires | 5211 | new title page format is also not applied, since it requires |
| 5086 | texinfo.tex changes.) | 5212 | texinfo.tex changes.) |
| 5087 | 5213 | ||
diff --git a/lispref/Makefile.in b/lispref/Makefile.in index e3d09fe2c6f..1eea23e122e 100644 --- a/lispref/Makefile.in +++ b/lispref/Makefile.in | |||
| @@ -27,6 +27,7 @@ srcdir = @srcdir@ | |||
| 27 | VPATH=@srcdir@ | 27 | VPATH=@srcdir@ |
| 28 | 28 | ||
| 29 | infodir = $(srcdir)/../info | 29 | infodir = $(srcdir)/../info |
| 30 | usermanualdir = $(srcdir)/../man | ||
| 30 | 31 | ||
| 31 | TEXI2DVI = texi2dvi | 32 | TEXI2DVI = texi2dvi |
| 32 | SHELL = /bin/sh | 33 | SHELL = /bin/sh |
| @@ -103,7 +104,7 @@ $(infodir)/elisp: $(srcs) | |||
| 103 | $(MAKEINFO) -I. -I$(srcdir) $(srcdir)/elisp.texi -o $(infodir)/elisp | 104 | $(MAKEINFO) -I. -I$(srcdir) $(srcdir)/elisp.texi -o $(infodir)/elisp |
| 104 | 105 | ||
| 105 | elisp.dvi: $(srcs) | 106 | elisp.dvi: $(srcs) |
| 106 | $(TEXI2DVI) -I $(srcdir) $(srcdir)/elisp.texi | 107 | $(TEXI2DVI) -I $(srcdir) -I $(usermanualdir) $(srcdir)/elisp.texi |
| 107 | 108 | ||
| 108 | # This is for use in a separate distro of the Emacs Lisp manual. | 109 | # This is for use in a separate distro of the Emacs Lisp manual. |
| 109 | install: elisp | 110 | install: elisp |
diff --git a/lispref/commands.texi b/lispref/commands.texi index 10cd97400f8..514b55205a1 100644 --- a/lispref/commands.texi +++ b/lispref/commands.texi | |||
| @@ -1087,7 +1087,7 @@ Lisp programs by representing the former as the integer 9, and the | |||
| 1087 | latter as the symbol @code{tab}. | 1087 | latter as the symbol @code{tab}. |
| 1088 | 1088 | ||
| 1089 | Most of the time, it's not useful to distinguish the two. So normally | 1089 | Most of the time, it's not useful to distinguish the two. So normally |
| 1090 | @code{function-key-map} (@pxref{Translating Input}) is set up to map | 1090 | @code{function-key-map} (@pxref{Translation Keymaps}) is set up to map |
| 1091 | @code{tab} into 9. Thus, a key binding for character code 9 (the | 1091 | @code{tab} into 9. Thus, a key binding for character code 9 (the |
| 1092 | character @kbd{C-i}) also applies to @code{tab}. Likewise for the other | 1092 | character @kbd{C-i}) also applies to @code{tab}. Likewise for the other |
| 1093 | symbols in this group. The function @code{read-char} likewise converts | 1093 | symbols in this group. The function @code{read-char} likewise converts |
| @@ -2051,14 +2051,14 @@ functions for event input are also available for use in Lisp programs. | |||
| 2051 | See also @code{momentary-string-display} in @ref{Temporary Displays}, | 2051 | See also @code{momentary-string-display} in @ref{Temporary Displays}, |
| 2052 | and @code{sit-for} in @ref{Waiting}. @xref{Terminal Input}, for | 2052 | and @code{sit-for} in @ref{Waiting}. @xref{Terminal Input}, for |
| 2053 | functions and variables for controlling terminal input modes and | 2053 | functions and variables for controlling terminal input modes and |
| 2054 | debugging terminal input. @xref{Translating Input}, for features you | 2054 | debugging terminal input. |
| 2055 | can use for translating or modifying input events while reading them. | ||
| 2056 | 2055 | ||
| 2057 | For higher-level input facilities, see @ref{Minibuffers}. | 2056 | For higher-level input facilities, see @ref{Minibuffers}. |
| 2058 | 2057 | ||
| 2059 | @menu | 2058 | @menu |
| 2060 | * Key Sequence Input:: How to read one key sequence. | 2059 | * Key Sequence Input:: How to read one key sequence. |
| 2061 | * Reading One Event:: How to read just one event. | 2060 | * Reading One Event:: How to read just one event. |
| 2061 | * Event Mod:: How Emacs modifies events as they are read. | ||
| 2062 | * Invoking the Input Method:: How reading an event uses the input method. | 2062 | * Invoking the Input Method:: How reading an event uses the input method. |
| 2063 | * Quoted Character Input:: Asking the user to specify a character. | 2063 | * Quoted Character Input:: Asking the user to specify a character. |
| 2064 | * Event Input Misc:: How to reread or throw away input events. | 2064 | * Event Input Misc:: How to reread or throw away input events. |
| @@ -2088,7 +2088,7 @@ events---characters, symbols, and lists. The elements of the string or | |||
| 2088 | vector are the events in the key sequence. | 2088 | vector are the events in the key sequence. |
| 2089 | 2089 | ||
| 2090 | Reading a key sequence includes translating the events in various | 2090 | Reading a key sequence includes translating the events in various |
| 2091 | ways. @xref{Translating Input}. | 2091 | ways. @xref{Translation Keymaps}. |
| 2092 | 2092 | ||
| 2093 | The argument @var{prompt} is either a string to be displayed in the | 2093 | The argument @var{prompt} is either a string to be displayed in the |
| 2094 | echo area as a prompt, or @code{nil}, meaning not to display a prompt. | 2094 | echo area as a prompt, or @code{nil}, meaning not to display a prompt. |
| @@ -2229,6 +2229,15 @@ number of seconds; on these systems, @var{seconds} is rounded down. | |||
| 2229 | If @var{seconds} is @code{nil}, @code{read-event} waits as long as | 2229 | If @var{seconds} is @code{nil}, @code{read-event} waits as long as |
| 2230 | necessary for input to arrive. | 2230 | necessary for input to arrive. |
| 2231 | 2231 | ||
| 2232 | If @var{seconds} is @code{nil}, Emacs is considered idle while waiting | ||
| 2233 | for user input to arrive. Idle timers---those created with | ||
| 2234 | @code{run-with-idle-timer} (@pxref{Idle Timers})---can run during this | ||
| 2235 | period. However, if @var{seconds} is non-@code{nil}, the state of | ||
| 2236 | idleness remains unchanged. If Emacs is non-idle when | ||
| 2237 | @code{read-event} is called, it remains non-idle throughout the | ||
| 2238 | operation of @code{read-event}; if Emacs is idle (which can happen if | ||
| 2239 | the call happens inside an idle timer), it remains idle. | ||
| 2240 | |||
| 2232 | If @code{read-event} gets an event that is defined as a help character, | 2241 | If @code{read-event} gets an event that is defined as a help character, |
| 2233 | then in some cases @code{read-event} processes the event directly without | 2242 | then in some cases @code{read-event} processes the event directly without |
| 2234 | returning. @xref{Help Functions}. Certain other events, called | 2243 | returning. @xref{Help Functions}. Certain other events, called |
| @@ -2290,6 +2299,87 @@ This variable holds the total number of input events received so far | |||
| 2290 | from the terminal---not counting those generated by keyboard macros. | 2299 | from the terminal---not counting those generated by keyboard macros. |
| 2291 | @end defvar | 2300 | @end defvar |
| 2292 | 2301 | ||
| 2302 | @node Event Mod | ||
| 2303 | @subsection Modifying and Translating Input Events | ||
| 2304 | |||
| 2305 | Emacs modifies every event it reads according to | ||
| 2306 | @code{extra-keyboard-modifiers}, then translates it through | ||
| 2307 | @code{keyboard-translate-table} (if applicable), before returning it | ||
| 2308 | from @code{read-event}. | ||
| 2309 | |||
| 2310 | @c Emacs 19 feature | ||
| 2311 | @defvar extra-keyboard-modifiers | ||
| 2312 | This variable lets Lisp programs ``press'' the modifier keys on the | ||
| 2313 | keyboard. The value is a character. Only the modifiers of the | ||
| 2314 | character matter. Each time the user types a keyboard key, it is | ||
| 2315 | altered as if those modifier keys were held down. For instance, if | ||
| 2316 | you bind @code{extra-keyboard-modifiers} to @code{?\C-\M-a}, then all | ||
| 2317 | keyboard input characters typed during the scope of the binding will | ||
| 2318 | have the control and meta modifiers applied to them. The character | ||
| 2319 | @code{?\C-@@}, equivalent to the integer 0, does not count as a control | ||
| 2320 | character for this purpose, but as a character with no modifiers. | ||
| 2321 | Thus, setting @code{extra-keyboard-modifiers} to zero cancels any | ||
| 2322 | modification. | ||
| 2323 | |||
| 2324 | When using a window system, the program can ``press'' any of the | ||
| 2325 | modifier keys in this way. Otherwise, only the @key{CTL} and @key{META} | ||
| 2326 | keys can be virtually pressed. | ||
| 2327 | |||
| 2328 | Note that this variable applies only to events that really come from | ||
| 2329 | the keyboard, and has no effect on mouse events or any other events. | ||
| 2330 | @end defvar | ||
| 2331 | |||
| 2332 | @defvar keyboard-translate-table | ||
| 2333 | This variable is the translate table for keyboard characters. It lets | ||
| 2334 | you reshuffle the keys on the keyboard without changing any command | ||
| 2335 | bindings. Its value is normally a char-table, or else @code{nil}. | ||
| 2336 | (It can also be a string or vector, but this is considered obsolete.) | ||
| 2337 | |||
| 2338 | If @code{keyboard-translate-table} is a char-table | ||
| 2339 | (@pxref{Char-Tables}), then each character read from the keyboard is | ||
| 2340 | looked up in this char-table. If the value found there is | ||
| 2341 | non-@code{nil}, then it is used instead of the actual input character. | ||
| 2342 | |||
| 2343 | Note that this translation is the first thing that happens to a | ||
| 2344 | character after it is read from the terminal. Record-keeping features | ||
| 2345 | such as @code{recent-keys} and dribble files record the characters after | ||
| 2346 | translation. | ||
| 2347 | |||
| 2348 | Note also that this translation is done before the characters are | ||
| 2349 | supplied to input methods (@pxref{Input Methods}). Use | ||
| 2350 | @code{translation-table-for-input} (@pxref{Translation of Characters}), | ||
| 2351 | if you want to translate characters after input methods operate. | ||
| 2352 | @end defvar | ||
| 2353 | |||
| 2354 | @defun keyboard-translate from to | ||
| 2355 | This function modifies @code{keyboard-translate-table} to translate | ||
| 2356 | character code @var{from} into character code @var{to}. It creates | ||
| 2357 | the keyboard translate table if necessary. | ||
| 2358 | @end defun | ||
| 2359 | |||
| 2360 | Here's an example of using the @code{keyboard-translate-table} to | ||
| 2361 | make @kbd{C-x}, @kbd{C-c} and @kbd{C-v} perform the cut, copy and paste | ||
| 2362 | operations: | ||
| 2363 | |||
| 2364 | @example | ||
| 2365 | (keyboard-translate ?\C-x 'control-x) | ||
| 2366 | (keyboard-translate ?\C-c 'control-c) | ||
| 2367 | (keyboard-translate ?\C-v 'control-v) | ||
| 2368 | (global-set-key [control-x] 'kill-region) | ||
| 2369 | (global-set-key [control-c] 'kill-ring-save) | ||
| 2370 | (global-set-key [control-v] 'yank) | ||
| 2371 | @end example | ||
| 2372 | |||
| 2373 | @noindent | ||
| 2374 | On a graphical terminal that supports extended @acronym{ASCII} input, | ||
| 2375 | you can still get the standard Emacs meanings of one of those | ||
| 2376 | characters by typing it with the shift key. That makes it a different | ||
| 2377 | character as far as keyboard translation is concerned, but it has the | ||
| 2378 | same usual meaning. | ||
| 2379 | |||
| 2380 | @xref{Translation Keymaps}, for mechanisms that translate event sequences | ||
| 2381 | at the level of @code{read-key-sequence}. | ||
| 2382 | |||
| 2293 | @node Invoking the Input Method | 2383 | @node Invoking the Input Method |
| 2294 | @subsection Invoking the Input Method | 2384 | @subsection Invoking the Input Method |
| 2295 | 2385 | ||
diff --git a/lispref/customize.texi b/lispref/customize.texi index 3aca1a90bcf..9e10e547b56 100644 --- a/lispref/customize.texi +++ b/lispref/customize.texi | |||
| @@ -133,18 +133,21 @@ version. The value @var{version} must be a string. | |||
| 133 | 133 | ||
| 134 | @item :package-version '(@var{package} . @var{version}) | 134 | @item :package-version '(@var{package} . @var{version}) |
| 135 | This option specifies that the item was first introduced in | 135 | This option specifies that the item was first introduced in |
| 136 | @var{package} version @var{version}, or that its default value was | 136 | @var{package} version @var{version}, or that its meaning or default |
| 137 | changed in that version. This keyword takes priority over :version. | 137 | value was changed in that version. The value of @var{package} is a |
| 138 | The value of @var{package} is a symbol and @var{version} is a string. | 138 | symbol and @var{version} is a string. |
| 139 | The @var{package} and @var{version} must appear in the alist | ||
| 140 | @code{customize-package-emacs-version-alist}. Since @var{package} must | ||
| 141 | be unique and the user might see it in an error message, a good choice | ||
| 142 | is the official name of the package, such as MH-E or Gnus. | ||
| 143 | 139 | ||
| 140 | This keyword takes priority over @code{:version}. | ||
| 141 | |||
| 142 | @var{package} should be the official name of the package, such as MH-E | ||
| 143 | or Gnus. If the package @var{package} is released as part of Emacs, | ||
| 144 | @var{package} and @var{version} should appear in the value of | ||
| 145 | @code{customize-package-emacs-version-alist}. | ||
| 144 | @end table | 146 | @end table |
| 145 | 147 | ||
| 146 | Packages that use the @code{:package-version} keyword must also update | 148 | Packages distributed as part of Emacs that use the |
| 147 | the @code{customize-package-emacs-version-alist} variable. | 149 | @code{:package-version} keyword must also update the |
| 150 | @code{customize-package-emacs-version-alist} variable. | ||
| 148 | 151 | ||
| 149 | @defvar customize-package-emacs-version-alist | 152 | @defvar customize-package-emacs-version-alist |
| 150 | This alist provides a mapping for the versions of Emacs that are | 153 | This alist provides a mapping for the versions of Emacs that are |
| @@ -248,19 +251,30 @@ turn this feature back on, if someone would like to do the work. | |||
| 248 | 251 | ||
| 249 | Use @code{defcustom} to declare user-editable variables. | 252 | Use @code{defcustom} to declare user-editable variables. |
| 250 | 253 | ||
| 251 | @defmac defcustom option default doc [keyword value]@dots{} | 254 | @defmac defcustom option standard doc [keyword value]@dots{} |
| 252 | Declare @var{option} as a customizable user option variable. Do not | 255 | This construct declares @var{option} as a customizable user option |
| 253 | quote @var{option}. The argument @var{doc} specifies the documentation | 256 | variable. You should not quote @var{option}. The argument @var{doc} |
| 254 | string for the variable. There is no need to start it with a @samp{*} | 257 | specifies the documentation string for the variable. There is no need |
| 255 | because @code{defcustom} automatically marks @var{option} as a | 258 | to start it with a @samp{*}, because @code{defcustom} automatically |
| 256 | @dfn{user option} (@pxref{Defining Variables}). | 259 | marks @var{option} as a @dfn{user option} (@pxref{Defining |
| 257 | 260 | Variables}). | |
| 258 | If @var{option} is void, @code{defcustom} initializes it to | 261 | |
| 259 | @var{default}. @var{default} should be an expression to compute the | 262 | The argument @var{standard} is an expression that specifies the |
| 260 | value; be careful in writing it, because it can be evaluated on more | 263 | standard value for @var{option}. Evaluating the @code{defcustom} form |
| 261 | than one occasion. You should normally avoid using backquotes in | 264 | evaluates @var{standard}, but does not necessarily install the |
| 262 | @var{default} because they are not expanded when editing the value, | 265 | standard value. If @var{option} already has a default value, |
| 263 | causing list values to appear to have the wrong structure. | 266 | @code{defcustom} does not change it. If the user has saved a |
| 267 | customization for @var{option}, @code{defcustom} installs the user's | ||
| 268 | customized value as @var{option}'s default value. If neither of those | ||
| 269 | cases applies, @code{defcustom} installs the result of evaluating | ||
| 270 | @var{standard} as the default value. | ||
| 271 | |||
| 272 | The expression @var{standard} can be evaluated at various other times, | ||
| 273 | too---whenever the customization facility needs to know @var{option}'s | ||
| 274 | standard value. So be sure to use an expression which is harmless to | ||
| 275 | evaluate at any time. We recommend avoiding backquotes in | ||
| 276 | @var{standard}, because they are not expanded when editing the value, | ||
| 277 | so list values will appear to have the wrong structure. | ||
| 264 | 278 | ||
| 265 | If you specify the @code{:set} option, to make the variable take other | 279 | If you specify the @code{:set} option, to make the variable take other |
| 266 | special actions when set through the customization buffer, the | 280 | special actions when set through the customization buffer, the |
| @@ -403,7 +417,7 @@ type of @var{symbol}. | |||
| 403 | @end defun | 417 | @end defun |
| 404 | 418 | ||
| 405 | Internally, @code{defcustom} uses the symbol property | 419 | Internally, @code{defcustom} uses the symbol property |
| 406 | @code{standard-value} to record the expression for the default value, | 420 | @code{standard-value} to record the expression for the standard value, |
| 407 | and @code{saved-value} to record the value saved by the user with the | 421 | and @code{saved-value} to record the value saved by the user with the |
| 408 | customization buffer. Both properties are actually lists whose car is | 422 | customization buffer. Both properties are actually lists whose car is |
| 409 | an expression which evaluates to the value. | 423 | an expression which evaluates to the value. |
diff --git a/lispref/display.texi b/lispref/display.texi index 678ca657b5b..e762c14a7f0 100644 --- a/lispref/display.texi +++ b/lispref/display.texi | |||
| @@ -1857,9 +1857,9 @@ as if they had a light background. | |||
| 1857 | 1857 | ||
| 1858 | The effect of using a face is determined by a fixed set of @dfn{face | 1858 | The effect of using a face is determined by a fixed set of @dfn{face |
| 1859 | attributes}. This table lists all the face attributes, and what they | 1859 | attributes}. This table lists all the face attributes, and what they |
| 1860 | mean. Note that in general, more than one face can be specified for a | 1860 | mean. You can specify more than one face for a given piece of text; |
| 1861 | given piece of text; when that happens, the attributes of all the faces | 1861 | Emacs merges the attributes of all the faces to determine how to |
| 1862 | are merged to specify how to display the text. @xref{Displaying Faces}. | 1862 | display the text. @xref{Displaying Faces}. |
| 1863 | 1863 | ||
| 1864 | Any attribute in a face can have the value @code{unspecified}. This | 1864 | Any attribute in a face can have the value @code{unspecified}. This |
| 1865 | means the face doesn't specify that attribute. In face merging, when | 1865 | means the face doesn't specify that attribute. In face merging, when |
| @@ -2048,15 +2048,13 @@ suitable for use with @code{:stipple} (see above). It returns | |||
| 2048 | @node Attribute Functions | 2048 | @node Attribute Functions |
| 2049 | @subsection Face Attribute Functions | 2049 | @subsection Face Attribute Functions |
| 2050 | 2050 | ||
| 2051 | You can modify the attributes of an existing face with the following | 2051 | This section describes the functions for accessing and modifying the |
| 2052 | functions. If you specify @var{frame}, they affect just that frame; | 2052 | attributes of an existing face. |
| 2053 | otherwise, they affect all frames as well as the defaults that apply to | ||
| 2054 | new frames. | ||
| 2055 | 2053 | ||
| 2056 | @defun set-face-attribute face frame &rest arguments | 2054 | @defun set-face-attribute face frame &rest arguments |
| 2057 | This function sets one or more attributes of face @var{face} | 2055 | This function sets one or more attributes of face @var{face} for frame |
| 2058 | for frame @var{frame}. If @var{frame} is @code{nil}, it sets | 2056 | @var{frame}. The attributes you specify this way override whatever |
| 2059 | the attribute for all frames, and the defaults for new frames. | 2057 | the @code{defface} says. |
| 2060 | 2058 | ||
| 2061 | The extra arguments @var{arguments} specify the attributes to set, and | 2059 | The extra arguments @var{arguments} specify the attributes to set, and |
| 2062 | the values for them. They should consist of alternating attribute names | 2060 | the values for them. They should consist of alternating attribute names |
| @@ -2073,6 +2071,13 @@ Thus, | |||
| 2073 | @noindent | 2071 | @noindent |
| 2074 | sets the attributes @code{:width}, @code{:weight} and @code{:underline} | 2072 | sets the attributes @code{:width}, @code{:weight} and @code{:underline} |
| 2075 | to the corresponding values. | 2073 | to the corresponding values. |
| 2074 | |||
| 2075 | If @var{frame} is @code{t}, this function sets the default attributes | ||
| 2076 | for new frames. Default attribute values specified this way override | ||
| 2077 | the @code{defface} for newly created frames. | ||
| 2078 | |||
| 2079 | If @var{frame} is @code{nil}, this function sets the attributes for | ||
| 2080 | all existing frames, and the default for new frames. | ||
| 2076 | @end defun | 2081 | @end defun |
| 2077 | 2082 | ||
| 2078 | @defun face-attribute face attribute &optional frame inherit | 2083 | @defun face-attribute face attribute &optional frame inherit |
| @@ -2080,8 +2085,10 @@ This returns the value of the @var{attribute} attribute of face | |||
| 2080 | @var{face} on @var{frame}. If @var{frame} is @code{nil}, | 2085 | @var{face} on @var{frame}. If @var{frame} is @code{nil}, |
| 2081 | that means the selected frame (@pxref{Input Focus}). | 2086 | that means the selected frame (@pxref{Input Focus}). |
| 2082 | 2087 | ||
| 2083 | If @var{frame} is @code{t}, the value is the default for | 2088 | If @var{frame} is @code{t}, this returns whatever new-frames default |
| 2084 | @var{face} for new frames. | 2089 | value you previously specified with @code{set-face-attribute} for the |
| 2090 | @var{attribute} attribute of @var{face}. If you have not specified | ||
| 2091 | one, it returns @code{nil}. | ||
| 2085 | 2092 | ||
| 2086 | If @var{inherit} is @code{nil}, only attributes directly defined by | 2093 | If @var{inherit} is @code{nil}, only attributes directly defined by |
| 2087 | @var{face} are considered, so the return value may be | 2094 | @var{face} are considered, so the return value may be |
| @@ -2135,6 +2142,8 @@ face attribute @var{attribute}, returns @var{value1} unchanged. | |||
| 2135 | The functions above did not exist before Emacs 21. For compatibility | 2142 | The functions above did not exist before Emacs 21. For compatibility |
| 2136 | with older Emacs versions, you can use the following functions to set | 2143 | with older Emacs versions, you can use the following functions to set |
| 2137 | and examine the face attributes which existed in those versions. | 2144 | and examine the face attributes which existed in those versions. |
| 2145 | They use values of @code{t} and @code{nil} for @var{frame} | ||
| 2146 | just like @code{set-face-attribute} and @code{face-attribute}. | ||
| 2138 | 2147 | ||
| 2139 | @defun set-face-foreground face color &optional frame | 2148 | @defun set-face-foreground face color &optional frame |
| 2140 | @defunx set-face-background face color &optional frame | 2149 | @defunx set-face-background face color &optional frame |
| @@ -2191,9 +2200,10 @@ This function swaps the foreground and background colors of face | |||
| 2191 | @end defun | 2200 | @end defun |
| 2192 | 2201 | ||
| 2193 | These functions examine the attributes of a face. If you don't | 2202 | These functions examine the attributes of a face. If you don't |
| 2194 | specify @var{frame}, they refer to the default data for new frames. | 2203 | specify @var{frame}, they refer to the selected frame; @code{t} refers |
| 2195 | They return the symbol @code{unspecified} if the face doesn't define any | 2204 | to the default data for new frames. They return the symbol |
| 2196 | value for that attribute. | 2205 | @code{unspecified} if the face doesn't define any value for that |
| 2206 | attribute. | ||
| 2197 | 2207 | ||
| 2198 | @defun face-foreground face &optional frame inherit | 2208 | @defun face-foreground face &optional frame inherit |
| 2199 | @defunx face-background face &optional frame inherit | 2209 | @defunx face-background face &optional frame inherit |
diff --git a/lispref/elisp.texi b/lispref/elisp.texi index db92bdc97ee..41a2f1cdde0 100644 --- a/lispref/elisp.texi +++ b/lispref/elisp.texi | |||
| @@ -1039,8 +1039,10 @@ Operating System Interface | |||
| 1039 | * Processor Run Time:: Getting the run time used by Emacs. | 1039 | * Processor Run Time:: Getting the run time used by Emacs. |
| 1040 | * Time Calculations:: Adding, subtracting, comparing times, etc. | 1040 | * Time Calculations:: Adding, subtracting, comparing times, etc. |
| 1041 | * Timers:: Setting a timer to call a function at a certain time. | 1041 | * Timers:: Setting a timer to call a function at a certain time. |
| 1042 | * Terminal Input:: Recording terminal input for debugging. | 1042 | * Idle Timers:: Setting a timer to call a function when Emacs has |
| 1043 | * Terminal Output:: Recording terminal output for debugging. | 1043 | been idle for a certain length of time. |
| 1044 | * Terminal Input:: Accessing and recordingo terminal input. | ||
| 1045 | * Terminal Output:: Controlling and recording terminal output. | ||
| 1044 | * Sound Output:: Playing sounds on the computer's speaker. | 1046 | * Sound Output:: Playing sounds on the computer's speaker. |
| 1045 | * X11 Keysyms:: Operating on key symbols for X Windows | 1047 | * X11 Keysyms:: Operating on key symbols for X Windows |
| 1046 | * Batch Mode:: Running Emacs without terminal interaction. | 1048 | * Batch Mode:: Running Emacs without terminal interaction. |
diff --git a/lispref/keymaps.texi b/lispref/keymaps.texi index f93c94b8dfe..13f4550a082 100644 --- a/lispref/keymaps.texi +++ b/lispref/keymaps.texi | |||
| @@ -33,6 +33,7 @@ found. The whole process is called @dfn{key lookup}. | |||
| 33 | * Functions for Key Lookup:: How to request key lookup. | 33 | * Functions for Key Lookup:: How to request key lookup. |
| 34 | * Changing Key Bindings:: Redefining a key in a keymap. | 34 | * Changing Key Bindings:: Redefining a key in a keymap. |
| 35 | * Remapping Commands:: Bindings that translate one command to another. | 35 | * Remapping Commands:: Bindings that translate one command to another. |
| 36 | * Translation Keymaps:: Keymaps for translating sequences of events. | ||
| 36 | * Key Binding Commands:: Interactive interfaces for redefining keys. | 37 | * Key Binding Commands:: Interactive interfaces for redefining keys. |
| 37 | * Scanning Keymaps:: Looking through all keymaps, for printing help. | 38 | * Scanning Keymaps:: Looking through all keymaps, for printing help. |
| 38 | * Menu Keymaps:: Defining a menu as a keymap. | 39 | * Menu Keymaps:: Defining a menu as a keymap. |
| @@ -642,7 +643,7 @@ only when the mode is used for the first time in a session. | |||
| 642 | and exit commands. @xref{Intro to Minibuffers}. | 643 | and exit commands. @xref{Intro to Minibuffers}. |
| 643 | 644 | ||
| 644 | Emacs has other keymaps that are used in a different way---translating | 645 | Emacs has other keymaps that are used in a different way---translating |
| 645 | events within @code{read-key-sequence}. @xref{Translating Input}. | 646 | events within @code{read-key-sequence}. @xref{Translation Keymaps}. |
| 646 | 647 | ||
| 647 | @xref{Standard Keymaps}, for a list of standard keymaps. | 648 | @xref{Standard Keymaps}, for a list of standard keymaps. |
| 648 | 649 | ||
| @@ -682,7 +683,7 @@ An error is signaled if @var{key} is not a string or a vector. | |||
| 682 | @node Searching Keymaps | 683 | @node Searching Keymaps |
| 683 | @section Searching the Active Keymaps | 684 | @section Searching the Active Keymaps |
| 684 | 685 | ||
| 685 | After translation of the input events (@pxref{Translating Input}) | 686 | After translation of event subsequences (@pxref{Translation Keymaps}) |
| 686 | Emacs looks for them in the active keymaps. Here is a pseudo-Lisp | 687 | Emacs looks for them in the active keymaps. Here is a pseudo-Lisp |
| 687 | description of the order in which the active keymaps are searched: | 688 | description of the order in which the active keymaps are searched: |
| 688 | 689 | ||
| @@ -1472,6 +1473,125 @@ given the current active keymaps. If @var{command} is not remapped | |||
| 1472 | @code{nil}. | 1473 | @code{nil}. |
| 1473 | @end defun | 1474 | @end defun |
| 1474 | 1475 | ||
| 1476 | @node Translation Keymaps | ||
| 1477 | @section Keymaps for Translating Sequences of Events | ||
| 1478 | |||
| 1479 | This section describes keymaps that are used during reading a key | ||
| 1480 | sequence, to translate certain event sequences into others. | ||
| 1481 | @code{read-key-sequence} checks every subsequence of the key sequence | ||
| 1482 | being read, as it is read, against @code{function-key-map} and then | ||
| 1483 | against @code{key-translation-map}. | ||
| 1484 | |||
| 1485 | @defvar function-key-map | ||
| 1486 | This variable holds a keymap that describes the character sequences sent | ||
| 1487 | by function keys on an ordinary character terminal. This keymap has the | ||
| 1488 | same structure as other keymaps, but is used differently: it specifies | ||
| 1489 | translations to make while reading key sequences, rather than bindings | ||
| 1490 | for key sequences. | ||
| 1491 | |||
| 1492 | If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector | ||
| 1493 | @var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a | ||
| 1494 | key sequence, it is replaced with the events in @var{v}. | ||
| 1495 | |||
| 1496 | For example, VT100 terminals send @kbd{@key{ESC} O P} when the | ||
| 1497 | keypad @key{PF1} key is pressed. Therefore, we want Emacs to translate | ||
| 1498 | that sequence of events into the single event @code{pf1}. We accomplish | ||
| 1499 | this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in | ||
| 1500 | @code{function-key-map}, when using a VT100. | ||
| 1501 | |||
| 1502 | Thus, typing @kbd{C-c @key{PF1}} sends the character sequence @kbd{C-c | ||
| 1503 | @key{ESC} O P}; later the function @code{read-key-sequence} translates | ||
| 1504 | this back into @kbd{C-c @key{PF1}}, which it returns as the vector | ||
| 1505 | @code{[?\C-c pf1]}. | ||
| 1506 | |||
| 1507 | Entries in @code{function-key-map} are ignored if they conflict with | ||
| 1508 | bindings made in the minor mode, local, or global keymaps. The intent | ||
| 1509 | is that the character sequences that function keys send should not have | ||
| 1510 | command bindings in their own right---but if they do, the ordinary | ||
| 1511 | bindings take priority. | ||
| 1512 | |||
| 1513 | The value of @code{function-key-map} is usually set up automatically | ||
| 1514 | according to the terminal's Terminfo or Termcap entry, but sometimes | ||
| 1515 | those need help from terminal-specific Lisp files. Emacs comes with | ||
| 1516 | terminal-specific files for many common terminals; their main purpose is | ||
| 1517 | to make entries in @code{function-key-map} beyond those that can be | ||
| 1518 | deduced from Termcap and Terminfo. @xref{Terminal-Specific}. | ||
| 1519 | @end defvar | ||
| 1520 | |||
| 1521 | @defvar key-translation-map | ||
| 1522 | This variable is another keymap used just like @code{function-key-map} | ||
| 1523 | to translate input events into other events. It differs from | ||
| 1524 | @code{function-key-map} in two ways: | ||
| 1525 | |||
| 1526 | @itemize @bullet | ||
| 1527 | @item | ||
| 1528 | @code{key-translation-map} goes to work after @code{function-key-map} is | ||
| 1529 | finished; it receives the results of translation by | ||
| 1530 | @code{function-key-map}. | ||
| 1531 | |||
| 1532 | @item | ||
| 1533 | Non-prefix bindings in @code{key-translation-map} override actual key | ||
| 1534 | bindings. For example, if @kbd{C-x f} has a non-prefix binding in | ||
| 1535 | @code{key-translation-map}, that translation takes effect even though | ||
| 1536 | @kbd{C-x f} also has a key binding in the global map. | ||
| 1537 | @end itemize | ||
| 1538 | |||
| 1539 | Note however that actual key bindings can have an effect on | ||
| 1540 | @code{key-translation-map}, even though they are overridden by it. | ||
| 1541 | Indeed, actual key bindings override @code{function-key-map} and thus | ||
| 1542 | may alter the key sequence that @code{key-translation-map} receives. | ||
| 1543 | Clearly, it is better to avoid this type of situation. | ||
| 1544 | |||
| 1545 | The intent of @code{key-translation-map} is for users to map one | ||
| 1546 | character set to another, including ordinary characters normally bound | ||
| 1547 | to @code{self-insert-command}. | ||
| 1548 | @end defvar | ||
| 1549 | |||
| 1550 | @cindex key translation function | ||
| 1551 | You can use @code{function-key-map} or @code{key-translation-map} for | ||
| 1552 | more than simple aliases, by using a function, instead of a key | ||
| 1553 | sequence, as the ``translation'' of a key. Then this function is called | ||
| 1554 | to compute the translation of that key. | ||
| 1555 | |||
| 1556 | The key translation function receives one argument, which is the prompt | ||
| 1557 | that was specified in @code{read-key-sequence}---or @code{nil} if the | ||
| 1558 | key sequence is being read by the editor command loop. In most cases | ||
| 1559 | you can ignore the prompt value. | ||
| 1560 | |||
| 1561 | If the function reads input itself, it can have the effect of altering | ||
| 1562 | the event that follows. For example, here's how to define @kbd{C-c h} | ||
| 1563 | to turn the character that follows into a Hyper character: | ||
| 1564 | |||
| 1565 | @example | ||
| 1566 | @group | ||
| 1567 | (defun hyperify (prompt) | ||
| 1568 | (let ((e (read-event))) | ||
| 1569 | (vector (if (numberp e) | ||
| 1570 | (logior (lsh 1 24) e) | ||
| 1571 | (if (memq 'hyper (event-modifiers e)) | ||
| 1572 | e | ||
| 1573 | (add-event-modifier "H-" e)))))) | ||
| 1574 | |||
| 1575 | (defun add-event-modifier (string e) | ||
| 1576 | (let ((symbol (if (symbolp e) e (car e)))) | ||
| 1577 | (setq symbol (intern (concat string | ||
| 1578 | (symbol-name symbol)))) | ||
| 1579 | @end group | ||
| 1580 | @group | ||
| 1581 | (if (symbolp e) | ||
| 1582 | symbol | ||
| 1583 | (cons symbol (cdr e))))) | ||
| 1584 | |||
| 1585 | (define-key function-key-map "\C-ch" 'hyperify) | ||
| 1586 | @end group | ||
| 1587 | @end example | ||
| 1588 | |||
| 1589 | If you have enabled keyboard character set decoding using | ||
| 1590 | @code{set-keyboard-coding-system}, decoding is done after the | ||
| 1591 | translations listed above. @xref{Terminal I/O Encoding}. However, in | ||
| 1592 | future Emacs versions, character set decoding may be done at an | ||
| 1593 | earlier stage. | ||
| 1594 | |||
| 1475 | @node Key Binding Commands | 1595 | @node Key Binding Commands |
| 1476 | @section Commands for Binding Keys | 1596 | @section Commands for Binding Keys |
| 1477 | 1597 | ||
| @@ -1896,7 +2016,7 @@ binding, like this: | |||
| 1896 | 2016 | ||
| 1897 | @c This line is not too long--rms. | 2017 | @c This line is not too long--rms. |
| 1898 | @example | 2018 | @example |
| 1899 | (@var{item-string} @r{[}@var{help-string}@r{]} (@var{key-binding-data}) . @var{real-binding}) | 2019 | (@var{item-string} @r{[}@var{help}@r{]} (@var{key-binding-data}) . @var{real-binding}) |
| 1900 | @end example | 2020 | @end example |
| 1901 | 2021 | ||
| 1902 | @noindent | 2022 | @noindent |
| @@ -2020,6 +2140,13 @@ operates on menu data structures, so you should write it so it can | |||
| 2020 | safely be called at any time. | 2140 | safely be called at any time. |
| 2021 | @end table | 2141 | @end table |
| 2022 | 2142 | ||
| 2143 | When an equivalent key binding is cached, the binding looks like this. | ||
| 2144 | |||
| 2145 | @example | ||
| 2146 | (menu-item @var{item-name} @var{real-binding} (@var{key-binding-data}) | ||
| 2147 | . @var{item-property-list}) | ||
| 2148 | @end example | ||
| 2149 | |||
| 2023 | @node Menu Separators | 2150 | @node Menu Separators |
| 2024 | @subsubsection Menu Separators | 2151 | @subsubsection Menu Separators |
| 2025 | @cindex menu separators | 2152 | @cindex menu separators |
diff --git a/lispref/lists.texi b/lispref/lists.texi index cb60baef900..1c6247d818c 100644 --- a/lispref/lists.texi +++ b/lispref/lists.texi | |||
| @@ -1489,7 +1489,7 @@ several @code{equal} occurrences of an element in @var{list}, | |||
| 1489 | @code{delete-dups} keeps the first one. | 1489 | @code{delete-dups} keeps the first one. |
| 1490 | @end defun | 1490 | @end defun |
| 1491 | 1491 | ||
| 1492 | See also the function @code{add-to-list}, in @ref{Setting Variables}, | 1492 | See also the function @code{add-to-list}, in @ref{List Variables}, |
| 1493 | for another way to add an element to a list stored in a variable. | 1493 | for another way to add an element to a list stored in a variable. |
| 1494 | 1494 | ||
| 1495 | @node Association Lists | 1495 | @node Association Lists |
diff --git a/lispref/maps.texi b/lispref/maps.texi index ec7728f7840..cdbd655eb3c 100644 --- a/lispref/maps.texi +++ b/lispref/maps.texi | |||
| @@ -115,7 +115,7 @@ Properties menu. | |||
| 115 | @item function-key-map | 115 | @item function-key-map |
| 116 | The keymap for translating keypad and function keys.@* | 116 | The keymap for translating keypad and function keys.@* |
| 117 | If there are none, then it contains an empty sparse keymap. | 117 | If there are none, then it contains an empty sparse keymap. |
| 118 | @xref{Translating Input}. | 118 | @xref{Translation Keymaps}. |
| 119 | 119 | ||
| 120 | @item fundamental-mode-map | 120 | @item fundamental-mode-map |
| 121 | @vindex fundamental-mode-map | 121 | @vindex fundamental-mode-map |
| @@ -158,7 +158,7 @@ search. | |||
| 158 | 158 | ||
| 159 | @item key-translation-map | 159 | @item key-translation-map |
| 160 | A keymap for translating keys. This one overrides ordinary key | 160 | A keymap for translating keys. This one overrides ordinary key |
| 161 | bindings, unlike @code{function-key-map}. @xref{Translating Input}. | 161 | bindings, unlike @code{function-key-map}. @xref{Translation Keymaps}. |
| 162 | 162 | ||
| 163 | @item kmacro-map | 163 | @item kmacro-map |
| 164 | @vindex kmacro-map | 164 | @vindex kmacro-map |
diff --git a/lispref/modes.texi b/lispref/modes.texi index b0c057ec1c9..f8afcd8a829 100644 --- a/lispref/modes.texi +++ b/lispref/modes.texi | |||
| @@ -43,18 +43,19 @@ up in the init file (@pxref{Init File}), but Lisp programs can set them also. | |||
| 43 | 43 | ||
| 44 | @cindex normal hook | 44 | @cindex normal hook |
| 45 | Most of the hooks in Emacs are @dfn{normal hooks}. These variables | 45 | Most of the hooks in Emacs are @dfn{normal hooks}. These variables |
| 46 | contain lists of functions to be called with no arguments. When the | 46 | contain lists of functions to be called with no arguments. By |
| 47 | hook name ends in @samp{-hook}, that tells you it is normal. We try to | 47 | convention, whenever the hook name ends in @samp{-hook}, that tells |
| 48 | make all hooks normal, as much as possible, so that you can use them in | 48 | you it is normal. We try to make all hooks normal, as much as |
| 49 | a uniform way. | 49 | possible, so that you can use them in a uniform way. |
| 50 | 50 | ||
| 51 | Every major mode function is supposed to run a normal hook called the | 51 | Every major mode function is supposed to run a normal hook called |
| 52 | @dfn{mode hook} as the last step of initialization. This makes it easy | 52 | the @dfn{mode hook} as the one of the last steps of initialization. |
| 53 | for a user to customize the behavior of the mode, by overriding the | 53 | This makes it easy for a user to customize the behavior of the mode, |
| 54 | buffer-local variable assignments already made by the mode. Most | 54 | by overriding the buffer-local variable assignments already made by |
| 55 | minor modes also run a mode hook at their end. But hooks are used in | 55 | the mode. Most minor mode functions also run a mode hook at the end. |
| 56 | other contexts too. For example, the hook @code{suspend-hook} runs | 56 | But hooks are used in other contexts too. For example, the hook |
| 57 | just before Emacs suspends itself (@pxref{Suspending Emacs}). | 57 | @code{suspend-hook} runs just before Emacs suspends itself |
| 58 | (@pxref{Suspending Emacs}). | ||
| 58 | 59 | ||
| 59 | The recommended way to add a hook function to a normal hook is by | 60 | The recommended way to add a hook function to a normal hook is by |
| 60 | calling @code{add-hook} (see below). The hook functions may be any of | 61 | calling @code{add-hook} (see below). The hook functions may be any of |
| @@ -65,20 +66,16 @@ globally or buffer-locally with @code{add-hook}. | |||
| 65 | 66 | ||
| 66 | @cindex abnormal hook | 67 | @cindex abnormal hook |
| 67 | If the hook variable's name does not end with @samp{-hook}, that | 68 | If the hook variable's name does not end with @samp{-hook}, that |
| 68 | indicates it is probably an @dfn{abnormal hook}. Then you should look at its | 69 | indicates it is probably an @dfn{abnormal hook}. That means the hook |
| 69 | documentation to see how to use the hook properly. | 70 | functions are called with arguments, or their return values are used |
| 71 | in some way. The hook's documentation says how the functions are | ||
| 72 | called. You can use @code{add-hook} to add a function to an abnormal | ||
| 73 | hook, but you must write the function to follow the hook's calling | ||
| 74 | convention. | ||
| 70 | 75 | ||
| 71 | If the variable's name ends in @samp{-functions} or @samp{-hooks}, | 76 | By convention, abnormal hook names end in @samp{-functions} or |
| 72 | then the value is a list of functions, but it is abnormal in that either | 77 | @samp{-hooks}. If the variable's name ends in @samp{-function}, then |
| 73 | these functions are called with arguments or their values are used in | 78 | its value is just a single function, not a list of functions. |
| 74 | some way. You can use @code{add-hook} to add a function to the list, | ||
| 75 | but you must take care in writing the function. (A few of these | ||
| 76 | variables, notably those ending in @samp{-hooks}, are actually | ||
| 77 | normal hooks which were named before we established the convention of | ||
| 78 | using @samp{-hook} for them.) | ||
| 79 | |||
| 80 | If the variable's name ends in @samp{-function}, then its value | ||
| 81 | is just a single function, not a list of functions. | ||
| 82 | 79 | ||
| 83 | Here's an example that uses a mode hook to turn on Auto Fill mode when | 80 | Here's an example that uses a mode hook to turn on Auto Fill mode when |
| 84 | in Lisp Interaction mode: | 81 | in Lisp Interaction mode: |
| @@ -96,12 +93,13 @@ arguments, and runs each hook in turn. Each argument should be a | |||
| 96 | symbol that is a normal hook variable. These arguments are processed | 93 | symbol that is a normal hook variable. These arguments are processed |
| 97 | in the order specified. | 94 | in the order specified. |
| 98 | 95 | ||
| 99 | If a hook variable has a non-@code{nil} value, that value may be a | 96 | If a hook variable has a non-@code{nil} value, that value should be a |
| 100 | function or a list of functions. (The former option is considered | 97 | list of functions. @code{run-hooks} calls all the functions, one by |
| 101 | obsolete.) If the value is a function (either a lambda expression or | 98 | one, with no arguments. |
| 102 | a symbol with a function definition), it is called. If it is a list | 99 | |
| 103 | that isn't a function, its elements are called, consecutively. All | 100 | The hook variable's value can also be a single function---either a |
| 104 | the hook functions are called with no arguments. | 101 | lambda expression or a symbol with a function definition---which |
| 102 | @code{run-hooks} calls. But this usage is obsolete. | ||
| 105 | @end defun | 103 | @end defun |
| 106 | 104 | ||
| 107 | @defun run-hook-with-args hook &rest args | 105 | @defun run-hook-with-args hook &rest args |
| @@ -187,7 +185,6 @@ to another major mode in the same buffer. | |||
| 187 | @menu | 185 | @menu |
| 188 | * Major Mode Basics:: | 186 | * Major Mode Basics:: |
| 189 | * Major Mode Conventions:: Coding conventions for keymaps, etc. | 187 | * Major Mode Conventions:: Coding conventions for keymaps, etc. |
| 190 | * Example Major Modes:: Text mode and Lisp modes. | ||
| 191 | * Auto Major Mode:: How Emacs chooses the major mode automatically. | 188 | * Auto Major Mode:: How Emacs chooses the major mode automatically. |
| 192 | * Mode Help:: Finding out how to use a mode. | 189 | * Mode Help:: Finding out how to use a mode. |
| 193 | * Derived Modes:: Defining a new major mode based on another major | 190 | * Derived Modes:: Defining a new major mode based on another major |
| @@ -195,6 +192,7 @@ to another major mode in the same buffer. | |||
| 195 | * Generic Modes:: Defining a simple major mode that supports | 192 | * Generic Modes:: Defining a simple major mode that supports |
| 196 | comment syntax and Font Lock mode. | 193 | comment syntax and Font Lock mode. |
| 197 | * Mode Hooks:: Hooks run at the end of major mode functions. | 194 | * Mode Hooks:: Hooks run at the end of major mode functions. |
| 195 | * Example Major Modes:: Text mode and Lisp modes. | ||
| 198 | @end menu | 196 | @end menu |
| 199 | 197 | ||
| 200 | @node Major Mode Basics | 198 | @node Major Mode Basics |
| @@ -214,14 +212,14 @@ specialized editing task, creating a new major mode is usually a good | |||
| 214 | idea. In practice, writing a major mode is easy (in contrast to | 212 | idea. In practice, writing a major mode is easy (in contrast to |
| 215 | writing a minor mode, which is often difficult). | 213 | writing a minor mode, which is often difficult). |
| 216 | 214 | ||
| 217 | If the new mode is similar to an old one, it is often unwise to modify | 215 | If the new mode is similar to an old one, it is often unwise to |
| 218 | the old one to serve two purposes, since it may become harder to use and | 216 | modify the old one to serve two purposes, since it may become harder |
| 219 | maintain. Instead, copy and rename an existing major mode definition | 217 | to use and maintain. Instead, copy and rename an existing major mode |
| 220 | and alter the copy---or define a @dfn{derived mode} (@pxref{Derived | 218 | definition and alter the copy---or use @code{define-derived-mode} to |
| 221 | Modes}). For example, Rmail Edit mode, which is in | 219 | define a @dfn{derived mode} (@pxref{Derived Modes}). For example, |
| 222 | @file{emacs/lisp/mail/rmailedit.el}, is a major mode that is very similar to | 220 | Rmail Edit mode is a major mode that is very similar to Text mode |
| 223 | Text mode except that it provides two additional commands. Its | 221 | except that it provides two additional commands. Its definition is |
| 224 | definition is distinct from that of Text mode, but uses that of Text mode. | 222 | distinct from that of Text mode, but uses that of Text mode. |
| 225 | 223 | ||
| 226 | Even if the new mode is not an obvious derivative of any other mode, | 224 | Even if the new mode is not an obvious derivative of any other mode, |
| 227 | it is convenient to use @code{define-derived-mode} with a @code{nil} | 225 | it is convenient to use @code{define-derived-mode} with a @code{nil} |
| @@ -287,8 +285,10 @@ Documentation}. | |||
| 287 | 285 | ||
| 288 | @item | 286 | @item |
| 289 | The major mode command should start by calling | 287 | The major mode command should start by calling |
| 290 | @code{kill-all-local-variables}. This is what gets rid of the | 288 | @code{kill-all-local-variables}. This runs the normal hook |
| 291 | buffer-local variables of the major mode previously in effect. | 289 | @code{change-major-mode-hook}, then gets rid of the buffer-local |
| 290 | variables of the major mode previously in effect. @xref{Creating | ||
| 291 | Buffer-Local}. | ||
| 292 | 292 | ||
| 293 | @item | 293 | @item |
| 294 | The major mode command should set the variable @code{major-mode} to the | 294 | The major mode command should set the variable @code{major-mode} to the |
| @@ -355,9 +355,11 @@ Rmail that do not allow self-insertion of text can reasonably redefine | |||
| 355 | letters and other printing characters as special commands. | 355 | letters and other printing characters as special commands. |
| 356 | 356 | ||
| 357 | @item | 357 | @item |
| 358 | Major modes must not define @key{RET} to do anything other than insert | 358 | Major modes modes for editing text should not define @key{RET} to do |
| 359 | a newline. The command to insert a newline and then indent is | 359 | anything other than insert a newline. However, it is ok for |
| 360 | @kbd{C-j}. Please keep this distinction uniform for all major modes. | 360 | specialized modes for text that users don't directly edit, such as |
| 361 | Dired and Info modes, to redefine @key{RET} to do something entirely | ||
| 362 | different. | ||
| 361 | 363 | ||
| 362 | @item | 364 | @item |
| 363 | Major modes should not alter options that are primarily a matter of user | 365 | Major modes should not alter options that are primarily a matter of user |
| @@ -427,10 +429,11 @@ other packages would interfere with them. | |||
| 427 | @item | 429 | @item |
| 428 | @cindex mode hook | 430 | @cindex mode hook |
| 429 | @cindex major mode hook | 431 | @cindex major mode hook |
| 430 | Each major mode should have a @dfn{mode hook} named | 432 | Each major mode should have a normal @dfn{mode hook} named |
| 431 | @code{@var{modename}-mode-hook}. The major mode command should run that | 433 | @code{@var{modename}-mode-hook}. The very last thing the major mode command |
| 432 | hook, with @code{run-mode-hooks}, as the very last thing it | 434 | should do is to call @code{run-mode-hooks}. This runs the mode hook, |
| 433 | does. @xref{Mode Hooks}. | 435 | and then runs the normal hook @code{after-change-major-mode-hook}. |
| 436 | @xref{Mode Hooks}. | ||
| 434 | 437 | ||
| 435 | @item | 438 | @item |
| 436 | The major mode command may start by calling some other major mode | 439 | The major mode command may start by calling some other major mode |
| @@ -488,281 +491,6 @@ that they may be evaluated more than once without adverse consequences. | |||
| 488 | Even if you never load the file more than once, someone else will. | 491 | Even if you never load the file more than once, someone else will. |
| 489 | @end itemize | 492 | @end itemize |
| 490 | 493 | ||
| 491 | @node Example Major Modes | ||
| 492 | @subsection Major Mode Examples | ||
| 493 | |||
| 494 | Text mode is perhaps the simplest mode besides Fundamental mode. | ||
| 495 | Here are excerpts from @file{text-mode.el} that illustrate many of | ||
| 496 | the conventions listed above: | ||
| 497 | |||
| 498 | @smallexample | ||
| 499 | @group | ||
| 500 | ;; @r{Create the syntax table for this mode.} | ||
| 501 | (defvar text-mode-syntax-table | ||
| 502 | (let ((st (make-syntax-table))) | ||
| 503 | (modify-syntax-entry ?\" ". " st) | ||
| 504 | (modify-syntax-entry ?\\ ". " st) | ||
| 505 | ;; Add `p' so M-c on `hello' leads to `Hello', not `hello'. | ||
| 506 | (modify-syntax-entry ?' "w p" st) | ||
| 507 | st) | ||
| 508 | "Syntax table used while in `text-mode'.") | ||
| 509 | @end group | ||
| 510 | |||
| 511 | ;; @r{Create the keymap for this mode.} | ||
| 512 | @group | ||
| 513 | (defvar text-mode-map | ||
| 514 | (let ((map (make-sparse-keymap))) | ||
| 515 | (define-key map "\e\t" 'ispell-complete-word) | ||
| 516 | (define-key map "\es" 'center-line) | ||
| 517 | (define-key map "\eS" 'center-paragraph) | ||
| 518 | map) | ||
| 519 | "Keymap for `text-mode'. | ||
| 520 | Many other modes, such as Mail mode, Outline mode | ||
| 521 | and Indented Text mode, inherit all the commands | ||
| 522 | defined in this map.") | ||
| 523 | @end group | ||
| 524 | @end smallexample | ||
| 525 | |||
| 526 | Here is how the actual mode command is defined now: | ||
| 527 | |||
| 528 | @smallexample | ||
| 529 | @group | ||
| 530 | (define-derived-mode text-mode nil "Text" | ||
| 531 | "Major mode for editing text written for humans to read. | ||
| 532 | In this mode, paragraphs are delimited only by blank or white lines. | ||
| 533 | You can thus get the full benefit of adaptive filling | ||
| 534 | (see the variable `adaptive-fill-mode'). | ||
| 535 | \\@{text-mode-map@} | ||
| 536 | Turning on Text mode runs the normal hook `text-mode-hook'." | ||
| 537 | @end group | ||
| 538 | @group | ||
| 539 | (make-local-variable 'text-mode-variant) | ||
| 540 | (setq text-mode-variant t) | ||
| 541 | ;; @r{These two lines are a feature added recently.} | ||
| 542 | (set (make-local-variable 'require-final-newline) | ||
| 543 | mode-require-final-newline) | ||
| 544 | (set (make-local-variable 'indent-line-function) 'indent-relative)) | ||
| 545 | @end group | ||
| 546 | @end smallexample | ||
| 547 | |||
| 548 | But here is how it was defined formerly, before | ||
| 549 | @code{define-derived-mode} existed: | ||
| 550 | |||
| 551 | @smallexample | ||
| 552 | @group | ||
| 553 | ;; @r{This isn't needed nowadays, since @code{define-derived-mode} does it.} | ||
| 554 | (defvar text-mode-abbrev-table nil | ||
| 555 | "Abbrev table used while in text mode.") | ||
| 556 | (define-abbrev-table 'text-mode-abbrev-table ()) | ||
| 557 | @end group | ||
| 558 | |||
| 559 | @group | ||
| 560 | (defun text-mode () | ||
| 561 | "Major mode for editing text intended for humans to read... | ||
| 562 | Special commands: \\@{text-mode-map@} | ||
| 563 | @end group | ||
| 564 | @group | ||
| 565 | Turning on text-mode runs the hook `text-mode-hook'." | ||
| 566 | (interactive) | ||
| 567 | (kill-all-local-variables) | ||
| 568 | (use-local-map text-mode-map) | ||
| 569 | @end group | ||
| 570 | @group | ||
| 571 | (setq local-abbrev-table text-mode-abbrev-table) | ||
| 572 | (set-syntax-table text-mode-syntax-table) | ||
| 573 | @end group | ||
| 574 | @group | ||
| 575 | ;; @r{These four lines are absent from the current version} | ||
| 576 | ;; @r{not because this is done some other way, but rather} | ||
| 577 | ;; @r{because nowadays Text mode uses the normal definition of paragraphs.} | ||
| 578 | (make-local-variable 'paragraph-start) | ||
| 579 | (setq paragraph-start (concat "[ \t]*$\\|" page-delimiter)) | ||
| 580 | (make-local-variable 'paragraph-separate) | ||
| 581 | (setq paragraph-separate paragraph-start) | ||
| 582 | (make-local-variable 'indent-line-function) | ||
| 583 | (setq indent-line-function 'indent-relative-maybe) | ||
| 584 | @end group | ||
| 585 | @group | ||
| 586 | (setq mode-name "Text") | ||
| 587 | (setq major-mode 'text-mode) | ||
| 588 | (run-mode-hooks 'text-mode-hook)) ; @r{Finally, this permits the user to} | ||
| 589 | ; @r{customize the mode with a hook.} | ||
| 590 | @end group | ||
| 591 | @end smallexample | ||
| 592 | |||
| 593 | @cindex @file{lisp-mode.el} | ||
| 594 | The three Lisp modes (Lisp mode, Emacs Lisp mode, and Lisp | ||
| 595 | Interaction mode) have more features than Text mode and the code is | ||
| 596 | correspondingly more complicated. Here are excerpts from | ||
| 597 | @file{lisp-mode.el} that illustrate how these modes are written. | ||
| 598 | |||
| 599 | @cindex syntax table example | ||
| 600 | @smallexample | ||
| 601 | @group | ||
| 602 | ;; @r{Create mode-specific table variables.} | ||
| 603 | (defvar lisp-mode-syntax-table nil "") | ||
| 604 | (defvar lisp-mode-abbrev-table nil "") | ||
| 605 | @end group | ||
| 606 | |||
| 607 | @group | ||
| 608 | (defvar emacs-lisp-mode-syntax-table | ||
| 609 | (let ((table (make-syntax-table))) | ||
| 610 | (let ((i 0)) | ||
| 611 | @end group | ||
| 612 | |||
| 613 | @group | ||
| 614 | ;; @r{Set syntax of chars up to @samp{0} to say they are} | ||
| 615 | ;; @r{part of symbol names but not words.} | ||
| 616 | ;; @r{(The digit @samp{0} is @code{48} in the @acronym{ASCII} character set.)} | ||
| 617 | (while (< i ?0) | ||
| 618 | (modify-syntax-entry i "_ " table) | ||
| 619 | (setq i (1+ i))) | ||
| 620 | ;; @r{@dots{} similar code follows for other character ranges.} | ||
| 621 | @end group | ||
| 622 | @group | ||
| 623 | ;; @r{Then set the syntax codes for characters that are special in Lisp.} | ||
| 624 | (modify-syntax-entry ? " " table) | ||
| 625 | (modify-syntax-entry ?\t " " table) | ||
| 626 | (modify-syntax-entry ?\f " " table) | ||
| 627 | (modify-syntax-entry ?\n "> " table) | ||
| 628 | @end group | ||
| 629 | @group | ||
| 630 | ;; @r{Give CR the same syntax as newline, for selective-display.} | ||
| 631 | (modify-syntax-entry ?\^m "> " table) | ||
| 632 | (modify-syntax-entry ?\; "< " table) | ||
| 633 | (modify-syntax-entry ?` "' " table) | ||
| 634 | (modify-syntax-entry ?' "' " table) | ||
| 635 | (modify-syntax-entry ?, "' " table) | ||
| 636 | @end group | ||
| 637 | @group | ||
| 638 | ;; @r{@dots{}likewise for many other characters@dots{}} | ||
| 639 | (modify-syntax-entry ?\( "() " table) | ||
| 640 | (modify-syntax-entry ?\) ")( " table) | ||
| 641 | (modify-syntax-entry ?\[ "(] " table) | ||
| 642 | (modify-syntax-entry ?\] ")[ " table)) | ||
| 643 | table)) | ||
| 644 | @end group | ||
| 645 | @group | ||
| 646 | ;; @r{Create an abbrev table for lisp-mode.} | ||
| 647 | (define-abbrev-table 'lisp-mode-abbrev-table ()) | ||
| 648 | @end group | ||
| 649 | @end smallexample | ||
| 650 | |||
| 651 | Much code is shared among the three Lisp modes. The following | ||
| 652 | function sets various variables; it is called by each of the major Lisp | ||
| 653 | mode functions: | ||
| 654 | |||
| 655 | @smallexample | ||
| 656 | @group | ||
| 657 | (defun lisp-mode-variables (lisp-syntax) | ||
| 658 | (when lisp-syntax | ||
| 659 | (set-syntax-table lisp-mode-syntax-table)) | ||
| 660 | (setq local-abbrev-table lisp-mode-abbrev-table) | ||
| 661 | @dots{} | ||
| 662 | @end group | ||
| 663 | @end smallexample | ||
| 664 | |||
| 665 | Functions such as @code{forward-paragraph} use the value of the | ||
| 666 | @code{paragraph-start} variable. Since Lisp code is different from | ||
| 667 | ordinary text, the @code{paragraph-start} variable needs to be set | ||
| 668 | specially to handle Lisp. Also, comments are indented in a special | ||
| 669 | fashion in Lisp and the Lisp modes need their own mode-specific | ||
| 670 | @code{comment-indent-function}. The code to set these variables is the | ||
| 671 | rest of @code{lisp-mode-variables}. | ||
| 672 | |||
| 673 | @smallexample | ||
| 674 | @group | ||
| 675 | (make-local-variable 'paragraph-start) | ||
| 676 | (setq paragraph-start (concat page-delimiter "\\|$" )) | ||
| 677 | (make-local-variable 'paragraph-separate) | ||
| 678 | (setq paragraph-separate paragraph-start) | ||
| 679 | @dots{} | ||
| 680 | @end group | ||
| 681 | @group | ||
| 682 | (make-local-variable 'comment-indent-function) | ||
| 683 | (setq comment-indent-function 'lisp-comment-indent)) | ||
| 684 | @dots{} | ||
| 685 | @end group | ||
| 686 | @end smallexample | ||
| 687 | |||
| 688 | Each of the different Lisp modes has a slightly different keymap. For | ||
| 689 | example, Lisp mode binds @kbd{C-c C-z} to @code{run-lisp}, but the other | ||
| 690 | Lisp modes do not. However, all Lisp modes have some commands in | ||
| 691 | common. The following code sets up the common commands: | ||
| 692 | |||
| 693 | @smallexample | ||
| 694 | @group | ||
| 695 | (defvar shared-lisp-mode-map () | ||
| 696 | "Keymap for commands shared by all sorts of Lisp modes.") | ||
| 697 | |||
| 698 | ;; @r{Putting this @code{if} after the @code{defvar} is an older style.} | ||
| 699 | (if shared-lisp-mode-map | ||
| 700 | () | ||
| 701 | (setq shared-lisp-mode-map (make-sparse-keymap)) | ||
| 702 | (define-key shared-lisp-mode-map "\e\C-q" 'indent-sexp) | ||
| 703 | (define-key shared-lisp-mode-map "\177" | ||
| 704 | 'backward-delete-char-untabify)) | ||
| 705 | @end group | ||
| 706 | @end smallexample | ||
| 707 | |||
| 708 | @noindent | ||
| 709 | And here is the code to set up the keymap for Lisp mode: | ||
| 710 | |||
| 711 | @smallexample | ||
| 712 | @group | ||
| 713 | (defvar lisp-mode-map () | ||
| 714 | "Keymap for ordinary Lisp mode...") | ||
| 715 | |||
| 716 | (if lisp-mode-map | ||
| 717 | () | ||
| 718 | (setq lisp-mode-map (make-sparse-keymap)) | ||
| 719 | (set-keymap-parent lisp-mode-map shared-lisp-mode-map) | ||
| 720 | (define-key lisp-mode-map "\e\C-x" 'lisp-eval-defun) | ||
| 721 | (define-key lisp-mode-map "\C-c\C-z" 'run-lisp)) | ||
| 722 | @end group | ||
| 723 | @end smallexample | ||
| 724 | |||
| 725 | Finally, here is the complete major mode function definition for | ||
| 726 | Lisp mode. | ||
| 727 | |||
| 728 | @smallexample | ||
| 729 | @group | ||
| 730 | (defun lisp-mode () | ||
| 731 | "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp. | ||
| 732 | Commands: | ||
| 733 | Delete converts tabs to spaces as it moves back. | ||
| 734 | Blank lines separate paragraphs. Semicolons start comments. | ||
| 735 | \\@{lisp-mode-map@} | ||
| 736 | Note that `run-lisp' may be used either to start an inferior Lisp job | ||
| 737 | or to switch back to an existing one. | ||
| 738 | @end group | ||
| 739 | |||
| 740 | @group | ||
| 741 | Entry to this mode calls the value of `lisp-mode-hook' | ||
| 742 | if that value is non-nil." | ||
| 743 | (interactive) | ||
| 744 | (kill-all-local-variables) | ||
| 745 | @end group | ||
| 746 | @group | ||
| 747 | (use-local-map lisp-mode-map) ; @r{Select the mode's keymap.} | ||
| 748 | (setq major-mode 'lisp-mode) ; @r{This is how @code{describe-mode}} | ||
| 749 | ; @r{finds out what to describe.} | ||
| 750 | (setq mode-name "Lisp") ; @r{This goes into the mode line.} | ||
| 751 | (lisp-mode-variables t) ; @r{This defines various variables.} | ||
| 752 | (make-local-variable 'comment-start-skip) | ||
| 753 | (setq comment-start-skip | ||
| 754 | "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *") | ||
| 755 | (make-local-variable 'font-lock-keywords-case-fold-search) | ||
| 756 | (setq font-lock-keywords-case-fold-search t) | ||
| 757 | @end group | ||
| 758 | @group | ||
| 759 | (setq imenu-case-fold-search t) | ||
| 760 | (set-syntax-table lisp-mode-syntax-table) | ||
| 761 | (run-mode-hooks 'lisp-mode-hook)) ; @r{This permits the user to use a} | ||
| 762 | ; @r{hook to customize the mode.} | ||
| 763 | @end group | ||
| 764 | @end smallexample | ||
| 765 | |||
| 766 | @node Auto Major Mode | 494 | @node Auto Major Mode |
| 767 | @subsection How Emacs Chooses a Major Mode | 495 | @subsection How Emacs Chooses a Major Mode |
| 768 | 496 | ||
| @@ -1073,104 +801,365 @@ Do not write an @code{interactive} spec in the definition; | |||
| 1073 | @subsection Generic Modes | 801 | @subsection Generic Modes |
| 1074 | @cindex generic mode | 802 | @cindex generic mode |
| 1075 | 803 | ||
| 1076 | @dfn{Generic modes} are simple major modes with basic support for | 804 | @dfn{Generic modes} are simple major modes with basic support for |
| 1077 | comment syntax and Font Lock mode. They are primarily useful for | 805 | comment syntax and Font Lock mode. To define a generic mode, use the |
| 1078 | configuration files. To define a generic mode, use the macro | 806 | macro @code{define-generic-mode}. See the file @file{generic-x.el} |
| 1079 | @code{define-generic-mode}. See the file @file{generic-x.el} for some | 807 | for some examples of the use of @code{define-generic-mode}. |
| 1080 | examples of the use of @code{define-generic-mode}. | ||
| 1081 | 808 | ||
| 1082 | @defmac define-generic-mode mode comment-list keyword-list font-lock-list auto-mode-list function-list &optional docstring | 809 | @defmac define-generic-mode mode comment-list keyword-list font-lock-list auto-mode-list function-list &optional docstring |
| 1083 | This macro creates a new generic mode. The argument @var{mode} (an | 810 | This macro defines a generic mode command named @var{mode} (a symbol, |
| 1084 | unquoted symbol) is the major mode command. The optional argument | 811 | not quoted). The optional argument @var{docstring} is the |
| 1085 | @var{docstring} is the documentation for the mode command. If you do | 812 | documentation for the mode command. If you do not supply it, |
| 1086 | not supply it, @code{define-generic-mode} uses a default documentation | 813 | @code{define-generic-mode} generates one by default. |
| 1087 | string instead. | 814 | |
| 1088 | 815 | The argument @var{comment-list} is a list in which each element is | |
| 1089 | @var{comment-list} is a list in which each element is either a | 816 | either a character, a string of one or two characters, or a cons cell. |
| 1090 | character, a string of one or two characters, or a cons cell. A | 817 | A character or a string is set up in the mode's syntax table as a |
| 1091 | character or a string is set up in the mode's syntax table as a | ||
| 1092 | ``comment starter.'' If the entry is a cons cell, the @sc{car} is set | 818 | ``comment starter.'' If the entry is a cons cell, the @sc{car} is set |
| 1093 | up as a ``comment starter'' and the @sc{cdr} as a ``comment ender.'' | 819 | up as a ``comment starter'' and the @sc{cdr} as a ``comment ender.'' |
| 1094 | (Use @code{nil} for the latter if you want comments to end at the end | 820 | (Use @code{nil} for the latter if you want comments to end at the end |
| 1095 | of the line.) Note that the syntax table has limitations about what | 821 | of the line.) Note that the syntax table mechanism has limitations |
| 1096 | comment starters and enders are actually possible. @xref{Syntax | 822 | about what comment starters and enders are actually possible. |
| 1097 | Tables}. | 823 | @xref{Syntax Tables}. |
| 1098 | 824 | ||
| 1099 | @var{keyword-list} is a list of keywords to highlight with | 825 | The argument @var{keyword-list} is a list of keywords to highlight |
| 1100 | @code{font-lock-keyword-face}. Each keyword should be a string. | 826 | with @code{font-lock-keyword-face}. Each keyword should be a string. |
| 1101 | @var{font-lock-list} is a list of additional expressions to highlight. | 827 | Meanwhile, @var{font-lock-list} is a list of additional expressions to |
| 1102 | Each element of this list should have the same form as an element of | 828 | highlight. Each element of this list should have the same form as an |
| 1103 | @code{font-lock-keywords}. @xref{Search-based Fontification}. | 829 | element of @code{font-lock-keywords}. @xref{Search-based |
| 1104 | 830 | Fontification}. | |
| 1105 | @var{auto-mode-list} is a list of regular expressions to add to the | 831 | |
| 1106 | variable @code{auto-mode-alist}. These regular expressions are added | 832 | The argument @var{auto-mode-list} is a list of regular expressions to |
| 1107 | when Emacs runs the macro expansion. | 833 | add to the variable @code{auto-mode-alist}. They are added by the execution |
| 1108 | 834 | of the @code{define-generic-mode} form, not by expanding the macro call. | |
| 1109 | @var{function-list} is a list of functions to call to do some | 835 | |
| 1110 | additional setup. The mode command calls these functions just before | 836 | Finally, @var{function-list} is a list of functions for the mode |
| 1111 | it runs the mode hook variable @code{@var{mode}-hook}. | 837 | command to call for additional setup. It calls these functions just |
| 838 | before it runs the mode hook variable @code{@var{mode}-hook}. | ||
| 1112 | @end defmac | 839 | @end defmac |
| 1113 | 840 | ||
| 1114 | @node Mode Hooks | 841 | @node Mode Hooks |
| 1115 | @subsection Mode Hooks | 842 | @subsection Mode Hooks |
| 1116 | 843 | ||
| 1117 | The two last things a major mode function should do is run its mode | 844 | Every major mode function should finish by running its mode hook and |
| 1118 | hook and finally the mode independent normal hook | 845 | the mode-independent normal hook @code{after-change-major-mode-hook}. |
| 1119 | @code{after-change-major-mode-hook}. If the major mode is a derived | 846 | It does this by calling @code{run-mode-hooks}. If the major mode is a |
| 1120 | mode, that is if it calls another major mode (the parent mode) in its | 847 | derived mode, that is if it calls another major mode (the parent mode) |
| 1121 | body, then the parent's mode hook is run just before the derived | 848 | in its body, it should do this inside @code{delay-mode-hooks} so that |
| 1122 | mode's hook. Neither the parent's mode hook nor | 849 | the parent won't run these hooks itself. Instead, the derived mode's |
| 1123 | @code{after-change-major-mode-hook} are run at the end of the actual | 850 | call to @code{run-mode-hooks} runs the parent's mode hook too. |
| 1124 | call to the parent mode. This applies recursively if the parent mode | 851 | @xref{Major Mode Conventions}. |
| 1125 | has itself a parent. That is, the mode hooks of all major modes | 852 | |
| 1126 | called directly or indirectly by the major mode function are all run | 853 | Emacs versions before Emacs 22 did not have @code{delay-mode-hooks}. |
| 1127 | in sequence at the end, just before | 854 | When user-implemented major modes have not been updated to use it, |
| 1128 | @code{after-change-major-mode-hook}. | 855 | they won't entirely follow these conventions: they may run the |
| 1129 | 856 | parent's mode hook too early, or fail to run | |
| 1130 | These conventions are new in Emacs 22, and some major modes | 857 | @code{after-change-major-mode-hook}. If you encounter such a major |
| 1131 | implemented by users do not follow them yet. So if you put a function | 858 | mode, please correct it to follow these conventions. |
| 1132 | onto @code{after-change-major-mode-hook}, keep in mind that some modes | ||
| 1133 | will fail to run it. If a user complains about that, you can respond, | ||
| 1134 | ``That major mode fails to follow Emacs conventions, and that's why it | ||
| 1135 | fails to work. Please fix the major mode.'' In most cases, that is | ||
| 1136 | good enough, so go ahead and use @code{after-change-major-mode-hook}. | ||
| 1137 | However, if a certain feature needs to be completely reliable, | ||
| 1138 | it should not use @code{after-change-major-mode-hook} as of yet. | ||
| 1139 | 859 | ||
| 1140 | When you defined a major mode using @code{define-derived-mode}, it | 860 | When you defined a major mode using @code{define-derived-mode}, it |
| 1141 | automatically makes sure these conventions are followed. If you | 861 | automatically makes sure these conventions are followed. If you |
| 1142 | define a major mode ``from scratch,'' not using | 862 | define a major mode ``by hand,'' not using @code{define-derived-mode}, |
| 1143 | @code{define-derived-mode}, make sure the major mode command follows | 863 | use the following functions to handle these conventions automatically. |
| 1144 | these and other conventions. @xref{Major Mode Conventions}. You use | ||
| 1145 | these functions to do it properly. | ||
| 1146 | 864 | ||
| 1147 | @defun run-mode-hooks &rest hookvars | 865 | @defun run-mode-hooks &rest hookvars |
| 1148 | Major modes should run their mode hook using this function. It is | 866 | Major modes should run their mode hook using this function. It is |
| 1149 | similar to @code{run-hooks} (@pxref{Hooks}), but it also runs | 867 | similar to @code{run-hooks} (@pxref{Hooks}), but it also runs |
| 1150 | @code{after-change-major-mode-hook}. | 868 | @code{after-change-major-mode-hook}. |
| 1151 | 869 | ||
| 1152 | When the call to this function is dynamically inside a | 870 | When this function is called during the execution of a |
| 1153 | @code{delay-mode-hooks} form, this function does not run any hooks. | 871 | @code{delay-mode-hooks} form, it does not run the hooks immediately. |
| 1154 | Instead, it arranges for the next call to @code{run-mode-hooks} to run | 872 | Instead, it arranges for the next call to @code{run-mode-hooks} to run |
| 1155 | @var{hookvars}. | 873 | them. |
| 1156 | @end defun | 874 | @end defun |
| 1157 | 875 | ||
| 1158 | @defmac delay-mode-hooks body@dots{} | 876 | @defmac delay-mode-hooks body@dots{} |
| 1159 | This macro executes @var{body} like @code{progn}, but all calls to | 877 | When one major mode command calls another, it should do so inside of |
| 1160 | @code{run-mode-hooks} inside @var{body} delay running their hooks. | 878 | @code{delay-mode-hooks}. |
| 1161 | They will be run by the first call to @code{run-mode-hooks} after exit | 879 | |
| 1162 | from @code{delay-mode-hooks}. This is the proper way for a major mode | 880 | This macro executes @var{body}, but tells all @code{run-mode-hooks} |
| 1163 | command to invoke its parent mode. | 881 | calls during the execution of @var{body} to delay running their hooks. |
| 882 | The hooks will actually run during the next call to | ||
| 883 | @code{run-mode-hooks} after the end of the @code{delay-mode-hooks} | ||
| 884 | construct. | ||
| 1164 | @end defmac | 885 | @end defmac |
| 1165 | 886 | ||
| 1166 | @defvar after-change-major-mode-hook | 887 | @defvar after-change-major-mode-hook |
| 1167 | Every major mode function should run this normal hook at its very end. | 888 | This is a normal hook run by @code{run-mode-hooks}. It is run at the |
| 1168 | It normally does not need to do so explicitly. Indeed, a major mode | 889 | very end of every properly-written major mode function. |
| 1169 | function should normally run its mode hook with @code{run-mode-hooks} | ||
| 1170 | as the very last thing it does, and the last thing | ||
| 1171 | @code{run-mode-hooks} does is run @code{after-change-major-mode-hook}. | ||
| 1172 | @end defvar | 890 | @end defvar |
| 1173 | 891 | ||
| 892 | @node Example Major Modes | ||
| 893 | @subsection Major Mode Examples | ||
| 894 | |||
| 895 | Text mode is perhaps the simplest mode besides Fundamental mode. | ||
| 896 | Here are excerpts from @file{text-mode.el} that illustrate many of | ||
| 897 | the conventions listed above: | ||
| 898 | |||
| 899 | @smallexample | ||
| 900 | @group | ||
| 901 | ;; @r{Create the syntax table for this mode.} | ||
| 902 | (defvar text-mode-syntax-table | ||
| 903 | (let ((st (make-syntax-table))) | ||
| 904 | (modify-syntax-entry ?\" ". " st) | ||
| 905 | (modify-syntax-entry ?\\ ". " st) | ||
| 906 | ;; Add `p' so M-c on `hello' leads to `Hello', not `hello'. | ||
| 907 | (modify-syntax-entry ?' "w p" st) | ||
| 908 | st) | ||
| 909 | "Syntax table used while in `text-mode'.") | ||
| 910 | @end group | ||
| 911 | |||
| 912 | ;; @r{Create the keymap for this mode.} | ||
| 913 | @group | ||
| 914 | (defvar text-mode-map | ||
| 915 | (let ((map (make-sparse-keymap))) | ||
| 916 | (define-key map "\e\t" 'ispell-complete-word) | ||
| 917 | (define-key map "\es" 'center-line) | ||
| 918 | (define-key map "\eS" 'center-paragraph) | ||
| 919 | map) | ||
| 920 | "Keymap for `text-mode'. | ||
| 921 | Many other modes, such as Mail mode, Outline mode | ||
| 922 | and Indented Text mode, inherit all the commands | ||
| 923 | defined in this map.") | ||
| 924 | @end group | ||
| 925 | @end smallexample | ||
| 926 | |||
| 927 | Here is how the actual mode command is defined now: | ||
| 928 | |||
| 929 | @smallexample | ||
| 930 | @group | ||
| 931 | (define-derived-mode text-mode nil "Text" | ||
| 932 | "Major mode for editing text written for humans to read. | ||
| 933 | In this mode, paragraphs are delimited only by blank or white lines. | ||
| 934 | You can thus get the full benefit of adaptive filling | ||
| 935 | (see the variable `adaptive-fill-mode'). | ||
| 936 | \\@{text-mode-map@} | ||
| 937 | Turning on Text mode runs the normal hook `text-mode-hook'." | ||
| 938 | @end group | ||
| 939 | @group | ||
| 940 | (make-local-variable 'text-mode-variant) | ||
| 941 | (setq text-mode-variant t) | ||
| 942 | ;; @r{These two lines are a feature added recently.} | ||
| 943 | (set (make-local-variable 'require-final-newline) | ||
| 944 | mode-require-final-newline) | ||
| 945 | (set (make-local-variable 'indent-line-function) 'indent-relative)) | ||
| 946 | @end group | ||
| 947 | @end smallexample | ||
| 948 | |||
| 949 | But here is how it was defined formerly, before | ||
| 950 | @code{define-derived-mode} existed: | ||
| 951 | |||
| 952 | @smallexample | ||
| 953 | @group | ||
| 954 | ;; @r{This isn't needed nowadays, since @code{define-derived-mode} does it.} | ||
| 955 | (defvar text-mode-abbrev-table nil | ||
| 956 | "Abbrev table used while in text mode.") | ||
| 957 | (define-abbrev-table 'text-mode-abbrev-table ()) | ||
| 958 | @end group | ||
| 959 | |||
| 960 | @group | ||
| 961 | (defun text-mode () | ||
| 962 | "Major mode for editing text intended for humans to read... | ||
| 963 | Special commands: \\@{text-mode-map@} | ||
| 964 | @end group | ||
| 965 | @group | ||
| 966 | Turning on text-mode runs the hook `text-mode-hook'." | ||
| 967 | (interactive) | ||
| 968 | (kill-all-local-variables) | ||
| 969 | (use-local-map text-mode-map) | ||
| 970 | @end group | ||
| 971 | @group | ||
| 972 | (setq local-abbrev-table text-mode-abbrev-table) | ||
| 973 | (set-syntax-table text-mode-syntax-table) | ||
| 974 | @end group | ||
| 975 | @group | ||
| 976 | ;; @r{These four lines are absent from the current version} | ||
| 977 | ;; @r{not because this is done some other way, but rather} | ||
| 978 | ;; @r{because nowadays Text mode uses the normal definition of paragraphs.} | ||
| 979 | (make-local-variable 'paragraph-start) | ||
| 980 | (setq paragraph-start (concat "[ \t]*$\\|" page-delimiter)) | ||
| 981 | (make-local-variable 'paragraph-separate) | ||
| 982 | (setq paragraph-separate paragraph-start) | ||
| 983 | (make-local-variable 'indent-line-function) | ||
| 984 | (setq indent-line-function 'indent-relative-maybe) | ||
| 985 | @end group | ||
| 986 | @group | ||
| 987 | (setq mode-name "Text") | ||
| 988 | (setq major-mode 'text-mode) | ||
| 989 | (run-mode-hooks 'text-mode-hook)) ; @r{Finally, this permits the user to} | ||
| 990 | ; @r{customize the mode with a hook.} | ||
| 991 | @end group | ||
| 992 | @end smallexample | ||
| 993 | |||
| 994 | @cindex @file{lisp-mode.el} | ||
| 995 | The three Lisp modes (Lisp mode, Emacs Lisp mode, and Lisp | ||
| 996 | Interaction mode) have more features than Text mode and the code is | ||
| 997 | correspondingly more complicated. Here are excerpts from | ||
| 998 | @file{lisp-mode.el} that illustrate how these modes are written. | ||
| 999 | |||
| 1000 | @cindex syntax table example | ||
| 1001 | @smallexample | ||
| 1002 | @group | ||
| 1003 | ;; @r{Create mode-specific table variables.} | ||
| 1004 | (defvar lisp-mode-syntax-table nil "") | ||
| 1005 | (defvar lisp-mode-abbrev-table nil "") | ||
| 1006 | @end group | ||
| 1007 | |||
| 1008 | @group | ||
| 1009 | (defvar emacs-lisp-mode-syntax-table | ||
| 1010 | (let ((table (make-syntax-table))) | ||
| 1011 | (let ((i 0)) | ||
| 1012 | @end group | ||
| 1013 | |||
| 1014 | @group | ||
| 1015 | ;; @r{Set syntax of chars up to @samp{0} to say they are} | ||
| 1016 | ;; @r{part of symbol names but not words.} | ||
| 1017 | ;; @r{(The digit @samp{0} is @code{48} in the @acronym{ASCII} character set.)} | ||
| 1018 | (while (< i ?0) | ||
| 1019 | (modify-syntax-entry i "_ " table) | ||
| 1020 | (setq i (1+ i))) | ||
| 1021 | ;; @r{@dots{} similar code follows for other character ranges.} | ||
| 1022 | @end group | ||
| 1023 | @group | ||
| 1024 | ;; @r{Then set the syntax codes for characters that are special in Lisp.} | ||
| 1025 | (modify-syntax-entry ? " " table) | ||
| 1026 | (modify-syntax-entry ?\t " " table) | ||
| 1027 | (modify-syntax-entry ?\f " " table) | ||
| 1028 | (modify-syntax-entry ?\n "> " table) | ||
| 1029 | @end group | ||
| 1030 | @group | ||
| 1031 | ;; @r{Give CR the same syntax as newline, for selective-display.} | ||
| 1032 | (modify-syntax-entry ?\^m "> " table) | ||
| 1033 | (modify-syntax-entry ?\; "< " table) | ||
| 1034 | (modify-syntax-entry ?` "' " table) | ||
| 1035 | (modify-syntax-entry ?' "' " table) | ||
| 1036 | (modify-syntax-entry ?, "' " table) | ||
| 1037 | @end group | ||
| 1038 | @group | ||
| 1039 | ;; @r{@dots{}likewise for many other characters@dots{}} | ||
| 1040 | (modify-syntax-entry ?\( "() " table) | ||
| 1041 | (modify-syntax-entry ?\) ")( " table) | ||
| 1042 | (modify-syntax-entry ?\[ "(] " table) | ||
| 1043 | (modify-syntax-entry ?\] ")[ " table)) | ||
| 1044 | table)) | ||
| 1045 | @end group | ||
| 1046 | @group | ||
| 1047 | ;; @r{Create an abbrev table for lisp-mode.} | ||
| 1048 | (define-abbrev-table 'lisp-mode-abbrev-table ()) | ||
| 1049 | @end group | ||
| 1050 | @end smallexample | ||
| 1051 | |||
| 1052 | The three modes for Lisp share much of their code. For instance, | ||
| 1053 | each calls the following function to set various variables: | ||
| 1054 | |||
| 1055 | @smallexample | ||
| 1056 | @group | ||
| 1057 | (defun lisp-mode-variables (lisp-syntax) | ||
| 1058 | (when lisp-syntax | ||
| 1059 | (set-syntax-table lisp-mode-syntax-table)) | ||
| 1060 | (setq local-abbrev-table lisp-mode-abbrev-table) | ||
| 1061 | @dots{} | ||
| 1062 | @end group | ||
| 1063 | @end smallexample | ||
| 1064 | |||
| 1065 | In Lisp and most programming languages, we want the paragraph | ||
| 1066 | commands to treat only blank lines as paragraph separators. And the | ||
| 1067 | modes should undestand the Lisp conventions for comments. The rest of | ||
| 1068 | @code{lisp-mode-variables} sets this up: | ||
| 1069 | |||
| 1070 | @smallexample | ||
| 1071 | @group | ||
| 1072 | (make-local-variable 'paragraph-start) | ||
| 1073 | (setq paragraph-start (concat page-delimiter "\\|$" )) | ||
| 1074 | (make-local-variable 'paragraph-separate) | ||
| 1075 | (setq paragraph-separate paragraph-start) | ||
| 1076 | @dots{} | ||
| 1077 | @end group | ||
| 1078 | @group | ||
| 1079 | (make-local-variable 'comment-indent-function) | ||
| 1080 | (setq comment-indent-function 'lisp-comment-indent)) | ||
| 1081 | @dots{} | ||
| 1082 | @end group | ||
| 1083 | @end smallexample | ||
| 1084 | |||
| 1085 | Each of the different Lisp modes has a slightly different keymap. For | ||
| 1086 | example, Lisp mode binds @kbd{C-c C-z} to @code{run-lisp}, but the other | ||
| 1087 | Lisp modes do not. However, all Lisp modes have some commands in | ||
| 1088 | common. The following code sets up the common commands: | ||
| 1089 | |||
| 1090 | @smallexample | ||
| 1091 | @group | ||
| 1092 | (defvar shared-lisp-mode-map () | ||
| 1093 | "Keymap for commands shared by all sorts of Lisp modes.") | ||
| 1094 | |||
| 1095 | ;; @r{Putting this @code{if} after the @code{defvar} is an older style.} | ||
| 1096 | (if shared-lisp-mode-map | ||
| 1097 | () | ||
| 1098 | (setq shared-lisp-mode-map (make-sparse-keymap)) | ||
| 1099 | (define-key shared-lisp-mode-map "\e\C-q" 'indent-sexp) | ||
| 1100 | (define-key shared-lisp-mode-map "\177" | ||
| 1101 | 'backward-delete-char-untabify)) | ||
| 1102 | @end group | ||
| 1103 | @end smallexample | ||
| 1104 | |||
| 1105 | @noindent | ||
| 1106 | And here is the code to set up the keymap for Lisp mode: | ||
| 1107 | |||
| 1108 | @smallexample | ||
| 1109 | @group | ||
| 1110 | (defvar lisp-mode-map () | ||
| 1111 | "Keymap for ordinary Lisp mode...") | ||
| 1112 | |||
| 1113 | (if lisp-mode-map | ||
| 1114 | () | ||
| 1115 | (setq lisp-mode-map (make-sparse-keymap)) | ||
| 1116 | (set-keymap-parent lisp-mode-map shared-lisp-mode-map) | ||
| 1117 | (define-key lisp-mode-map "\e\C-x" 'lisp-eval-defun) | ||
| 1118 | (define-key lisp-mode-map "\C-c\C-z" 'run-lisp)) | ||
| 1119 | @end group | ||
| 1120 | @end smallexample | ||
| 1121 | |||
| 1122 | Finally, here is the complete major mode function definition for | ||
| 1123 | Lisp mode. | ||
| 1124 | |||
| 1125 | @smallexample | ||
| 1126 | @group | ||
| 1127 | (defun lisp-mode () | ||
| 1128 | "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp. | ||
| 1129 | Commands: | ||
| 1130 | Delete converts tabs to spaces as it moves back. | ||
| 1131 | Blank lines separate paragraphs. Semicolons start comments. | ||
| 1132 | \\@{lisp-mode-map@} | ||
| 1133 | Note that `run-lisp' may be used either to start an inferior Lisp job | ||
| 1134 | or to switch back to an existing one. | ||
| 1135 | @end group | ||
| 1136 | |||
| 1137 | @group | ||
| 1138 | Entry to this mode calls the value of `lisp-mode-hook' | ||
| 1139 | if that value is non-nil." | ||
| 1140 | (interactive) | ||
| 1141 | (kill-all-local-variables) | ||
| 1142 | @end group | ||
| 1143 | @group | ||
| 1144 | (use-local-map lisp-mode-map) ; @r{Select the mode's keymap.} | ||
| 1145 | (setq major-mode 'lisp-mode) ; @r{This is how @code{describe-mode}} | ||
| 1146 | ; @r{finds out what to describe.} | ||
| 1147 | (setq mode-name "Lisp") ; @r{This goes into the mode line.} | ||
| 1148 | (lisp-mode-variables t) ; @r{This defines various variables.} | ||
| 1149 | (make-local-variable 'comment-start-skip) | ||
| 1150 | (setq comment-start-skip | ||
| 1151 | "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *") | ||
| 1152 | (make-local-variable 'font-lock-keywords-case-fold-search) | ||
| 1153 | (setq font-lock-keywords-case-fold-search t) | ||
| 1154 | @end group | ||
| 1155 | @group | ||
| 1156 | (setq imenu-case-fold-search t) | ||
| 1157 | (set-syntax-table lisp-mode-syntax-table) | ||
| 1158 | (run-mode-hooks 'lisp-mode-hook)) ; @r{This permits the user to use a} | ||
| 1159 | ; @r{hook to customize the mode.} | ||
| 1160 | @end group | ||
| 1161 | @end smallexample | ||
| 1162 | |||
| 1174 | @node Minor Modes | 1163 | @node Minor Modes |
| 1175 | @section Minor Modes | 1164 | @section Minor Modes |
| 1176 | @cindex minor mode | 1165 | @cindex minor mode |
| @@ -1295,7 +1284,7 @@ check for an existing element, to avoid duplication. For example: | |||
| 1295 | @end smallexample | 1284 | @end smallexample |
| 1296 | 1285 | ||
| 1297 | @noindent | 1286 | @noindent |
| 1298 | or like this, using @code{add-to-list} (@pxref{Setting Variables}): | 1287 | or like this, using @code{add-to-list} (@pxref{List Variables}): |
| 1299 | 1288 | ||
| 1300 | @smallexample | 1289 | @smallexample |
| 1301 | @group | 1290 | @group |
| @@ -1533,16 +1522,14 @@ minor modes. | |||
| 1533 | @subsection Mode Line Basics | 1522 | @subsection Mode Line Basics |
| 1534 | 1523 | ||
| 1535 | @code{mode-line-format} is a buffer-local variable that holds a | 1524 | @code{mode-line-format} is a buffer-local variable that holds a |
| 1536 | @dfn{mode line construct}, a kind of template, which controls the | 1525 | @dfn{mode line construct}, a kind of template, which controls what is |
| 1537 | display the mode line of the current buffer. All windows for the same | 1526 | displayed on the mode line of the current buffer. The value of |
| 1538 | buffer use the same @code{mode-line-format}, so their mode lines | 1527 | @code{header-line-format} specifies the buffer's header line in the |
| 1539 | appear the same---except for scrolling percentages, and line and | 1528 | same way. All windows for the same buffer use the same |
| 1540 | column numbers, since those depend on point and on how the window is | 1529 | @code{mode-line-format} and @code{header-line-format}. |
| 1541 | scrolled. The value of @code{header-line-format} specifies the | 1530 | |
| 1542 | buffer's header line in the same way, with a mode line construct. | 1531 | For efficiency, Emacs does not continuously recompute the mode |
| 1543 | 1532 | line and header line of a window. It does so when circumstances | |
| 1544 | For efficiency, Emacs does not recompute the mode line and header | ||
| 1545 | line of a window in every redisplay. It does so when circumstances | ||
| 1546 | appear to call for it---for instance, if you change the window | 1533 | appear to call for it---for instance, if you change the window |
| 1547 | configuration, switch buffers, narrow or widen the buffer, scroll, or | 1534 | configuration, switch buffers, narrow or widen the buffer, scroll, or |
| 1548 | change the buffer's modification status. If you modify any of the | 1535 | change the buffer's modification status. If you modify any of the |
| @@ -1552,7 +1539,6 @@ how text is displayed (@pxref{Display}), you may want to force an | |||
| 1552 | update of the mode line so as to display the new information or | 1539 | update of the mode line so as to display the new information or |
| 1553 | display it in the new way. | 1540 | display it in the new way. |
| 1554 | 1541 | ||
| 1555 | @c Emacs 19 feature | ||
| 1556 | @defun force-mode-line-update &optional all | 1542 | @defun force-mode-line-update &optional all |
| 1557 | Force redisplay of the current buffer's mode line and header line. | 1543 | Force redisplay of the current buffer's mode line and header line. |
| 1558 | The next redisplay will update the mode line and header line based on | 1544 | The next redisplay will update the mode line and header line based on |
| @@ -1589,15 +1575,17 @@ defined to have mode-line constructs as their values. | |||
| 1589 | @table @code | 1575 | @table @code |
| 1590 | @cindex percent symbol in mode line | 1576 | @cindex percent symbol in mode line |
| 1591 | @item @var{string} | 1577 | @item @var{string} |
| 1592 | A string as a mode-line construct appears verbatim in the mode line | 1578 | A string as a mode-line construct appears verbatim except for |
| 1593 | except for @dfn{@code{%}-constructs} in it. These stand for | 1579 | @dfn{@code{%}-constructs} in it. These stand for substitution of |
| 1594 | substitution of other data; see @ref{%-Constructs}. | 1580 | other data; see @ref{%-Constructs}. |
| 1595 | 1581 | ||
| 1596 | If the string has @code{face} properties, they are copied into the | 1582 | If parts of the string have @code{face} properties, they control |
| 1597 | mode line contents too (@pxref{Properties in Mode}). Any characters | 1583 | display of the text just as they would text in the buffer. Any |
| 1598 | in the mode line which have no @code{face} properties are displayed, | 1584 | characters which have no @code{face} properties are displayed, by |
| 1599 | by default, in the face @code{mode-line} or @code{mode-line-inactive} | 1585 | default, in the face @code{mode-line} or @code{mode-line-inactive} |
| 1600 | (@pxref{Standard Faces,,, emacs, The GNU Emacs Manual}). | 1586 | (@pxref{Standard Faces,,, emacs, The GNU Emacs Manual}). The |
| 1587 | @code{help-echo} and @code{local-map} properties in @var{string} have | ||
| 1588 | special meanings. @xref{Properties in Mode}. | ||
| 1601 | 1589 | ||
| 1602 | @item @var{symbol} | 1590 | @item @var{symbol} |
| 1603 | A symbol as a mode-line construct stands for its value. The value of | 1591 | A symbol as a mode-line construct stands for its value. The value of |
| @@ -1612,7 +1600,9 @@ Unless @var{symbol} is marked as ``risky'' (i.e., it has a | |||
| 1612 | non-@code{nil} @code{risky-local-variable} property), all text | 1600 | non-@code{nil} @code{risky-local-variable} property), all text |
| 1613 | properties specified in @var{symbol}'s value are ignored. This | 1601 | properties specified in @var{symbol}'s value are ignored. This |
| 1614 | includes the text properties of strings in @var{symbol}'s value, as | 1602 | includes the text properties of strings in @var{symbol}'s value, as |
| 1615 | well as all @code{:eval} and @code{:propertize} forms in it. | 1603 | well as all @code{:eval} and @code{:propertize} forms in it. (The |
| 1604 | reason for this is security: non-risky variables could be set | ||
| 1605 | automatically from file variables without prompting the user.) | ||
| 1616 | 1606 | ||
| 1617 | @item (@var{string} @var{rest}@dots{}) | 1607 | @item (@var{string} @var{rest}@dots{}) |
| 1618 | @itemx (@var{list} @var{rest}@dots{}) | 1608 | @itemx (@var{list} @var{rest}@dots{}) |
| @@ -2055,10 +2045,10 @@ structure, and make @var{form} evaluate to a string that has a text | |||
| 2055 | property. | 2045 | property. |
| 2056 | @end enumerate | 2046 | @end enumerate |
| 2057 | 2047 | ||
| 2058 | You use the @code{local-map} property to specify a keymap. Like any | 2048 | You can use the @code{local-map} property to specify a keymap. This |
| 2059 | keymap, it can bind character keys and function keys; but that has no | 2049 | keymap only takes real effect for mouse clicks; binding character keys |
| 2060 | effect, since it is impossible to move point into the mode line. This | 2050 | and function keys to it has no effect, since it is impossible to move |
| 2061 | keymap can only take real effect for mouse clicks. | 2051 | point into the mode line. |
| 2062 | 2052 | ||
| 2063 | When the mode line refers to a variable which does not have a | 2053 | When the mode line refers to a variable which does not have a |
| 2064 | non-@code{nil} @code{risky-local-variable} property, any text | 2054 | non-@code{nil} @code{risky-local-variable} property, any text |
| @@ -2889,6 +2879,10 @@ Used (typically) for constant names. | |||
| 2889 | @vindex font-lock-preprocessor-face | 2879 | @vindex font-lock-preprocessor-face |
| 2890 | Used (typically) for preprocessor commands. | 2880 | Used (typically) for preprocessor commands. |
| 2891 | 2881 | ||
| 2882 | @item font-lock-negation-char-face | ||
| 2883 | @vindex font-lock-negation-char-face | ||
| 2884 | Used (typically) for easily-overlooked negation characters. | ||
| 2885 | |||
| 2892 | @item font-lock-warning-face | 2886 | @item font-lock-warning-face |
| 2893 | @vindex font-lock-warning-face | 2887 | @vindex font-lock-warning-face |
| 2894 | Used (typically) for constructs that are peculiar, or that greatly | 2888 | Used (typically) for constructs that are peculiar, or that greatly |
| @@ -3044,7 +3038,7 @@ closely related, and often getting one of them to work will appear to | |||
| 3044 | make the other also work. However, for reliable results you must | 3038 | make the other also work. However, for reliable results you must |
| 3045 | attend explicitly to both aspects. | 3039 | attend explicitly to both aspects. |
| 3046 | 3040 | ||
| 3047 | There are two ways to ensure correct identification of multiline | 3041 | There are three ways to ensure correct identification of multiline |
| 3048 | constructs: | 3042 | constructs: |
| 3049 | 3043 | ||
| 3050 | @itemize | 3044 | @itemize |
| @@ -3055,6 +3049,10 @@ property on the construct when it is added to the buffer. | |||
| 3055 | Use @code{font-lock-fontify-region-function} hook to extend the scan | 3049 | Use @code{font-lock-fontify-region-function} hook to extend the scan |
| 3056 | so that the scanned text never starts or ends in the middle of a | 3050 | so that the scanned text never starts or ends in the middle of a |
| 3057 | multiline construct. | 3051 | multiline construct. |
| 3052 | @item | ||
| 3053 | Add a function to @code{font-lock-extend-region-functions} that does | ||
| 3054 | the @emph{identification} and extends the scan so that the scanned | ||
| 3055 | text never starts or ends in the middle of a multiline construct. | ||
| 3058 | @end itemize | 3056 | @end itemize |
| 3059 | 3057 | ||
| 3060 | There are three ways to do rehighlighting of multiline constructs: | 3058 | There are three ways to do rehighlighting of multiline constructs: |
| @@ -3144,7 +3142,7 @@ earlier line. | |||
| 3144 | You can enlarge (or even reduce) the region to fontify by setting | 3142 | You can enlarge (or even reduce) the region to fontify by setting |
| 3145 | one the following variables: | 3143 | one the following variables: |
| 3146 | 3144 | ||
| 3147 | @defvar font-lock-extend-region-function | 3145 | @defvar font-lock-extend-after-change-region-function |
| 3148 | This buffer-local variable is either @code{nil} or a function for | 3146 | This buffer-local variable is either @code{nil} or a function for |
| 3149 | Font-Lock to call to determine the region to scan and fontify. | 3147 | Font-Lock to call to determine the region to scan and fontify. |
| 3150 | 3148 | ||
diff --git a/lispref/os.texi b/lispref/os.texi index e3634746988..f6682548e5b 100644 --- a/lispref/os.texi +++ b/lispref/os.texi | |||
| @@ -28,8 +28,10 @@ pertaining to the terminal and the screen. | |||
| 28 | * Processor Run Time:: Getting the run time used by Emacs. | 28 | * Processor Run Time:: Getting the run time used by Emacs. |
| 29 | * Time Calculations:: Adding, subtracting, comparing times, etc. | 29 | * Time Calculations:: Adding, subtracting, comparing times, etc. |
| 30 | * Timers:: Setting a timer to call a function at a certain time. | 30 | * Timers:: Setting a timer to call a function at a certain time. |
| 31 | * Terminal Input:: Recording terminal input for debugging. | 31 | * Idle Timers:: Setting a timer to call a function when Emacs has |
| 32 | * Terminal Output:: Recording terminal output for debugging. | 32 | been idle for a certain length of time. |
| 33 | * Terminal Input:: Accessing and recording terminal input. | ||
| 34 | * Terminal Output:: Controlling and recording terminal output. | ||
| 33 | * Sound Output:: Playing sounds on the computer's speaker. | 35 | * Sound Output:: Playing sounds on the computer's speaker. |
| 34 | * X11 Keysyms:: Operating on key symbols for X Windows | 36 | * X11 Keysyms:: Operating on key symbols for X Windows |
| 35 | * Batch Mode:: Running Emacs without terminal interaction. | 37 | * Batch Mode:: Running Emacs without terminal interaction. |
| @@ -1256,7 +1258,9 @@ This stands for the year without century (00-99). | |||
| 1256 | @item %Y | 1258 | @item %Y |
| 1257 | This stands for the year with century. | 1259 | This stands for the year with century. |
| 1258 | @item %Z | 1260 | @item %Z |
| 1259 | This stands for the time zone abbreviation. | 1261 | This stands for the time zone abbreviation (e.g., @samp{EST}). |
| 1262 | @item %z | ||
| 1263 | This stands for the time zone numerical offset (e.g., @samp{-0500}). | ||
| 1260 | @end table | 1264 | @end table |
| 1261 | 1265 | ||
| 1262 | You can also specify the field width and type of padding for any of | 1266 | You can also specify the field width and type of padding for any of |
| @@ -1286,12 +1290,14 @@ If @var{universal} is non-@code{nil}, that means to describe the time as | |||
| 1286 | Universal Time; @code{nil} means describe it using what Emacs believes | 1290 | Universal Time; @code{nil} means describe it using what Emacs believes |
| 1287 | is the local time zone (see @code{current-time-zone}). | 1291 | is the local time zone (see @code{current-time-zone}). |
| 1288 | 1292 | ||
| 1289 | This function uses the C library function @code{strftime} to do most of | 1293 | This function uses the C library function @code{strftime} |
| 1290 | the work. In order to communicate with that function, it first encodes | 1294 | (@pxref{Formatting Calendar Time,,, libc, The GNU C Library Reference |
| 1291 | its argument using the coding system specified by | 1295 | Manual}) to do most of the work. In order to communicate with that |
| 1292 | @code{locale-coding-system} (@pxref{Locales}); after @code{strftime} | 1296 | function, it first encodes its argument using the coding system |
| 1293 | returns the resulting string, @code{format-time-string} decodes the | 1297 | specified by @code{locale-coding-system} (@pxref{Locales}); after |
| 1294 | string using that same coding system. | 1298 | @code{strftime} returns the resulting string, |
| 1299 | @code{format-time-string} decodes the string using that same coding | ||
| 1300 | system. | ||
| 1295 | @end defun | 1301 | @end defun |
| 1296 | 1302 | ||
| 1297 | @defun seconds-to-time seconds | 1303 | @defun seconds-to-time seconds |
| @@ -1388,6 +1394,13 @@ both before and after changing the buffer, to separate the timer's | |||
| 1388 | changes from user commands' changes and prevent a single undo entry | 1394 | changes from user commands' changes and prevent a single undo entry |
| 1389 | from growing to be quite large. | 1395 | from growing to be quite large. |
| 1390 | 1396 | ||
| 1397 | Timer functions should also avoid calling functions that cause Emacs | ||
| 1398 | to wait, such as @code{sit-for} (@pxref{Waiting}). This can lead to | ||
| 1399 | unpredictable effects, since other timers (or even the same timer) can | ||
| 1400 | run while waiting. If a timer function needs to perform an action | ||
| 1401 | after a certain time has elapsed, it can do this by scheduling a new | ||
| 1402 | timer. | ||
| 1403 | |||
| 1391 | If a timer function calls functions that can change the match data, | 1404 | If a timer function calls functions that can change the match data, |
| 1392 | it should save and restore the match data. @xref{Saving Match Data}. | 1405 | it should save and restore the match data. @xref{Saving Match Data}. |
| 1393 | 1406 | ||
| @@ -1469,10 +1482,26 @@ calls one of those primitives. So use @code{with-timeout} only with a | |||
| 1469 | a timer to avoid waiting too long for an answer. @xref{Yes-or-No | 1482 | a timer to avoid waiting too long for an answer. @xref{Yes-or-No |
| 1470 | Queries}. | 1483 | Queries}. |
| 1471 | 1484 | ||
| 1485 | @defun cancel-timer timer | ||
| 1486 | This cancels the requested action for @var{timer}, which should be a | ||
| 1487 | timer---usually, one previously returned by @code{run-at-time} or | ||
| 1488 | @code{run-with-idle-timer}. This cancels the effect of that call to | ||
| 1489 | one of these functions; the arrival of the specified time will not | ||
| 1490 | cause anything special to happen. | ||
| 1491 | @end defun | ||
| 1492 | |||
| 1493 | @node Idle Timers | ||
| 1494 | @section Idle Timers | ||
| 1495 | |||
| 1496 | Here is how to set up a timer that runs when Emacs is idle for a | ||
| 1497 | certain length of time. Aside from how to set them up, idle timers | ||
| 1498 | work just like ordinary timers. | ||
| 1499 | |||
| 1472 | @deffn Command run-with-idle-timer secs repeat function &rest args | 1500 | @deffn Command run-with-idle-timer secs repeat function &rest args |
| 1473 | Set up a timer which runs when Emacs has been idle for @var{secs} | 1501 | Set up a timer which runs when Emacs has been idle for @var{secs} |
| 1474 | seconds. The value of @var{secs} may be an integer or a floating point | 1502 | seconds. The value of @var{secs} may be an integer or a floating point |
| 1475 | number. | 1503 | number; a value of the type returned by @code{current-idle-time} |
| 1504 | is also allowed. | ||
| 1476 | 1505 | ||
| 1477 | If @var{repeat} is @code{nil}, the timer runs just once, the first time | 1506 | If @var{repeat} is @code{nil}, the timer runs just once, the first time |
| 1478 | Emacs remains idle for a long enough time. More often @var{repeat} is | 1507 | Emacs remains idle for a long enough time. More often @var{repeat} is |
| @@ -1480,7 +1509,7 @@ non-@code{nil}, which means to run the timer @emph{each time} Emacs | |||
| 1480 | remains idle for @var{secs} seconds. | 1509 | remains idle for @var{secs} seconds. |
| 1481 | 1510 | ||
| 1482 | The function @code{run-with-idle-timer} returns a timer value which you | 1511 | The function @code{run-with-idle-timer} returns a timer value which you |
| 1483 | can use in calling @code{cancel-timer} (see below). | 1512 | can use in calling @code{cancel-timer} (@pxref{Timers}). |
| 1484 | @end deffn | 1513 | @end deffn |
| 1485 | 1514 | ||
| 1486 | @cindex idleness | 1515 | @cindex idleness |
| @@ -1504,11 +1533,49 @@ minutes, and even if there have been garbage collections and autosaves. | |||
| 1504 | input. Then it becomes idle again, and all the idle timers that are | 1533 | input. Then it becomes idle again, and all the idle timers that are |
| 1505 | set up to repeat will subsequently run another time, one by one. | 1534 | set up to repeat will subsequently run another time, one by one. |
| 1506 | 1535 | ||
| 1507 | @defun cancel-timer timer | 1536 | @c Emacs 19 feature |
| 1508 | Cancel the requested action for @var{timer}, which should be a value | 1537 | @defun current-idle-time |
| 1509 | previously returned by @code{run-at-time} or @code{run-with-idle-timer}. | 1538 | This function returns the length of time Emacs has been idle, as a |
| 1510 | This cancels the effect of that call to one of these functions; the | 1539 | list of three integers: @code{(@var{high} @var{low} @var{microsec})}. |
| 1511 | arrival of the specified time will not cause anything special to happen. | 1540 | The integers @var{high} and @var{low} combine to give the number of |
| 1541 | seconds of idleness, which is | ||
| 1542 | @ifnottex | ||
| 1543 | @var{high} * 2**16 + @var{low}. | ||
| 1544 | @end ifnottex | ||
| 1545 | @tex | ||
| 1546 | $high*2^{16}+low$. | ||
| 1547 | @end tex | ||
| 1548 | |||
| 1549 | The third element, @var{microsec}, gives the microseconds since the | ||
| 1550 | start of the current second (or 0 for systems that return time with | ||
| 1551 | the resolution of only one second). | ||
| 1552 | |||
| 1553 | The main use of this function is when an idle timer function wants to | ||
| 1554 | ``take a break'' for a while. It can set up another idle timer to | ||
| 1555 | call the same function again, after a few seconds more idleness. | ||
| 1556 | Here's an example: | ||
| 1557 | |||
| 1558 | @smallexample | ||
| 1559 | (defvar resume-timer nil | ||
| 1560 | "Timer that `timer-function' used to reschedule itself, or nil.") | ||
| 1561 | |||
| 1562 | (defun timer-function () | ||
| 1563 | ;; @r{If the user types a command while @code{resume-timer}} | ||
| 1564 | ;; @r{is active, the next time this function is called from} | ||
| 1565 | ;; @r{its main idle timer, deactivate @code{resume-timer}.} | ||
| 1566 | (when resume-timer | ||
| 1567 | (cancel-timer resume-timer)) | ||
| 1568 | ...@var{do the work for a while}... | ||
| 1569 | (when @var{taking-a-break} | ||
| 1570 | (setq resume-timer | ||
| 1571 | (run-with-idle-timer | ||
| 1572 | ;; Compute an idle time @var{break-length} | ||
| 1573 | ;; more than the current value. | ||
| 1574 | (time-add (current-idle-time) | ||
| 1575 | (seconds-to-time @var{break-length})) | ||
| 1576 | nil | ||
| 1577 | 'timer-function)))) | ||
| 1578 | @end smallexample | ||
| 1512 | @end defun | 1579 | @end defun |
| 1513 | 1580 | ||
| 1514 | @node Terminal Input | 1581 | @node Terminal Input |
| @@ -1521,8 +1588,6 @@ functions. | |||
| 1521 | 1588 | ||
| 1522 | @menu | 1589 | @menu |
| 1523 | * Input Modes:: Options for how input is processed. | 1590 | * Input Modes:: Options for how input is processed. |
| 1524 | * Translating Input:: Low level conversion of some characters or events | ||
| 1525 | into others. | ||
| 1526 | * Recording Input:: Saving histories of recent or all input events. | 1591 | * Recording Input:: Saving histories of recent or all input events. |
| 1527 | @end menu | 1592 | @end menu |
| 1528 | 1593 | ||
| @@ -1587,204 +1652,6 @@ is the character Emacs currently uses for quitting, usually @kbd{C-g}. | |||
| 1587 | @end table | 1652 | @end table |
| 1588 | @end defun | 1653 | @end defun |
| 1589 | 1654 | ||
| 1590 | @node Translating Input | ||
| 1591 | @subsection Translating Input Events | ||
| 1592 | @cindex translating input events | ||
| 1593 | |||
| 1594 | This section describes features for translating input events into | ||
| 1595 | other input events before they become part of key sequences. These | ||
| 1596 | features apply to each event in the order they are described here: each | ||
| 1597 | event is first modified according to @code{extra-keyboard-modifiers}, | ||
| 1598 | then translated through @code{keyboard-translate-table} (if applicable), | ||
| 1599 | and finally decoded with the specified keyboard coding system. If it is | ||
| 1600 | being read as part of a key sequence, it is then added to the sequence | ||
| 1601 | being read; then subsequences containing it are checked first with | ||
| 1602 | @code{function-key-map} and then with @code{key-translation-map}. | ||
| 1603 | |||
| 1604 | @c Emacs 19 feature | ||
| 1605 | @defvar extra-keyboard-modifiers | ||
| 1606 | This variable lets Lisp programs ``press'' the modifier keys on the | ||
| 1607 | keyboard. The value is a character. Only the modifiers of the | ||
| 1608 | character matter. Each time the user types a keyboard key, it is | ||
| 1609 | altered as if those modifier keys were held down. For instance, if | ||
| 1610 | you bind @code{extra-keyboard-modifiers} to @code{?\C-\M-a}, then all | ||
| 1611 | keyboard input characters typed during the scope of the binding will | ||
| 1612 | have the control and meta modifiers applied to them. The character | ||
| 1613 | @code{?\C-@@}, equivalent to the integer 0, does not count as a control | ||
| 1614 | character for this purpose, but as a character with no modifiers. | ||
| 1615 | Thus, setting @code{extra-keyboard-modifiers} to zero cancels any | ||
| 1616 | modification. | ||
| 1617 | |||
| 1618 | When using a window system, the program can ``press'' any of the | ||
| 1619 | modifier keys in this way. Otherwise, only the @key{CTL} and @key{META} | ||
| 1620 | keys can be virtually pressed. | ||
| 1621 | |||
| 1622 | Note that this variable applies only to events that really come from | ||
| 1623 | the keyboard, and has no effect on mouse events or any other events. | ||
| 1624 | @end defvar | ||
| 1625 | |||
| 1626 | @defvar keyboard-translate-table | ||
| 1627 | This variable is the translate table for keyboard characters. It lets | ||
| 1628 | you reshuffle the keys on the keyboard without changing any command | ||
| 1629 | bindings. Its value is normally a char-table, or else @code{nil}. | ||
| 1630 | (It can also be a string or vector, but this is considered obsolete.) | ||
| 1631 | |||
| 1632 | If @code{keyboard-translate-table} is a char-table | ||
| 1633 | (@pxref{Char-Tables}), then each character read from the keyboard is | ||
| 1634 | looked up in this char-table. If the value found there is | ||
| 1635 | non-@code{nil}, then it is used instead of the actual input character. | ||
| 1636 | |||
| 1637 | Note that this translation is the first thing that happens to a | ||
| 1638 | character after it is read from the terminal. Record-keeping features | ||
| 1639 | such as @code{recent-keys} and dribble files record the characters after | ||
| 1640 | translation. | ||
| 1641 | |||
| 1642 | Note also that this translation is done before the characters are | ||
| 1643 | supplied to input methods (@pxref{Input Methods}). Use | ||
| 1644 | @code{translation-table-for-input} (@pxref{Translation of Characters}), | ||
| 1645 | if you want to translate characters after input methods operate. | ||
| 1646 | @end defvar | ||
| 1647 | |||
| 1648 | @defun keyboard-translate from to | ||
| 1649 | This function modifies @code{keyboard-translate-table} to translate | ||
| 1650 | character code @var{from} into character code @var{to}. It creates | ||
| 1651 | the keyboard translate table if necessary. | ||
| 1652 | @end defun | ||
| 1653 | |||
| 1654 | Here's an example of using the @code{keyboard-translate-table} to | ||
| 1655 | make @kbd{C-x}, @kbd{C-c} and @kbd{C-v} perform the cut, copy and paste | ||
| 1656 | operations: | ||
| 1657 | |||
| 1658 | @example | ||
| 1659 | (keyboard-translate ?\C-x 'control-x) | ||
| 1660 | (keyboard-translate ?\C-c 'control-c) | ||
| 1661 | (keyboard-translate ?\C-v 'control-v) | ||
| 1662 | (global-set-key [control-x] 'kill-region) | ||
| 1663 | (global-set-key [control-c] 'kill-ring-save) | ||
| 1664 | (global-set-key [control-v] 'yank) | ||
| 1665 | @end example | ||
| 1666 | |||
| 1667 | @noindent | ||
| 1668 | On a graphical terminal that supports extended @acronym{ASCII} input, | ||
| 1669 | you can still get the standard Emacs meanings of one of those | ||
| 1670 | characters by typing it with the shift key. That makes it a different | ||
| 1671 | character as far as keyboard translation is concerned, but it has the | ||
| 1672 | same usual meaning. | ||
| 1673 | |||
| 1674 | The remaining translation features translate subsequences of key | ||
| 1675 | sequences being read. They are implemented in @code{read-key-sequence} | ||
| 1676 | and have no effect on input read with @code{read-event}. | ||
| 1677 | |||
| 1678 | @defvar function-key-map | ||
| 1679 | This variable holds a keymap that describes the character sequences sent | ||
| 1680 | by function keys on an ordinary character terminal. This keymap has the | ||
| 1681 | same structure as other keymaps, but is used differently: it specifies | ||
| 1682 | translations to make while reading key sequences, rather than bindings | ||
| 1683 | for key sequences. | ||
| 1684 | |||
| 1685 | If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector | ||
| 1686 | @var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a | ||
| 1687 | key sequence, it is replaced with the events in @var{v}. | ||
| 1688 | |||
| 1689 | For example, VT100 terminals send @kbd{@key{ESC} O P} when the | ||
| 1690 | keypad @key{PF1} key is pressed. Therefore, we want Emacs to translate | ||
| 1691 | that sequence of events into the single event @code{pf1}. We accomplish | ||
| 1692 | this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in | ||
| 1693 | @code{function-key-map}, when using a VT100. | ||
| 1694 | |||
| 1695 | Thus, typing @kbd{C-c @key{PF1}} sends the character sequence @kbd{C-c | ||
| 1696 | @key{ESC} O P}; later the function @code{read-key-sequence} translates | ||
| 1697 | this back into @kbd{C-c @key{PF1}}, which it returns as the vector | ||
| 1698 | @code{[?\C-c pf1]}. | ||
| 1699 | |||
| 1700 | Entries in @code{function-key-map} are ignored if they conflict with | ||
| 1701 | bindings made in the minor mode, local, or global keymaps. The intent | ||
| 1702 | is that the character sequences that function keys send should not have | ||
| 1703 | command bindings in their own right---but if they do, the ordinary | ||
| 1704 | bindings take priority. | ||
| 1705 | |||
| 1706 | The value of @code{function-key-map} is usually set up automatically | ||
| 1707 | according to the terminal's Terminfo or Termcap entry, but sometimes | ||
| 1708 | those need help from terminal-specific Lisp files. Emacs comes with | ||
| 1709 | terminal-specific files for many common terminals; their main purpose is | ||
| 1710 | to make entries in @code{function-key-map} beyond those that can be | ||
| 1711 | deduced from Termcap and Terminfo. @xref{Terminal-Specific}. | ||
| 1712 | @end defvar | ||
| 1713 | |||
| 1714 | @defvar key-translation-map | ||
| 1715 | This variable is another keymap used just like @code{function-key-map} | ||
| 1716 | to translate input events into other events. It differs from | ||
| 1717 | @code{function-key-map} in two ways: | ||
| 1718 | |||
| 1719 | @itemize @bullet | ||
| 1720 | @item | ||
| 1721 | @code{key-translation-map} goes to work after @code{function-key-map} is | ||
| 1722 | finished; it receives the results of translation by | ||
| 1723 | @code{function-key-map}. | ||
| 1724 | |||
| 1725 | @item | ||
| 1726 | Non-prefix bindings in @code{key-translation-map} override actual key | ||
| 1727 | bindings. For example, if @kbd{C-x f} has a non-prefix binding in | ||
| 1728 | @code{key-translation-map}, that translation takes effect even though | ||
| 1729 | @kbd{C-x f} also has a key binding in the global map. | ||
| 1730 | @end itemize | ||
| 1731 | |||
| 1732 | Note however that actual key bindings can have an effect on | ||
| 1733 | @code{key-translation-map}, even though they are overridden by it. | ||
| 1734 | Indeed, actual key bindings override @code{function-key-map} and thus | ||
| 1735 | may alter the key sequence that @code{key-translation-map} receives. | ||
| 1736 | Clearly, it is better to avoid this type of situation. | ||
| 1737 | |||
| 1738 | The intent of @code{key-translation-map} is for users to map one | ||
| 1739 | character set to another, including ordinary characters normally bound | ||
| 1740 | to @code{self-insert-command}. | ||
| 1741 | @end defvar | ||
| 1742 | |||
| 1743 | @cindex key translation function | ||
| 1744 | You can use @code{function-key-map} or @code{key-translation-map} for | ||
| 1745 | more than simple aliases, by using a function, instead of a key | ||
| 1746 | sequence, as the ``translation'' of a key. Then this function is called | ||
| 1747 | to compute the translation of that key. | ||
| 1748 | |||
| 1749 | The key translation function receives one argument, which is the prompt | ||
| 1750 | that was specified in @code{read-key-sequence}---or @code{nil} if the | ||
| 1751 | key sequence is being read by the editor command loop. In most cases | ||
| 1752 | you can ignore the prompt value. | ||
| 1753 | |||
| 1754 | If the function reads input itself, it can have the effect of altering | ||
| 1755 | the event that follows. For example, here's how to define @kbd{C-c h} | ||
| 1756 | to turn the character that follows into a Hyper character: | ||
| 1757 | |||
| 1758 | @example | ||
| 1759 | @group | ||
| 1760 | (defun hyperify (prompt) | ||
| 1761 | (let ((e (read-event))) | ||
| 1762 | (vector (if (numberp e) | ||
| 1763 | (logior (lsh 1 24) e) | ||
| 1764 | (if (memq 'hyper (event-modifiers e)) | ||
| 1765 | e | ||
| 1766 | (add-event-modifier "H-" e)))))) | ||
| 1767 | |||
| 1768 | (defun add-event-modifier (string e) | ||
| 1769 | (let ((symbol (if (symbolp e) e (car e)))) | ||
| 1770 | (setq symbol (intern (concat string | ||
| 1771 | (symbol-name symbol)))) | ||
| 1772 | @end group | ||
| 1773 | @group | ||
| 1774 | (if (symbolp e) | ||
| 1775 | symbol | ||
| 1776 | (cons symbol (cdr e))))) | ||
| 1777 | |||
| 1778 | (define-key function-key-map "\C-ch" 'hyperify) | ||
| 1779 | @end group | ||
| 1780 | @end example | ||
| 1781 | |||
| 1782 | Finally, if you have enabled keyboard character set decoding using | ||
| 1783 | @code{set-keyboard-coding-system}, decoding is done after the | ||
| 1784 | translations listed above. @xref{Terminal I/O Encoding}. In future | ||
| 1785 | Emacs versions, character set decoding may be done before the other | ||
| 1786 | translations. | ||
| 1787 | |||
| 1788 | @node Recording Input | 1655 | @node Recording Input |
| 1789 | @subsection Recording Input | 1656 | @subsection Recording Input |
| 1790 | 1657 | ||
diff --git a/lispref/processes.texi b/lispref/processes.texi index a6f43cfa95d..f957ebcac4b 100644 --- a/lispref/processes.texi +++ b/lispref/processes.texi | |||
| @@ -1520,7 +1520,7 @@ text at the end of the entire answer, but nothing before; that's how | |||
| 1520 | 1520 | ||
| 1521 | If the argument @var{delay-question} is non-nil, delay sending this | 1521 | If the argument @var{delay-question} is non-nil, delay sending this |
| 1522 | question until the process has finished replying to any previous | 1522 | question until the process has finished replying to any previous |
| 1523 | questions. This produces more reliable results with some processes." | 1523 | questions. This produces more reliable results with some processes. |
| 1524 | 1524 | ||
| 1525 | The return value of @code{tq-enqueue} itself is not meaningful. | 1525 | The return value of @code{tq-enqueue} itself is not meaningful. |
| 1526 | @end defun | 1526 | @end defun |
diff --git a/lispref/strings.texi b/lispref/strings.texi index 46c01982f32..17a62b546b4 100644 --- a/lispref/strings.texi +++ b/lispref/strings.texi | |||
| @@ -700,8 +700,8 @@ in the copy with encodings of the corresponding @var{objects}. The | |||
| 700 | arguments @var{objects} are the computed values to be formatted. | 700 | arguments @var{objects} are the computed values to be formatted. |
| 701 | 701 | ||
| 702 | The characters in @var{string}, other than the format specifications, | 702 | The characters in @var{string}, other than the format specifications, |
| 703 | are copied directly into the output; if they have text properties, | 703 | are copied directly into the output, including their text properties, |
| 704 | these are copied into the output also. | 704 | if any. |
| 705 | @end defun | 705 | @end defun |
| 706 | 706 | ||
| 707 | @cindex @samp{%} in format | 707 | @cindex @samp{%} in format |
| @@ -719,6 +719,17 @@ For example: | |||
| 719 | @end group | 719 | @end group |
| 720 | @end example | 720 | @end example |
| 721 | 721 | ||
| 722 | Since @code{format} interprets @samp{%} characters as format | ||
| 723 | specifications, you should @emph{never} pass an arbitrary string as | ||
| 724 | the first argument. This is particularly true when the string is | ||
| 725 | generated by some Lisp code. Unless the string is @emph{known} to | ||
| 726 | never include any @samp{%} characters, pass @code{"%s"}, described | ||
| 727 | below, as the first argument, and the string as the second, like this: | ||
| 728 | |||
| 729 | @example | ||
| 730 | (format "%s" @var{arbitrary-string}) | ||
| 731 | @end example | ||
| 732 | |||
| 722 | If @var{string} contains more than one format specification, the | 733 | If @var{string} contains more than one format specification, the |
| 723 | format specifications correspond to successive values from | 734 | format specifications correspond to successive values from |
| 724 | @var{objects}. Thus, the first format specification in @var{string} | 735 | @var{objects}. Thus, the first format specification in @var{string} |
diff --git a/lispref/text.texi b/lispref/text.texi index 898f33443b5..4d2f278bee8 100644 --- a/lispref/text.texi +++ b/lispref/text.texi | |||
| @@ -103,9 +103,9 @@ This function returns the character following point in the current | |||
| 103 | buffer. This is similar to @code{(char-after (point))}. However, if | 103 | buffer. This is similar to @code{(char-after (point))}. However, if |
| 104 | point is at the end of the buffer, then @code{following-char} returns 0. | 104 | point is at the end of the buffer, then @code{following-char} returns 0. |
| 105 | 105 | ||
| 106 | Remember that point is always between characters, and the terminal | 106 | Remember that point is always between characters, and the cursor |
| 107 | cursor normally appears over the character following point. Therefore, | 107 | normally appears over the character following point. Therefore, the |
| 108 | the character returned by @code{following-char} is the character the | 108 | character returned by @code{following-char} is the character the |
| 109 | cursor is over. | 109 | cursor is over. |
| 110 | 110 | ||
| 111 | In this example, point is between the @samp{a} and the @samp{c}. | 111 | In this example, point is between the @samp{a} and the @samp{c}. |
| @@ -526,16 +526,6 @@ The value returned is @code{nil}. In an interactive call, @var{count} | |||
| 526 | is the numeric prefix argument. | 526 | is the numeric prefix argument. |
| 527 | @end deffn | 527 | @end deffn |
| 528 | 528 | ||
| 529 | @deffn Command split-line | ||
| 530 | This command splits the current line, moving the portion of the line | ||
| 531 | after point down vertically so that it is on the next line directly | ||
| 532 | below where it was before. Whitespace is inserted as needed at the | ||
| 533 | beginning of the lower line, using the @code{indent-to} function. | ||
| 534 | @code{split-line} returns the position of point. | ||
| 535 | |||
| 536 | Programs hardly ever use this function. | ||
| 537 | @end deffn | ||
| 538 | |||
| 539 | @defvar overwrite-mode | 529 | @defvar overwrite-mode |
| 540 | This variable controls whether overwrite mode is in effect. The value | 530 | This variable controls whether overwrite mode is in effect. The value |
| 541 | should be @code{overwrite-mode-textual}, @code{overwrite-mode-binary}, | 531 | should be @code{overwrite-mode-textual}, @code{overwrite-mode-binary}, |
| @@ -978,8 +968,11 @@ the @var{undo} value. | |||
| 978 | @comment node-name, next, previous, up | 968 | @comment node-name, next, previous, up |
| 979 | @subsection Functions for Yanking | 969 | @subsection Functions for Yanking |
| 980 | 970 | ||
| 981 | @dfn{Yanking} means reinserting an entry of previously killed text | 971 | This section describes higher-level commands for yanking, which are |
| 982 | from the kill ring. The text properties are copied too. | 972 | intended primarily for the user but useful also in Lisp programs. |
| 973 | Both @code{yank} and @code{yank-pop} honor the | ||
| 974 | @code{yank-excluded-properties} variable and @code{yank-handler} text | ||
| 975 | property (@pxref{Yanking}). | ||
| 983 | 976 | ||
| 984 | @deffn Command yank &optional arg | 977 | @deffn Command yank &optional arg |
| 985 | @cindex inserting killed text | 978 | @cindex inserting killed text |
| @@ -1213,7 +1206,7 @@ value for @code{kill-ring-max} is 60. | |||
| 1213 | to the buffer's text so that they can be undone. (The buffers that | 1206 | to the buffer's text so that they can be undone. (The buffers that |
| 1214 | don't have one are usually special-purpose buffers for which Emacs | 1207 | don't have one are usually special-purpose buffers for which Emacs |
| 1215 | assumes that undoing is not useful. In particular, any buffer whose | 1208 | assumes that undoing is not useful. In particular, any buffer whose |
| 1216 | name begins with a space has its undo recording off by default, | 1209 | name begins with a space has its undo recording off by default; |
| 1217 | see @ref{Buffer Names}.) All the primitives that modify the | 1210 | see @ref{Buffer Names}.) All the primitives that modify the |
| 1218 | text in the buffer automatically add elements to the front of the undo | 1211 | text in the buffer automatically add elements to the front of the undo |
| 1219 | list, which is in the variable @code{buffer-undo-list}. | 1212 | list, which is in the variable @code{buffer-undo-list}. |
| @@ -1318,8 +1311,7 @@ they're being called for the sake of undoing. | |||
| 1318 | @defun primitive-undo count list | 1311 | @defun primitive-undo count list |
| 1319 | This is the basic function for undoing elements of an undo list. | 1312 | This is the basic function for undoing elements of an undo list. |
| 1320 | It undoes the first @var{count} elements of @var{list}, returning | 1313 | It undoes the first @var{count} elements of @var{list}, returning |
| 1321 | the rest of @var{list}. You could write this function in Lisp, | 1314 | the rest of @var{list}. |
| 1322 | but it is convenient to have it in C. | ||
| 1323 | 1315 | ||
| 1324 | @code{primitive-undo} adds elements to the buffer's undo list when it | 1316 | @code{primitive-undo} adds elements to the buffer's undo list when it |
| 1325 | changes the buffer. Undo commands avoid confusion by saving the undo | 1317 | changes the buffer. Undo commands avoid confusion by saving the undo |
| @@ -1372,7 +1364,9 @@ them back to size limits you can set. (For this purpose, the ``size'' | |||
| 1372 | of an undo list measures the cons cells that make up the list, plus the | 1364 | of an undo list measures the cons cells that make up the list, plus the |
| 1373 | strings of deleted text.) Three variables control the range of acceptable | 1365 | strings of deleted text.) Three variables control the range of acceptable |
| 1374 | sizes: @code{undo-limit}, @code{undo-strong-limit} and | 1366 | sizes: @code{undo-limit}, @code{undo-strong-limit} and |
| 1375 | @code{undo-outer-limit}. | 1367 | @code{undo-outer-limit}. In these variables, size is counted as the |
| 1368 | number of bytes occupied, which includes both saved text and other | ||
| 1369 | data. | ||
| 1376 | 1370 | ||
| 1377 | @defopt undo-limit | 1371 | @defopt undo-limit |
| 1378 | This is the soft limit for the acceptable size of an undo list. The | 1372 | This is the soft limit for the acceptable size of an undo list. The |
| @@ -1392,6 +1386,17 @@ exceeds this limit, Emacs discards the info and displays a warning. | |||
| 1392 | This is a last ditch limit to prevent memory overflow. | 1386 | This is a last ditch limit to prevent memory overflow. |
| 1393 | @end defopt | 1387 | @end defopt |
| 1394 | 1388 | ||
| 1389 | @defopt undo-ask-before-discard | ||
| 1390 | If this variable is non-@code{nil}, when the undo info exceeds | ||
| 1391 | @code{undo-outer-limit}, Emacs asks in the echo area whether to | ||
| 1392 | discard the info. The default value is @code{nil}, which means to | ||
| 1393 | discard it automatically. | ||
| 1394 | |||
| 1395 | This option is mainly intended for debugging. Garbage collection is | ||
| 1396 | inhibited while the question is asked, which means that Emacs might | ||
| 1397 | leak memory if the user waits too long before answering the question. | ||
| 1398 | @end defopt | ||
| 1399 | |||
| 1395 | @node Filling | 1400 | @node Filling |
| 1396 | @comment node-name, next, previous, up | 1401 | @comment node-name, next, previous, up |
| 1397 | @section Filling | 1402 | @section Filling |
| @@ -1481,8 +1486,6 @@ it. If the region was made up of many paragraphs, the blank lines | |||
| 1481 | between paragraphs are removed. This function justifies as well as | 1486 | between paragraphs are removed. This function justifies as well as |
| 1482 | filling when @var{justify} is non-@code{nil}. | 1487 | filling when @var{justify} is non-@code{nil}. |
| 1483 | 1488 | ||
| 1484 | In an interactive call, any prefix argument requests justification. | ||
| 1485 | |||
| 1486 | If @var{nosqueeze} is non-@code{nil}, that means to leave whitespace | 1489 | If @var{nosqueeze} is non-@code{nil}, that means to leave whitespace |
| 1487 | other than line breaks untouched. If @var{squeeze-after} is | 1490 | other than line breaks untouched. If @var{squeeze-after} is |
| 1488 | non-@code{nil}, it specifies a position in the region, and means don't | 1491 | non-@code{nil}, it specifies a position in the region, and means don't |
| @@ -1522,6 +1525,11 @@ values are @code{left}, @code{right}, @code{full}, @code{center}, or | |||
| 1522 | @defun current-justification | 1525 | @defun current-justification |
| 1523 | This function returns the proper justification style to use for filling | 1526 | This function returns the proper justification style to use for filling |
| 1524 | the text around point. | 1527 | the text around point. |
| 1528 | |||
| 1529 | This returns the value of the @code{justification} text property at | ||
| 1530 | point, or the variable @var{default-justification} if there is no such | ||
| 1531 | text property. However, it returns @code{nil} rather than @code{none} | ||
| 1532 | to mean ``don't justify''. | ||
| 1525 | @end defun | 1533 | @end defun |
| 1526 | 1534 | ||
| 1527 | @defopt sentence-end-double-space | 1535 | @defopt sentence-end-double-space |
| @@ -1569,14 +1577,14 @@ newlines'' act as paragraph separators. | |||
| 1569 | @section Margins for Filling | 1577 | @section Margins for Filling |
| 1570 | 1578 | ||
| 1571 | @defopt fill-prefix | 1579 | @defopt fill-prefix |
| 1572 | This buffer-local variable specifies a string of text that appears at | 1580 | This buffer-local variable, if non-@code{nil}, specifies a string of |
| 1573 | the beginning | 1581 | text that appears at the beginning of normal text lines and should be |
| 1574 | of normal text lines and should be disregarded when filling them. Any | 1582 | disregarded when filling them. Any line that fails to start with the |
| 1575 | line that fails to start with the fill prefix is considered the start of | 1583 | fill prefix is considered the start of a paragraph; so is any line |
| 1576 | a paragraph; so is any line that starts with the fill prefix followed by | 1584 | that starts with the fill prefix followed by additional whitespace. |
| 1577 | additional whitespace. Lines that start with the fill prefix but no | 1585 | Lines that start with the fill prefix but no additional whitespace are |
| 1578 | additional whitespace are ordinary text lines that can be filled | 1586 | ordinary text lines that can be filled together. The resulting filled |
| 1579 | together. The resulting filled lines also start with the fill prefix. | 1587 | lines also start with the fill prefix. |
| 1580 | 1588 | ||
| 1581 | The fill prefix follows the left margin whitespace, if any. | 1589 | The fill prefix follows the left margin whitespace, if any. |
| 1582 | @end defopt | 1590 | @end defopt |
| @@ -1661,12 +1669,11 @@ becomes buffer-local when set in any fashion. | |||
| 1661 | 1669 | ||
| 1662 | @defvar fill-nobreak-predicate | 1670 | @defvar fill-nobreak-predicate |
| 1663 | This variable gives major modes a way to specify not to break a line | 1671 | This variable gives major modes a way to specify not to break a line |
| 1664 | at certain places. Its value should be a list of functions, but a | 1672 | at certain places. Its value should be a list of functions. Whenever |
| 1665 | single function is also supported for compatibility. Whenever filling | 1673 | filling considers breaking the line at a certain place in the buffer, |
| 1666 | considers breaking the line at a certain place in the buffer, it calls | 1674 | it calls each of these functions with no arguments and with point |
| 1667 | each of these functions with no arguments and with point located at | 1675 | located at that place. If any of the functions returns |
| 1668 | that place. If any of the functions returns non-@code{nil}, then the | 1676 | non-@code{nil}, then the line won't be broken there. |
| 1669 | line won't be broken there. | ||
| 1670 | @end defvar | 1677 | @end defvar |
| 1671 | 1678 | ||
| 1672 | @node Adaptive Fill | 1679 | @node Adaptive Fill |
| @@ -1733,7 +1740,7 @@ Adaptive Fill mode matches this regular expression against the text | |||
| 1733 | starting after the left margin whitespace (if any) on a line; the | 1740 | starting after the left margin whitespace (if any) on a line; the |
| 1734 | characters it matches are that line's candidate for the fill prefix. | 1741 | characters it matches are that line's candidate for the fill prefix. |
| 1735 | 1742 | ||
| 1736 | @w{@code{"[ \t]*\\([-|#;>*]+[ \t]*\\|(?[0-9]+[.)][ \t]*\\)*"}} is the | 1743 | @w{@code{"[ \t]*\\([-!|#%;>*·•‣⁃◦]+[ \t]*\\|(?[0-9]+[.)][ \t]*\\)*"}} is the |
| 1737 | default value. This matches a number enclosed in parentheses or | 1744 | default value. This matches a number enclosed in parentheses or |
| 1738 | followed by a period, or certain punctuation characters, or any | 1745 | followed by a period, or certain punctuation characters, or any |
| 1739 | sequence of these intermingled with whitespace. In particular, it | 1746 | sequence of these intermingled with whitespace. In particular, it |
| @@ -1898,7 +1905,8 @@ the sort order." | |||
| 1898 | (save-restriction | 1905 | (save-restriction |
| 1899 | (narrow-to-region beg end) | 1906 | (narrow-to-region beg end) |
| 1900 | (goto-char (point-min)) | 1907 | (goto-char (point-min)) |
| 1901 | (sort-subr reverse 'forward-line 'end-of-line)))) | 1908 | (let ((inhibit-field-text-motion t)) |
| 1909 | (sort-subr reverse 'forward-line 'end-of-line))))) | ||
| 1902 | @end group | 1910 | @end group |
| 1903 | @end example | 1911 | @end example |
| 1904 | 1912 | ||
| @@ -2054,9 +2062,12 @@ One unusual thing about this command is that the entire line | |||
| 2054 | containing position @var{beg}, and the entire line containing position | 2062 | containing position @var{beg}, and the entire line containing position |
| 2055 | @var{end}, are included in the region sorted. | 2063 | @var{end}, are included in the region sorted. |
| 2056 | 2064 | ||
| 2057 | Note that @code{sort-columns} uses the @code{sort} utility program, | 2065 | Note that @code{sort-columns} rejects text that contains tabs, because |
| 2058 | and so cannot work properly on text containing tab characters. Use | 2066 | tabs could be split across the specified columns. Use @kbd{M-x |
| 2059 | @kbd{M-x untabify} to convert tabs to spaces before sorting. | 2067 | untabify} to convert tabs to spaces before sorting. |
| 2068 | |||
| 2069 | When possible, this command actually works by calling the @code{sort} | ||
| 2070 | utility program. | ||
| 2060 | @end deffn | 2071 | @end deffn |
| 2061 | 2072 | ||
| 2062 | @node Columns | 2073 | @node Columns |
| @@ -2391,6 +2402,7 @@ spaces and tab characters to reach the next tab stop column; it does not | |||
| 2391 | affect the display of tab characters in the buffer (@pxref{Usual | 2402 | affect the display of tab characters in the buffer (@pxref{Usual |
| 2392 | Display}). Note that the @key{TAB} character as input uses this tab | 2403 | Display}). Note that the @key{TAB} character as input uses this tab |
| 2393 | stop feature only in a few major modes, such as Text mode. | 2404 | stop feature only in a few major modes, such as Text mode. |
| 2405 | @xref{Tab Stops,,, emacs, The GNU Emacs Manual}. | ||
| 2394 | 2406 | ||
| 2395 | @deffn Command tab-to-tab-stop | 2407 | @deffn Command tab-to-tab-stop |
| 2396 | This command inserts spaces or tabs before point, up to the next tab | 2408 | This command inserts spaces or tabs before point, up to the next tab |
| @@ -3079,22 +3091,23 @@ This feature is used in the mode line and for other active text. | |||
| 3079 | @cindex keymap of character | 3091 | @cindex keymap of character |
| 3080 | @kindex keymap @r{(text property)} | 3092 | @kindex keymap @r{(text property)} |
| 3081 | The @code{keymap} property specifies an additional keymap for | 3093 | The @code{keymap} property specifies an additional keymap for |
| 3082 | commands. The property's value for the character before point applies | 3094 | commands. When this keymap applies, it is used for key lookup before |
| 3083 | if it is non-@code{nil} and rear-sticky, and the property's value for | 3095 | the minor mode keymaps and before the buffer's local map. |
| 3084 | the character after point applies if it is non-@code{nil} and | 3096 | @xref{Active Keymaps}. If the property value is a symbol, the |
| 3097 | symbol's function definition is used as the keymap. | ||
| 3098 | |||
| 3099 | The property's value for the character before point applies if it is | ||
| 3100 | non-@code{nil} and rear-sticky, and the property's value for the | ||
| 3101 | character after point applies if it is non-@code{nil} and | ||
| 3085 | front-sticky. (For mouse clicks, the position of the click is used | 3102 | front-sticky. (For mouse clicks, the position of the click is used |
| 3086 | instead of the position of point.) If the property value is a symbol, | 3103 | instead of the position of point.) |
| 3087 | the symbol's function definition is used as the keymap. | ||
| 3088 | |||
| 3089 | When this keymap applies, it is used for key lookup before the minor | ||
| 3090 | mode keymaps and before the buffer's local map. @xref{Active | ||
| 3091 | Keymaps}. | ||
| 3092 | 3104 | ||
| 3093 | @item local-map | 3105 | @item local-map |
| 3094 | @kindex local-map @r{(text property)} | 3106 | @kindex local-map @r{(text property)} |
| 3095 | This property works like @code{keymap} except that it specifies a | 3107 | This property works like @code{keymap} except that it specifies a |
| 3096 | keymap to use @emph{instead of} the buffer's local map. For most | 3108 | keymap to use @emph{instead of} the buffer's local map. For most |
| 3097 | purposes (perhaps all purposes), the @code{keymap} is superior. | 3109 | purposes (perhaps all purposes), it is better to use the @code{keymap} |
| 3110 | property. | ||
| 3098 | 3111 | ||
| 3099 | @item syntax-table | 3112 | @item syntax-table |
| 3100 | The @code{syntax-table} property overrides what the syntax table says | 3113 | The @code{syntax-table} property overrides what the syntax table says |
| @@ -3479,26 +3492,39 @@ being called over and over for the same text. | |||
| 3479 | @subsection Defining Clickable Text | 3492 | @subsection Defining Clickable Text |
| 3480 | @cindex clickable text | 3493 | @cindex clickable text |
| 3481 | 3494 | ||
| 3482 | There are two parts of setting up @dfn{clickable text} in a buffer: | 3495 | @dfn{Clickable text} is text that can be clicked, with either the |
| 3483 | (1) to make that text highlight when the mouse moves over it, and (2) | 3496 | the mouse or via keyboard commands, to produce some result. Many |
| 3484 | to make a mouse button do something when you click on that text. | 3497 | major modes use clickable text to implement features such as |
| 3498 | hyper-links. The @code{button} package provides an easy way to insert | ||
| 3499 | and manipulate clickable text. @xref{Buttons}. | ||
| 3500 | |||
| 3501 | In this section, we will explain how to manually set up clickable | ||
| 3502 | text in a buffer using text properties. This involves two things: (1) | ||
| 3503 | indicating clickability when the mouse moves over the text, and (2) | ||
| 3504 | making @kbd{RET} or a mouse click on that text do something. | ||
| 3485 | 3505 | ||
| 3486 | For highlighting, use the @code{mouse-face} text property. Here is | 3506 | Indicating clickability usually involves highlighting the text, and |
| 3487 | an example of how Dired does it: | 3507 | often involves displaying helpful information about the action, such |
| 3508 | as which mouse button to press, or a short summary of the action. | ||
| 3509 | This can be done with the @code{mouse-face} and @code{help-echo} | ||
| 3510 | text properties. @xref{Special Properties}. | ||
| 3511 | Here is an example of how Dired does it: | ||
| 3488 | 3512 | ||
| 3489 | @smallexample | 3513 | @smallexample |
| 3490 | (condition-case nil | 3514 | (condition-case nil |
| 3491 | (if (dired-move-to-filename) | 3515 | (if (dired-move-to-filename) |
| 3492 | (put-text-property (point) | 3516 | (add-text-properties |
| 3493 | (save-excursion | 3517 | (point) |
| 3494 | (dired-move-to-end-of-filename) | 3518 | (save-excursion |
| 3495 | (point)) | 3519 | (dired-move-to-end-of-filename) |
| 3496 | 'mouse-face 'highlight)) | 3520 | (point)) |
| 3521 | '(mouse-face highlight | ||
| 3522 | help-echo "mouse-2: visit this file in other window"))) | ||
| 3497 | (error nil)) | 3523 | (error nil)) |
| 3498 | @end smallexample | 3524 | @end smallexample |
| 3499 | 3525 | ||
| 3500 | @noindent | 3526 | @noindent |
| 3501 | The first two arguments to @code{put-text-property} specify the | 3527 | The first two arguments to @code{add-text-properties} specify the |
| 3502 | beginning and end of the text. | 3528 | beginning and end of the text. |
| 3503 | 3529 | ||
| 3504 | The usual way to make the mouse do something when you click it | 3530 | The usual way to make the mouse do something when you click it |
| @@ -3508,24 +3534,34 @@ is done by the command definition. Here is how Dired does it: | |||
| 3508 | 3534 | ||
| 3509 | @smallexample | 3535 | @smallexample |
| 3510 | (defun dired-mouse-find-file-other-window (event) | 3536 | (defun dired-mouse-find-file-other-window (event) |
| 3511 | "In dired, visit the file or directory name you click on." | 3537 | "In Dired, visit the file or directory name you click on." |
| 3512 | (interactive "e") | 3538 | (interactive "e") |
| 3513 | (let (file) | 3539 | (let (window pos file) |
| 3514 | (save-excursion | 3540 | (save-excursion |
| 3515 | (set-buffer (window-buffer (posn-window (event-end event)))) | 3541 | (setq window (posn-window (event-end event)) |
| 3516 | (save-excursion | 3542 | pos (posn-point (event-end event))) |
| 3517 | (goto-char (posn-point (event-end event))) | 3543 | (if (not (windowp window)) |
| 3518 | (setq file (dired-get-filename)))) | 3544 | (error "No file chosen")) |
| 3519 | (select-window (posn-window (event-end event))) | 3545 | (set-buffer (window-buffer window)) |
| 3520 | (find-file-other-window (file-name-sans-versions file t)))) | 3546 | (goto-char pos) |
| 3547 | (setq file (dired-get-file-for-visit))) | ||
| 3548 | (if (file-directory-p file) | ||
| 3549 | (or (and (cdr dired-subdir-alist) | ||
| 3550 | (dired-goto-subdir file)) | ||
| 3551 | (progn | ||
| 3552 | (select-window window) | ||
| 3553 | (dired-other-window file))) | ||
| 3554 | (select-window window) | ||
| 3555 | (find-file-other-window (file-name-sans-versions file t))))) | ||
| 3521 | @end smallexample | 3556 | @end smallexample |
| 3522 | 3557 | ||
| 3523 | @noindent | 3558 | @noindent |
| 3524 | The reason for the outer @code{save-excursion} construct is to avoid | 3559 | The reason for the @code{save-excursion} construct is to avoid |
| 3525 | changing the current buffer; the reason for the inner one is to avoid | 3560 | changing the current buffer. In this case, |
| 3526 | permanently altering point in the buffer you click on. In this case, | 3561 | Dired uses the functions @code{posn-window} and @code{posn-point} |
| 3527 | Dired uses the function @code{dired-get-filename} to determine which | 3562 | to determine which buffer the click happened in and where, and |
| 3528 | file to visit, based on the position found in the event. | 3563 | in that buffer, @code{dired-get-file-for-visit} to determine which |
| 3564 | file to visit. | ||
| 3529 | 3565 | ||
| 3530 | Instead of defining a mouse command for the major mode, you can define | 3566 | Instead of defining a mouse command for the major mode, you can define |
| 3531 | a key binding for the clickable text itself, using the @code{keymap} | 3567 | a key binding for the clickable text itself, using the @code{keymap} |
| @@ -3697,7 +3733,8 @@ field nor the following field; the field functions treat it as belonging | |||
| 3697 | to an empty field whose beginning and end are both at @var{pos}. | 3733 | to an empty field whose beginning and end are both at @var{pos}. |
| 3698 | 3734 | ||
| 3699 | In all of these functions, if @var{pos} is omitted or @code{nil}, the | 3735 | In all of these functions, if @var{pos} is omitted or @code{nil}, the |
| 3700 | value of point is used by default. | 3736 | value of point is used by default. If narrowing is in effect, then |
| 3737 | @var{pos} should fall within the accessible portion. @xref{Narrowing}. | ||
| 3701 | 3738 | ||
| 3702 | @defun field-beginning &optional pos escape-from-edge limit | 3739 | @defun field-beginning &optional pos escape-from-edge limit |
| 3703 | This function returns the beginning of the field specified by @var{pos}. | 3740 | This function returns the beginning of the field specified by @var{pos}. |