diff options
| author | Paul Eggert | 2011-09-03 16:03:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-09-03 16:03:38 -0700 |
| commit | b49e353d9d01adbe60bc5d0b1658b4ef978b0b06 (patch) | |
| tree | 9f2ffa6f7a6562abf661a4951012b488ad8b1ae7 /doc/lispref | |
| parent | 74b880cbc18bd0194c7b1fc44c4a983ee05adae2 (diff) | |
| parent | bc3200871917d5c54c8c4299a06bf8f8ba2ea02d (diff) | |
| download | emacs-b49e353d9d01adbe60bc5d0b1658b4ef978b0b06.tar.gz emacs-b49e353d9d01adbe60bc5d0b1658b4ef978b0b06.zip | |
Merge from trunk.
Diffstat (limited to 'doc/lispref')
| -rw-r--r-- | doc/lispref/ChangeLog | 94 | ||||
| -rw-r--r-- | doc/lispref/debugging.texi | 19 | ||||
| -rw-r--r-- | doc/lispref/display.texi | 242 | ||||
| -rw-r--r-- | doc/lispref/elisp.texi | 6 | ||||
| -rw-r--r-- | doc/lispref/files.texi | 64 | ||||
| -rw-r--r-- | doc/lispref/frames.texi | 17 | ||||
| -rw-r--r-- | doc/lispref/lists.texi | 2 | ||||
| -rw-r--r-- | doc/lispref/modes.texi | 389 | ||||
| -rw-r--r-- | doc/lispref/nonascii.texi | 66 | ||||
| -rw-r--r-- | doc/lispref/objects.texi | 10 | ||||
| -rw-r--r-- | doc/lispref/os.texi | 104 | ||||
| -rw-r--r-- | doc/lispref/searching.texi | 6 | ||||
| -rw-r--r-- | doc/lispref/syntax.texi | 18 | ||||
| -rw-r--r-- | doc/lispref/text.texi | 5 | ||||
| -rw-r--r-- | doc/lispref/vol1.texi | 8 | ||||
| -rw-r--r-- | doc/lispref/vol2.texi | 8 |
16 files changed, 680 insertions, 378 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index f08ee3a227c..3f52d684683 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,97 @@ | |||
| 1 | 2011-08-30 Dani Moncayo <dmoncayo@gmail.com> (tiny change) | ||
| 2 | |||
| 3 | * lists.texi (Building Lists): Fix typo. | ||
| 4 | |||
| 5 | 2011-08-30 Chong Yidong <cyd@stupidchicken.com> | ||
| 6 | |||
| 7 | * display.texi (Basic Faces): New node. Document new faces. | ||
| 8 | |||
| 9 | * modes.texi (Major Mode Conventions): Move some text there. | ||
| 10 | (Mode Help): Remove major-mode var, duplicated in Major Modes. | ||
| 11 | |||
| 12 | 2011-08-29 Chong Yidong <cyd@stupidchicken.com> | ||
| 13 | |||
| 14 | * modes.texi (Basic Major Modes): New node. Callers updated. | ||
| 15 | (Major Modes): Document fundamental-mode and major-mode. | ||
| 16 | (Major Mode Basics): Node deleted; text moved to Major Modes. | ||
| 17 | (Derived Modes): Document derived-mode-p. | ||
| 18 | |||
| 19 | 2011-08-28 Chong Yidong <cyd@stupidchicken.com> | ||
| 20 | |||
| 21 | * files.texi (Changing Files, Create/Delete Dirs): Document new | ||
| 22 | arguments for delete-file, delete-directory, and copy-directory. | ||
| 23 | (Visiting Functions): Remove view-file; it is documented in the | ||
| 24 | Emacs manual. | ||
| 25 | |||
| 26 | * frames.texi (Layout Parameters): The defaults for the | ||
| 27 | menu-bar-lines and tool-bar-lines parameters depend on the mode. | ||
| 28 | |||
| 29 | * display.texi (Progress): Document spinner functionality. | ||
| 30 | |||
| 31 | * os.texi (Killing Emacs): Note that kill-emacs can be called by | ||
| 32 | operating system signals. Refer to save-buffers-kill-terminal | ||
| 33 | instead of save-buffers-kill-emacs. | ||
| 34 | |||
| 35 | * objects.texi (Symbol Type): Document ## print representation. | ||
| 36 | |||
| 37 | 2011-08-25 Eli Zaretskii <eliz@gnu.org> | ||
| 38 | |||
| 39 | * display.texi (Specified Space): Mention that `space' specs | ||
| 40 | influence bidi reordering. | ||
| 41 | (Bidirectional Display): Explain how to use `(space . PROPS)' for | ||
| 42 | separating fields with bidirectional content. | ||
| 43 | |||
| 44 | 2011-08-24 Eli Zaretskii <eliz@gnu.org> | ||
| 45 | |||
| 46 | * display.texi (Bidirectional Display): Document return value in | ||
| 47 | buffers that are not bidi-reordered for display, and in unibyte | ||
| 48 | buffers. | ||
| 49 | |||
| 50 | 2011-08-23 Eli Zaretskii <eliz@gnu.org> | ||
| 51 | |||
| 52 | * nonascii.texi (Character Properties): Document the values for | ||
| 53 | unassigned codepoints. | ||
| 54 | |||
| 55 | 2011-08-18 Eli Zaretskii <eliz@gnu.org> | ||
| 56 | |||
| 57 | * nonascii.texi (Character Properties): Document use of | ||
| 58 | `bidi-class' and `mirroring' properties as part of reordering. | ||
| 59 | Provide cross-references to "Bidirectional Display". | ||
| 60 | |||
| 61 | * display.texi (Bidirectional Display): Document the pitfalls of | ||
| 62 | concatenating strings with bidirectional content, with possible | ||
| 63 | solutions. Document bidi-string-mark-left-to-right. Mention | ||
| 64 | paragraph direction in modes that inherit from prog-mode. | ||
| 65 | Document use of `bidi-class' and `mirroring' properties as part of | ||
| 66 | reordering. | ||
| 67 | |||
| 68 | 2011-08-16 Eli Zaretskii <eliz@gnu.org> | ||
| 69 | |||
| 70 | * modes.texi (Major Mode Conventions): Improve the documentation | ||
| 71 | of `mode-class' `special' modes. | ||
| 72 | |||
| 73 | * nonascii.texi (Character Properties): Document the `mirroring' | ||
| 74 | property. Add index entries. | ||
| 75 | |||
| 76 | * syntax.texi (Categories): Add an example of defining a new | ||
| 77 | category and category table. | ||
| 78 | |||
| 79 | * searching.texi (Regexp Backslash): Document how to display | ||
| 80 | existing categories. Mention the possibility of adding | ||
| 81 | categories, and add an xref to where this is described. Add an | ||
| 82 | index entry. | ||
| 83 | |||
| 84 | 2011-08-09 Chong Yidong <cyd@stupidchicken.com> | ||
| 85 | |||
| 86 | * text.texi (Special Properties): | ||
| 87 | * display.texi (Overlay Properties): Note that mouse-face cannot | ||
| 88 | change the text size (Bug#8530). | ||
| 89 | |||
| 90 | 2011-08-08 Chong Yidong <cyd@stupidchicken.com> | ||
| 91 | |||
| 92 | * os.texi (Time of Day): Remove set-time-zone-rule, and recommend | ||
| 93 | using setenv instead. | ||
| 94 | |||
| 1 | 2011-07-28 Eli Zaretskii <eliz@gnu.org> | 95 | 2011-07-28 Eli Zaretskii <eliz@gnu.org> |
| 2 | 96 | ||
| 3 | * display.texi (Bidirectional Display): Document the fact that | 97 | * display.texi (Bidirectional Display): Document the fact that |
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi index d9e807afb88..757906f286e 100644 --- a/doc/lispref/debugging.texi +++ b/doc/lispref/debugging.texi | |||
| @@ -596,25 +596,6 @@ forms are elided. | |||
| 596 | @end smallexample | 596 | @end smallexample |
| 597 | @end deffn | 597 | @end deffn |
| 598 | 598 | ||
| 599 | @ignore @c Not worth mentioning | ||
| 600 | @defopt stack-trace-on-error | ||
| 601 | @cindex stack trace | ||
| 602 | This variable controls whether Lisp automatically displays a | ||
| 603 | backtrace buffer after every error that is not handled. A quit signal | ||
| 604 | counts as an error for this variable. If it is non-@code{nil} then a | ||
| 605 | backtrace is shown in a pop-up buffer named @samp{*Backtrace*} on every | ||
| 606 | error. If it is @code{nil}, then a backtrace is not shown. | ||
| 607 | |||
| 608 | When a backtrace is shown, that buffer is not selected. If either | ||
| 609 | @code{debug-on-quit} or @code{debug-on-error} is also non-@code{nil}, then | ||
| 610 | a backtrace is shown in one buffer, and the debugger is popped up in | ||
| 611 | another buffer with its own backtrace. | ||
| 612 | |||
| 613 | We consider this feature to be obsolete and superseded by the debugger | ||
| 614 | itself. | ||
| 615 | @end defopt | ||
| 616 | @end ignore | ||
| 617 | |||
| 618 | @defvar debug-on-next-call | 599 | @defvar debug-on-next-call |
| 619 | @cindex @code{eval}, and debugging | 600 | @cindex @code{eval}, and debugging |
| 620 | @cindex @code{apply}, and debugging | 601 | @cindex @code{apply}, and debugging |
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 077d0992232..68291319ef1 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi | |||
| @@ -367,10 +367,9 @@ echo area, or @code{nil} if there is none. | |||
| 367 | When an operation can take a while to finish, you should inform the | 367 | When an operation can take a while to finish, you should inform the |
| 368 | user about the progress it makes. This way the user can estimate | 368 | user about the progress it makes. This way the user can estimate |
| 369 | remaining time and clearly see that Emacs is busy working, not hung. | 369 | remaining time and clearly see that Emacs is busy working, not hung. |
| 370 | A convenient way to do this is to use a @dfn{progress reporter}. | ||
| 370 | 371 | ||
| 371 | Functions listed in this section provide simple and efficient way of | 372 | Here is a working example that does nothing useful: |
| 372 | reporting operation progress. Here is a working example that does | ||
| 373 | nothing useful: | ||
| 374 | 373 | ||
| 375 | @smallexample | 374 | @smallexample |
| 376 | (let ((progress-reporter | 375 | (let ((progress-reporter |
| @@ -382,11 +381,11 @@ nothing useful: | |||
| 382 | (progress-reporter-done progress-reporter)) | 381 | (progress-reporter-done progress-reporter)) |
| 383 | @end smallexample | 382 | @end smallexample |
| 384 | 383 | ||
| 385 | @defun make-progress-reporter message min-value max-value &optional current-value min-change min-time | 384 | @defun make-progress-reporter message &optional min-value max-value current-value min-change min-time |
| 386 | This function creates and returns a @dfn{progress reporter}---an | 385 | This function creates and returns a progress reporter object, which |
| 387 | object you will use as an argument for all other functions listed | 386 | you will use as an argument for the other functions listed below. The |
| 388 | here. The idea is to precompute as much data as possible to make | 387 | idea is to precompute as much data as possible to make progress |
| 389 | progress reporting very fast. | 388 | reporting very fast. |
| 390 | 389 | ||
| 391 | When this progress reporter is subsequently used, it will display | 390 | When this progress reporter is subsequently used, it will display |
| 392 | @var{message} in the echo area, followed by progress percentage. | 391 | @var{message} in the echo area, followed by progress percentage. |
| @@ -394,24 +393,28 @@ When this progress reporter is subsequently used, it will display | |||
| 394 | on a filename, for instance, use @code{format} before calling this | 393 | on a filename, for instance, use @code{format} before calling this |
| 395 | function. | 394 | function. |
| 396 | 395 | ||
| 397 | @var{min-value} and @var{max-value} arguments stand for starting and | 396 | The arguments @var{min-value} and @var{max-value} should be numbers |
| 398 | final states of your operation. For instance, if you scan a buffer, | 397 | standing for the starting and final states of the operation. For |
| 399 | they should be the results of @code{point-min} and @code{point-max} | 398 | instance, an operation that ``scans'' a buffer should set these to the |
| 400 | correspondingly. It is required that @var{max-value} is greater than | 399 | results of @code{point-min} and @code{point-max} correspondingly. |
| 401 | @var{min-value}. If you create progress reporter when some part of | 400 | @var{max-value} should be greater than @var{min-value}. |
| 402 | the operation has already been completed, then specify | 401 | |
| 403 | @var{current-value} argument. But normally you should omit it or set | 402 | Alternatively, you can set @var{min-value} and @var{max-value} to |
| 404 | it to @code{nil}---it will default to @var{min-value} then. | 403 | @code{nil}. In that case, the progress reporter does not report |
| 405 | 404 | process percentages; it instead displays a ``spinner'' that rotates a | |
| 406 | Remaining arguments control the rate of echo area updates. Progress | 405 | notch each time you update the progress reporter. |
| 407 | reporter will wait for at least @var{min-change} more percents of the | 406 | |
| 408 | operation to be completed before printing next message. | 407 | If @var{min-value} and @var{max-value} are numbers, you can give the |
| 409 | @var{min-time} specifies the minimum time in seconds to pass between | 408 | argument @var{current-value} a numerical value specifying the initial |
| 410 | successive prints. It can be fractional. Depending on Emacs and | 409 | progress; if omitted, this defaults to @var{min-value}. |
| 411 | system capabilities, progress reporter may or may not respect this | 410 | |
| 412 | last argument or do it with varying precision. Default value for | 411 | The remaining arguments control the rate of echo area updates. The |
| 413 | @var{min-change} is 1 (one percent), for @var{min-time}---0.2 | 412 | progress reporter will wait for at least @var{min-change} more |
| 414 | (seconds.) | 413 | percents of the operation to be completed before printing next |
| 414 | message; the default is one percent. @var{min-time} specifies the | ||
| 415 | minimum time in seconds to pass between successive prints; the default | ||
| 416 | is 0.2 seconds. (On some operating systems, the progress reporter may | ||
| 417 | handle fractions of seconds with varying precision). | ||
| 415 | 418 | ||
| 416 | This function calls @code{progress-reporter-update}, so the first | 419 | This function calls @code{progress-reporter-update}, so the first |
| 417 | message is printed immediately. | 420 | message is printed immediately. |
| @@ -1454,7 +1457,10 @@ specify just the foreground color or just the background color. | |||
| 1454 | @item mouse-face | 1457 | @item mouse-face |
| 1455 | @kindex mouse-face @r{(overlay property)} | 1458 | @kindex mouse-face @r{(overlay property)} |
| 1456 | This property is used instead of @code{face} when the mouse is within | 1459 | This property is used instead of @code{face} when the mouse is within |
| 1457 | the range of the overlay. | 1460 | the range of the overlay. However, Emacs ignores all face attributes |
| 1461 | from this property that alter the text size (e.g. @code{:height}, | ||
| 1462 | @code{:weight}, and @code{:slant}). Those attributes are always the | ||
| 1463 | same as in the unhighlighted text. | ||
| 1458 | 1464 | ||
| 1459 | @item display | 1465 | @item display |
| 1460 | @kindex display @r{(overlay property)} | 1466 | @kindex display @r{(overlay property)} |
| @@ -1827,9 +1833,10 @@ particular face name a special meaning in one frame if you wish. | |||
| 1827 | * Face Attributes:: What is in a face? | 1833 | * Face Attributes:: What is in a face? |
| 1828 | * Attribute Functions:: Functions to examine and set face attributes. | 1834 | * Attribute Functions:: Functions to examine and set face attributes. |
| 1829 | * Displaying Faces:: How Emacs combines the faces specified for a character. | 1835 | * Displaying Faces:: How Emacs combines the faces specified for a character. |
| 1830 | * Face Remapping:: Remapping faces to alternative definitions. | 1836 | * Face Remapping:: Remapping faces to alternative definitions. |
| 1831 | * Face Functions:: How to define and examine faces. | 1837 | * Face Functions:: How to define and examine faces. |
| 1832 | * Auto Faces:: Hook for automatic face assignment. | 1838 | * Auto Faces:: Hook for automatic face assignment. |
| 1839 | * Basic Faces:: Faces that are defined by default. | ||
| 1833 | * Font Selection:: Finding the best available font for a face. | 1840 | * Font Selection:: Finding the best available font for a face. |
| 1834 | * Font Lookup:: Looking up the names of available fonts | 1841 | * Font Lookup:: Looking up the names of available fonts |
| 1835 | and information about them. | 1842 | and information about them. |
| @@ -2681,6 +2688,62 @@ For efficiency, we recommend writing these functions so that they | |||
| 2681 | usually assign faces to around 400 to 600 characters at each call. | 2688 | usually assign faces to around 400 to 600 characters at each call. |
| 2682 | @end defvar | 2689 | @end defvar |
| 2683 | 2690 | ||
| 2691 | @node Basic Faces | ||
| 2692 | @subsection Basic Faces | ||
| 2693 | |||
| 2694 | If your Emacs Lisp program needs to assign some faces to text, it is | ||
| 2695 | often a good idea to use certain existing faces or inherit from them, | ||
| 2696 | rather than defining entirely new faces. This way, if other users | ||
| 2697 | have customized the basic faces to give Emacs a certain look, your | ||
| 2698 | program will ``fit in'' without additional customization. | ||
| 2699 | |||
| 2700 | Some of the basic faces defined in Emacs are listed below. In | ||
| 2701 | addition to these, you might want to make use of the Font Lock faces | ||
| 2702 | for syntactic highlighting, if highlighting is not already handled by | ||
| 2703 | Font Lock mode, or if some Font Lock faces are not in use. | ||
| 2704 | @xref{Faces for Font Lock}. | ||
| 2705 | |||
| 2706 | @table @code | ||
| 2707 | @item default | ||
| 2708 | The default face, whose attributes are all specified. All other faces | ||
| 2709 | implicitly inherit from it: any unspecified attribute defaults to the | ||
| 2710 | attribute on this face (@pxref{Face Attributes}). | ||
| 2711 | |||
| 2712 | @item bold | ||
| 2713 | @itemx italic | ||
| 2714 | @itemx bold-italic | ||
| 2715 | @itemx underline | ||
| 2716 | @itemx fixed-pitch | ||
| 2717 | @itemx variable-pitch | ||
| 2718 | These have the attributes indicated by their names (e.g. @code{bold} | ||
| 2719 | has a bold @code{:weight} attribute), with all other attributes | ||
| 2720 | unspecified (and so given by @code{default}). | ||
| 2721 | |||
| 2722 | @item shadow | ||
| 2723 | For ``dimmed out'' text. For example, it is used for the ignored | ||
| 2724 | part of a filename in the minibuffer (@pxref{Minibuffer File,, | ||
| 2725 | Minibuffers for File Names, emacs, The GNU Emacs Manual}). | ||
| 2726 | |||
| 2727 | @item link | ||
| 2728 | @itemx link-visited | ||
| 2729 | For clickable text buttons that send the user to a different | ||
| 2730 | buffer or ``location''. | ||
| 2731 | |||
| 2732 | @item highlight | ||
| 2733 | For stretches of text that should temporarily stand out. For example, | ||
| 2734 | it is commonly assigned to the @code{mouse-face} property for cursor | ||
| 2735 | highlighting (@pxref{Special Properties}). | ||
| 2736 | |||
| 2737 | @item match | ||
| 2738 | For text matching a search command. | ||
| 2739 | |||
| 2740 | @item error | ||
| 2741 | @itemx warning | ||
| 2742 | @itemx success | ||
| 2743 | For text concerning errors, warnings, or successes. For example, | ||
| 2744 | these are used for messages in @samp{*Compilation*} buffers. | ||
| 2745 | @end table | ||
| 2746 | |||
| 2684 | @node Font Selection | 2747 | @node Font Selection |
| 2685 | @subsection Font Selection | 2748 | @subsection Font Selection |
| 2686 | 2749 | ||
| @@ -3791,6 +3854,10 @@ with a @dfn{pixel ascent} specification (@pxref{Pixel Specification}). | |||
| 3791 | non-graphic terminals, but the other space properties in this section | 3854 | non-graphic terminals, but the other space properties in this section |
| 3792 | are not. | 3855 | are not. |
| 3793 | 3856 | ||
| 3857 | Note that space properties are treated as paragraph separators for | ||
| 3858 | the purposes of reordering bidirectional text for display. | ||
| 3859 | @xref{Bidirectional Display}, for the details. | ||
| 3860 | |||
| 3794 | @node Pixel Specification | 3861 | @node Pixel Specification |
| 3795 | @subsection Pixel Specification for Spaces | 3862 | @subsection Pixel Specification for Spaces |
| 3796 | @cindex spaces, pixel specification | 3863 | @cindex spaces, pixel specification |
| @@ -5989,6 +6056,7 @@ left-to-right and right-to-left characters. | |||
| 5989 | for editing and displaying bidirectional text. | 6056 | for editing and displaying bidirectional text. |
| 5990 | 6057 | ||
| 5991 | @cindex logical order | 6058 | @cindex logical order |
| 6059 | @cindex reading order | ||
| 5992 | @cindex visual order | 6060 | @cindex visual order |
| 5993 | @cindex unicode bidirectional algorithm | 6061 | @cindex unicode bidirectional algorithm |
| 5994 | Emacs stores right-to-left and bidirectional text in the so-called | 6062 | Emacs stores right-to-left and bidirectional text in the so-called |
| @@ -6003,17 +6071,16 @@ for display. Reordering of bidirectional text for display in Emacs is | |||
| 6003 | a ``Full bidirectionality'' class implementation of the @acronym{UBA}. | 6071 | a ``Full bidirectionality'' class implementation of the @acronym{UBA}. |
| 6004 | 6072 | ||
| 6005 | @defvar bidi-display-reordering | 6073 | @defvar bidi-display-reordering |
| 6006 | The buffer-local variable @code{bidi-display-reordering} controls | 6074 | This buffer-local variable controls whether text in the buffer is |
| 6007 | whether text in the buffer is reordered for display. If its value is | 6075 | reordered for display. If its value is non-@code{nil}, Emacs reorders |
| 6008 | non-@code{nil}, Emacs reorders characters that have right-to-left | 6076 | characters that have right-to-left directionality when they are |
| 6009 | directionality when they are displayed. The default value is | 6077 | displayed. The default value is @code{t}. Text in overlay strings |
| 6010 | @code{t}. Text in overlay strings (@pxref{Overlay | 6078 | (@pxref{Overlay Properties,,before-string}), display strings |
| 6011 | Properties,,before-string}), display strings (@pxref{Overlay | 6079 | (@pxref{Overlay Properties,,display}), and @code{display} text |
| 6012 | Properties,,display}), and @code{display} text properties | 6080 | properties (@pxref{Display Property}) is also reordered for display if |
| 6013 | (@pxref{Display Property}) is also reordered if the buffer whose text | 6081 | the buffer whose text includes these strings is reordered. Turning |
| 6014 | includes these strings is reordered for display. Turning off | 6082 | off @code{bidi-display-reordering} for a buffer turns off reordering |
| 6015 | @code{bidi-display-reordering} for a buffer turns off reordering of | 6083 | of all the overlay and display strings in that buffer. |
| 6016 | all the overlay and display strings in that buffer. | ||
| 6017 | 6084 | ||
| 6018 | Reordering of strings that are unrelated to any buffer, such as text | 6085 | Reordering of strings that are unrelated to any buffer, such as text |
| 6019 | displayed on the mode line (@pxref{Mode Line Format}) or header line | 6086 | displayed on the mode line (@pxref{Mode Line Format}) or header line |
| @@ -6053,7 +6120,7 @@ it is reordered for display. That is, the entire chunk of text | |||
| 6053 | covered by these properties is reordered together. Moreover, the | 6120 | covered by these properties is reordered together. Moreover, the |
| 6054 | bidirectional properties of the characters in this chunk of text are | 6121 | bidirectional properties of the characters in this chunk of text are |
| 6055 | ignored, and Emacs reorders them as if they were replaced with a | 6122 | ignored, and Emacs reorders them as if they were replaced with a |
| 6056 | single character @code{u+FFFC}, known as the @dfn{Object Replacement | 6123 | single character @code{U+FFFC}, known as the @dfn{Object Replacement |
| 6057 | Character}. This means that placing a display property over a portion | 6124 | Character}. This means that placing a display property over a portion |
| 6058 | of text may change the way that the surrounding text is reordered for | 6125 | of text may change the way that the surrounding text is reordered for |
| 6059 | display. To prevent this unexpected effect, always place such | 6126 | display. To prevent this unexpected effect, always place such |
| @@ -6070,9 +6137,9 @@ begins at the right margin and is continued or truncated at the left | |||
| 6070 | margin. | 6137 | margin. |
| 6071 | 6138 | ||
| 6072 | @defvar bidi-paragraph-direction | 6139 | @defvar bidi-paragraph-direction |
| 6073 | Emacs determines the base direction of each paragraph dynamically, | 6140 | By default, Emacs determines the base direction of each paragraph |
| 6074 | based on the text at the beginning of the paragraph. The precise | 6141 | dynamically, based on the text at the beginning of the paragraph. The |
| 6075 | method of determining the base direction is specified by the | 6142 | precise method of determining the base direction is specified by the |
| 6076 | @acronym{UBA}; in a nutshell, the first character in a paragraph that | 6143 | @acronym{UBA}; in a nutshell, the first character in a paragraph that |
| 6077 | has an explicit directionality determines the base direction of the | 6144 | has an explicit directionality determines the base direction of the |
| 6078 | paragraph. However, sometimes a buffer may need to force a certain | 6145 | paragraph. However, sometimes a buffer may need to force a certain |
| @@ -6084,6 +6151,13 @@ dynamic determination of the base direction, and instead forces all | |||
| 6084 | paragraphs in the buffer to have the direction specified by its | 6151 | paragraphs in the buffer to have the direction specified by its |
| 6085 | buffer-local value. The value can be either @code{right-to-left} or | 6152 | buffer-local value. The value can be either @code{right-to-left} or |
| 6086 | @code{left-to-right}. Any other value is interpreted as @code{nil}. | 6153 | @code{left-to-right}. Any other value is interpreted as @code{nil}. |
| 6154 | The default is @code{nil}. | ||
| 6155 | |||
| 6156 | @cindex @code{prog-mode}, and @code{bidi-paragraph-direction} | ||
| 6157 | Modes that are meant to display program source code should force a | ||
| 6158 | @code{left-to-right} paragraph direction. The easiest way of doing so | ||
| 6159 | is to derive the mode from Prog Mode, which already sets | ||
| 6160 | @code{bidi-paragraph-direction} to that value. | ||
| 6087 | @end defvar | 6161 | @end defvar |
| 6088 | 6162 | ||
| 6089 | @defun current-bidi-paragraph-direction &optional buffer | 6163 | @defun current-bidi-paragraph-direction &optional buffer |
| @@ -6094,5 +6168,83 @@ omitted or @code{nil}, it defaults to the current buffer. If the | |||
| 6094 | buffer-local value of the variable @code{bidi-paragraph-direction} is | 6168 | buffer-local value of the variable @code{bidi-paragraph-direction} is |
| 6095 | non-@code{nil}, the returned value will be identical to that value; | 6169 | non-@code{nil}, the returned value will be identical to that value; |
| 6096 | otherwise, the returned value reflects the paragraph direction | 6170 | otherwise, the returned value reflects the paragraph direction |
| 6097 | determined dynamically by Emacs. | 6171 | determined dynamically by Emacs. For buffers whose value of |
| 6098 | @end defun | 6172 | @code{bidi-display-reordering} is @code{nil} as well as unibyte |
| 6173 | buffers, this function always returns @code{left-to-right}. | ||
| 6174 | @end defun | ||
| 6175 | |||
| 6176 | @cindex layout on display, and bidirectional text | ||
| 6177 | @cindex jumbled display of bidirectional text | ||
| 6178 | @cindex concatenating bidirectional strings | ||
| 6179 | Reordering of bidirectional text for display can have surprising and | ||
| 6180 | unpleasant effects when two strings with bidirectional content are | ||
| 6181 | juxtaposed in a buffer, or otherwise programmatically concatenated | ||
| 6182 | into a string of text. A typical example is a buffer whose lines are | ||
| 6183 | actually sequences of items, or fields, separated by whitespace or | ||
| 6184 | punctuation characters. This is used in specialized modes such as | ||
| 6185 | Buffer-menu Mode or various email summary modes, like Rmail Summary | ||
| 6186 | Mode. Because these separator characters are @dfn{weak}, i.e.@: have | ||
| 6187 | no strong directionality, they take on the directionality of | ||
| 6188 | surrounding text. As result, a numeric field that follows a field | ||
| 6189 | with bidirectional content can be displayed @emph{to the left} of the | ||
| 6190 | preceding field, producing a jumbled display and messing up the | ||
| 6191 | expected layout. | ||
| 6192 | |||
| 6193 | To countermand this, we recommend that you use one of the following | ||
| 6194 | techniques for forcing correct order of fields on display: | ||
| 6195 | |||
| 6196 | @itemize @minus | ||
| 6197 | @item | ||
| 6198 | Append the special character @code{U+200E}, LEFT-TO-RIGHT MARK, or | ||
| 6199 | @acronym{LRM}, to the end of each field that may have bidirectional | ||
| 6200 | content, or prepend it to the beginning of the following field. The | ||
| 6201 | function @code{bidi-string-mark-left-to-right}, described below, comes | ||
| 6202 | in handy for this purpose. (In a right-to-left paragraph, use | ||
| 6203 | @code{U+200F}, RIGHT-TO-LEFT MARK, or @acronym{RLM}, instead.) This | ||
| 6204 | is one of the solutions recommended by | ||
| 6205 | @uref{http://www.unicode.org/reports/tr9/#Separators, the | ||
| 6206 | @acronym{UBA}}. | ||
| 6207 | |||
| 6208 | @item | ||
| 6209 | Include the tab character in the field separator. The tab character | ||
| 6210 | plays the role of @dfn{segment separator} in the @acronym{UBA} | ||
| 6211 | reordering, whose effect is to make each field a separate segment, and | ||
| 6212 | thus reorder them separately. | ||
| 6213 | |||
| 6214 | @cindex @code{space} display spec, and bidirectional text | ||
| 6215 | @item | ||
| 6216 | Separate fields with a @code{display} property or overlay with the | ||
| 6217 | property value of the form @code{(space . PROPS)} (@pxref{Specified | ||
| 6218 | Space}). This display specification is treated by Emacs as a | ||
| 6219 | @dfn{paragraph separator}; the text before and after the separator is | ||
| 6220 | reordered separately, which avoids the influence of any field on its | ||
| 6221 | neighboring fields. | ||
| 6222 | @end itemize | ||
| 6223 | |||
| 6224 | @defun bidi-string-mark-left-to-right string | ||
| 6225 | This subroutine returns its argument @var{string}, possibly modified, | ||
| 6226 | such that the result can be safely concatenated with another string, | ||
| 6227 | or juxtaposed with another string in a buffer, without disrupting the | ||
| 6228 | relative layout of this string and the next one on display. If the | ||
| 6229 | string returned by this function is displayed as part of a | ||
| 6230 | left-to-right paragraph, it will always appear on display to the left | ||
| 6231 | of the text that follows it. The function works by examining the | ||
| 6232 | characters of its argument, and if any of those characters could cause | ||
| 6233 | reordering on display, the function appends the @acronym{LRM} | ||
| 6234 | character to the string. The appended @acronym{LRM} character is made | ||
| 6235 | @emph{invisible} (@pxref{Invisible Text}), to hide it on display. | ||
| 6236 | @end defun | ||
| 6237 | |||
| 6238 | The reordering algorithm uses the bidirectional properties of the | ||
| 6239 | characters stored as their @code{bidi-class} property | ||
| 6240 | (@pxref{Character Properties}). Lisp programs can change these | ||
| 6241 | properties by calling the @code{put-char-code-property} function. | ||
| 6242 | However, doing this requires a thorough understanding of the | ||
| 6243 | @acronym{UBA}, and is therefore not recommended. Any changes to the | ||
| 6244 | bidirectional properties of a character have global effect: they | ||
| 6245 | affect all Emacs frames and windows. | ||
| 6246 | |||
| 6247 | Similarly, the @code{mirroring} property is used to display the | ||
| 6248 | appropriate mirrored character in the reordered text. Lisp programs | ||
| 6249 | can affect the mirrored display by changing this property. Again, any | ||
| 6250 | such changes affect all of Emacs display. | ||
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index bb05f1b4a0b..bcf6d3318ef 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi | |||
| @@ -765,8 +765,7 @@ Major and Minor Modes | |||
| 765 | * Major Modes:: Defining major modes. | 765 | * Major Modes:: Defining major modes. |
| 766 | * Minor Modes:: Defining minor modes. | 766 | * Minor Modes:: Defining minor modes. |
| 767 | * Mode Line Format:: Customizing the text that appears in the mode line. | 767 | * Mode Line Format:: Customizing the text that appears in the mode line. |
| 768 | * Imenu:: How a mode can provide a menu | 768 | * Imenu:: Providing a menu of definitions made in a buffer. |
| 769 | of definitions in the buffer. | ||
| 770 | * Font Lock Mode:: How modes can highlight text according to syntax. | 769 | * Font Lock Mode:: How modes can highlight text according to syntax. |
| 771 | * Desktop Save Mode:: How modes can have buffer state saved between | 770 | * Desktop Save Mode:: How modes can have buffer state saved between |
| 772 | Emacs sessions. | 771 | Emacs sessions. |
| @@ -778,12 +777,12 @@ Hooks | |||
| 778 | 777 | ||
| 779 | Major Modes | 778 | Major Modes |
| 780 | 779 | ||
| 781 | * Major Mode Basics:: | ||
| 782 | * Major Mode Conventions:: Coding conventions for keymaps, etc. | 780 | * Major Mode Conventions:: Coding conventions for keymaps, etc. |
| 783 | * Auto Major Mode:: How Emacs chooses the major mode automatically. | 781 | * Auto Major Mode:: How Emacs chooses the major mode automatically. |
| 784 | * Mode Help:: Finding out how to use a mode. | 782 | * Mode Help:: Finding out how to use a mode. |
| 785 | * Derived Modes:: Defining a new major mode based on another major | 783 | * Derived Modes:: Defining a new major mode based on another major |
| 786 | mode. | 784 | mode. |
| 785 | * Basic Major Modes:: Modes that other modes are often derived from. | ||
| 787 | * Generic Modes:: Defining a simple major mode that supports | 786 | * Generic Modes:: Defining a simple major mode that supports |
| 788 | comment syntax and Font Lock mode. | 787 | comment syntax and Font Lock mode. |
| 789 | * Mode Hooks:: Hooks run at the end of major mode functions. | 788 | * Mode Hooks:: Hooks run at the end of major mode functions. |
| @@ -1309,6 +1308,7 @@ Faces | |||
| 1309 | * Face Remapping:: Remapping faces to alternative definitions. | 1308 | * Face Remapping:: Remapping faces to alternative definitions. |
| 1310 | * Face Functions:: How to define and examine faces. | 1309 | * Face Functions:: How to define and examine faces. |
| 1311 | * Auto Faces:: Hook for automatic face assignment. | 1310 | * Auto Faces:: Hook for automatic face assignment. |
| 1311 | * Basic Faces:: Faces that are defined by default. | ||
| 1312 | * Font Selection:: Finding the best available font for a face. | 1312 | * Font Selection:: Finding the best available font for a face. |
| 1313 | * Font Lookup:: Looking up the names of available fonts | 1313 | * Font Lookup:: Looking up the names of available fonts |
| 1314 | and information about them. | 1314 | and information about them. |
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 4d992bd2c51..bd904bf49c0 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -203,17 +203,6 @@ When this command is called interactively, it prompts for | |||
| 203 | @var{filename}. | 203 | @var{filename}. |
| 204 | @end deffn | 204 | @end deffn |
| 205 | 205 | ||
| 206 | @deffn Command view-file filename | ||
| 207 | This command visits @var{filename} using View mode, returning to the | ||
| 208 | previous buffer when you exit View mode. View mode is a minor mode that | ||
| 209 | provides commands to skim rapidly through the file, but does not let you | ||
| 210 | modify the text. Entering View mode runs the normal hook | ||
| 211 | @code{view-mode-hook}. @xref{Hooks}. | ||
| 212 | |||
| 213 | When @code{view-file} is called interactively, it prompts for | ||
| 214 | @var{filename}. | ||
| 215 | @end deffn | ||
| 216 | |||
| 217 | @defopt find-file-wildcards | 206 | @defopt find-file-wildcards |
| 218 | If this variable is non-@code{nil}, then the various @code{find-file} | 207 | If this variable is non-@code{nil}, then the various @code{find-file} |
| 219 | commands check for wildcard characters and visit all the files that | 208 | commands check for wildcard characters and visit all the files that |
| @@ -1529,19 +1518,26 @@ This function is not available on systems that don't support symbolic | |||
| 1529 | links. | 1518 | links. |
| 1530 | @end deffn | 1519 | @end deffn |
| 1531 | 1520 | ||
| 1532 | @deffn Command delete-file filename | 1521 | @cindex trash |
| 1522 | @vindex delete-by-moving-to-trash | ||
| 1523 | @deffn Command delete-file filename &optional trash | ||
| 1533 | @pindex rm | 1524 | @pindex rm |
| 1534 | This command deletes the file @var{filename}, like the shell command | 1525 | This command deletes the file @var{filename}. If the file has |
| 1535 | @samp{rm @var{filename}}. If the file has multiple names, it continues | 1526 | multiple names, it continues to exist under the other names. If |
| 1536 | to exist under the other names. | 1527 | @var{filename} is a symbolic link, @code{delete-file} deletes only the |
| 1537 | 1528 | symbolic link and not its target (though it does follow symbolic links | |
| 1538 | A suitable kind of @code{file-error} error is signaled if the file does | 1529 | at all levels of parent directories). |
| 1539 | not exist, or is not deletable. (On Unix and GNU/Linux, a file is | 1530 | |
| 1540 | deletable if its directory is writable.) | 1531 | A suitable kind of @code{file-error} error is signaled if the file |
| 1541 | 1532 | does not exist, or is not deletable. (On Unix and GNU/Linux, a file | |
| 1542 | If @var{filename} is a symbolic link, @code{delete-file} does not | 1533 | is deletable if its directory is writable.) |
| 1543 | replace it with its target, but it does follow symbolic links at all | 1534 | |
| 1544 | levels of parent directories. | 1535 | If the optional argument @var{trash} is non-@code{nil} and the |
| 1536 | variable @code{delete-by-moving-to-trash} is non-@code{nil}, this | ||
| 1537 | command moves the file into the system Trash instead of deleting it. | ||
| 1538 | @xref{Misc File Ops,,Miscellaneous File Operations, emacs, The GNU | ||
| 1539 | Emacs Manual}. When called interactively, @var{trash} is @code{t} if | ||
| 1540 | no prefix argument is given, and @code{nil} otherwise. | ||
| 1545 | 1541 | ||
| 1546 | See also @code{delete-directory} in @ref{Create/Delete Dirs}. | 1542 | See also @code{delete-directory} in @ref{Create/Delete Dirs}. |
| 1547 | @end deffn | 1543 | @end deffn |
| @@ -2507,7 +2503,7 @@ if they don't already exist. | |||
| 2507 | @code{mkdir} is an alias for this. | 2503 | @code{mkdir} is an alias for this. |
| 2508 | @end deffn | 2504 | @end deffn |
| 2509 | 2505 | ||
| 2510 | @deffn Command copy-directory dirname newname &optional keep-time parents | 2506 | @deffn Command copy-directory dirname newname &optional keep-time parents copy-contents |
| 2511 | This command copies the directory named @var{dirname} to | 2507 | This command copies the directory named @var{dirname} to |
| 2512 | @var{newname}. If @var{newname} names an existing directory, | 2508 | @var{newname}. If @var{newname} names an existing directory, |
| 2513 | @var{dirname} will be copied to a subdirectory there. | 2509 | @var{dirname} will be copied to a subdirectory there. |
| @@ -2515,16 +2511,23 @@ This command copies the directory named @var{dirname} to | |||
| 2515 | It always sets the file modes of the copied files to match the | 2511 | It always sets the file modes of the copied files to match the |
| 2516 | corresponding original file. | 2512 | corresponding original file. |
| 2517 | 2513 | ||
| 2518 | The third arg @var{keep-time} non-@code{nil} means to preserve the | 2514 | The third argument @var{keep-time} non-@code{nil} means to preserve the |
| 2519 | modification time of the copied files. A prefix arg makes | 2515 | modification time of the copied files. A prefix arg makes |
| 2520 | @var{keep-time} non-@code{nil}. | 2516 | @var{keep-time} non-@code{nil}. |
| 2521 | 2517 | ||
| 2522 | Noninteractively, the last argument @var{parents} says whether to | 2518 | The fourth argument @var{parents} says whether to |
| 2523 | create parent directories if they don't exist. Interactively, | 2519 | create parent directories if they don't exist. Interactively, |
| 2524 | this happens by default. | 2520 | this happens by default. |
| 2521 | |||
| 2522 | The fifth argument @var{copy-contents}, if non-@code{nil}, means to | ||
| 2523 | copy the contents of @var{dirname} directly into @var{newname} if the | ||
| 2524 | latter is an existing directory, instead of copying @var{dirname} into | ||
| 2525 | it as a subdirectory. | ||
| 2525 | @end deffn | 2526 | @end deffn |
| 2526 | 2527 | ||
| 2527 | @deffn Command delete-directory dirname &optional recursive | 2528 | @cindex trash |
| 2529 | @vindex delete-by-moving-to-trash | ||
| 2530 | @deffn Command delete-directory dirname &optional recursive trash | ||
| 2528 | This command deletes the directory named @var{dirname}. The function | 2531 | This command deletes the directory named @var{dirname}. The function |
| 2529 | @code{delete-file} does not work for files that are directories; you | 2532 | @code{delete-file} does not work for files that are directories; you |
| 2530 | must use @code{delete-directory} for them. If @var{recursive} is | 2533 | must use @code{delete-directory} for them. If @var{recursive} is |
| @@ -2533,6 +2536,13 @@ must use @code{delete-directory} for them. If @var{recursive} is | |||
| 2533 | 2536 | ||
| 2534 | @code{delete-directory} only follows symbolic links at the level of | 2537 | @code{delete-directory} only follows symbolic links at the level of |
| 2535 | parent directories. | 2538 | parent directories. |
| 2539 | |||
| 2540 | If the optional argument @var{trash} is non-@code{nil} and the | ||
| 2541 | variable @code{delete-by-moving-to-trash} is non-@code{nil}, this | ||
| 2542 | command moves the file into the system Trash instead of deleting it. | ||
| 2543 | @xref{Misc File Ops,,Miscellaneous File Operations, emacs, The GNU | ||
| 2544 | Emacs Manual}. When called interactively, @var{trash} is @code{t} if | ||
| 2545 | no prefix argument is given, and @code{nil} otherwise. | ||
| 2536 | @end deffn | 2546 | @end deffn |
| 2537 | 2547 | ||
| 2538 | @node Magic File Names | 2548 | @node Magic File Names |
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index b6012a4dd53..e799cfa6b7f 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi | |||
| @@ -695,20 +695,19 @@ right fringe. However, you can force one fringe or the other to a | |||
| 695 | precise width by specifying that width as a negative integer. If both | 695 | precise width by specifying that width as a negative integer. If both |
| 696 | widths are negative, only the left fringe gets the specified width. | 696 | widths are negative, only the left fringe gets the specified width. |
| 697 | 697 | ||
| 698 | @vindex menu-bar-lines, a frame parameter | 698 | @vindex menu-bar-lines frame parameter |
| 699 | @item menu-bar-lines | 699 | @item menu-bar-lines |
| 700 | The number of lines to allocate at the top of the frame for a menu | 700 | The number of lines to allocate at the top of the frame for a menu |
| 701 | bar. The default is 1. A value of @code{nil} means don't display a | 701 | bar. The default is 1 if Menu Bar mode is enabled, and 0 otherwise. |
| 702 | menu bar. @xref{Menu Bar}. (The X toolkit and GTK allow at most one | 702 | @xref{Menu Bars,,,emacs, The GNU Emacs Manual}. |
| 703 | menu bar line; they treat larger values as 1.) | ||
| 704 | 703 | ||
| 705 | @vindex tool-bar-lines, a frame parameter | 704 | @vindex tool-bar-lines frame parameter |
| 706 | @item tool-bar-lines | 705 | @item tool-bar-lines |
| 707 | The number of lines to use for the tool bar. A value of @code{nil} | 706 | The number of lines to use for the tool bar. The default is 1 if Tool |
| 708 | means don't display a tool bar. (GTK and Nextstep allow at most one | 707 | Bar mode is enabled, and 0 otherwise. @xref{Tool Bars,,,emacs, The |
| 709 | tool bar line; they treat larger values as 1.) | 708 | GNU Emacs Manual}. |
| 710 | 709 | ||
| 711 | @vindex tool-bar-position, a frame parameter | 710 | @vindex tool-bar-position frame parameter |
| 712 | @item tool-bar-position | 711 | @item tool-bar-position |
| 713 | The position of the tool bar. Currently only for the GTK tool bar. | 712 | The position of the tool bar. Currently only for the GTK tool bar. |
| 714 | Value can be one of @code{top}, @code{bottom} @code{left}, @code{right}. | 713 | Value can be one of @code{top}, @code{bottom} @code{left}, @code{right}. |
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi index 064be89632f..7a530b602e0 100644 --- a/doc/lispref/lists.texi +++ b/doc/lispref/lists.texi | |||
| @@ -462,7 +462,7 @@ element is @var{object}. Compare @code{make-list} with | |||
| 462 | @result{} nil | 462 | @result{} nil |
| 463 | @end group | 463 | @end group |
| 464 | @group | 464 | @group |
| 465 | (setq l (make-list 3 '(a b)) | 465 | (setq l (make-list 3 '(a b))) |
| 466 | @result{} ((a b) (a b) (a b)) | 466 | @result{} ((a b) (a b) (a b)) |
| 467 | (eq (car l) (cadr l)) | 467 | (eq (car l) (cadr l)) |
| 468 | @result{} t | 468 | @result{} t |
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index dd3b2e3038f..eb81ebc4acb 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi | |||
| @@ -19,16 +19,15 @@ user. For related topics such as keymaps and syntax tables, see | |||
| 19 | @ref{Keymaps}, and @ref{Syntax Tables}. | 19 | @ref{Keymaps}, and @ref{Syntax Tables}. |
| 20 | 20 | ||
| 21 | @menu | 21 | @menu |
| 22 | * Hooks:: How to use hooks; how to write code that provides hooks. | 22 | * Hooks:: How to use hooks; how to write code that provides hooks. |
| 23 | * Major Modes:: Defining major modes. | 23 | * Major Modes:: Defining major modes. |
| 24 | * Minor Modes:: Defining minor modes. | 24 | * Minor Modes:: Defining minor modes. |
| 25 | * Mode Line Format:: Customizing the text that appears in the mode line. | 25 | * Mode Line Format:: Customizing the text that appears in the mode line. |
| 26 | * Imenu:: How a mode can provide a menu | 26 | * Imenu:: Providing a menu of definitions made in a buffer. |
| 27 | of definitions in the buffer. | 27 | * Font Lock Mode:: How modes can highlight text according to syntax. |
| 28 | * Font Lock Mode:: How modes can highlight text according to syntax. | 28 | * Auto-Indentation:: How to teach Emacs to indent for a major mode. |
| 29 | * Auto-Indentation:: How to teach Emacs to indent for a major mode. | 29 | * Desktop Save Mode:: How modes can have buffer state saved between |
| 30 | * Desktop Save Mode:: How modes can have buffer state saved between | 30 | Emacs sessions. |
| 31 | Emacs sessions. | ||
| 32 | @end menu | 31 | @end menu |
| 33 | 32 | ||
| 34 | @node Hooks | 33 | @node Hooks |
| @@ -48,12 +47,12 @@ convention, whenever the hook name ends in @samp{-hook}, that tells | |||
| 48 | you it is normal. We try to make all hooks normal, as much as | 47 | you it is normal. We try to make all hooks normal, as much as |
| 49 | possible, so that you can use them in a uniform way. | 48 | possible, so that you can use them in a uniform way. |
| 50 | 49 | ||
| 51 | Every major mode function is supposed to run a normal hook called | 50 | Every major mode command is supposed to run a normal hook called the |
| 52 | the @dfn{mode hook} as the one of the last steps of initialization. | 51 | @dfn{mode hook} as the one of the last steps of initialization. This |
| 53 | This makes it easy for a user to customize the behavior of the mode, | 52 | makes it easy for a user to customize the behavior of the mode, by |
| 54 | by overriding the buffer-local variable assignments already made by | 53 | overriding the buffer-local variable assignments already made by the |
| 55 | the mode. Most minor mode functions also run a mode hook at the end. | 54 | mode. Most minor mode functions also run a mode hook at the end. But |
| 56 | But hooks are used in other contexts too. For example, the hook | 55 | hooks are used in other contexts too. For example, the hook |
| 57 | @code{suspend-hook} runs just before Emacs suspends itself | 56 | @code{suspend-hook} runs just before Emacs suspends itself |
| 58 | (@pxref{Suspending Emacs}). | 57 | (@pxref{Suspending Emacs}). |
| 59 | 58 | ||
| @@ -78,8 +77,8 @@ convention. | |||
| 78 | its value is just a single function, not a list of functions. | 77 | its value is just a single function, not a list of functions. |
| 79 | 78 | ||
| 80 | @menu | 79 | @menu |
| 81 | * Running Hooks:: How to run a hook. | 80 | * Running Hooks:: How to run a hook. |
| 82 | * Setting Hooks:: How to put functions on a hook, or remove them. | 81 | * Setting Hooks:: How to put functions on a hook, or remove them. |
| 83 | @end menu | 82 | @end menu |
| 84 | 83 | ||
| 85 | @node Running Hooks | 84 | @node Running Hooks |
| @@ -195,115 +194,98 @@ from the buffer-local hook list instead of from the global hook list. | |||
| 195 | @section Major Modes | 194 | @section Major Modes |
| 196 | @cindex major mode | 195 | @cindex major mode |
| 197 | 196 | ||
| 197 | @cindex major mode command | ||
| 198 | Major modes specialize Emacs for editing particular kinds of text. | 198 | Major modes specialize Emacs for editing particular kinds of text. |
| 199 | Each buffer has only one major mode at a time. For each major mode | 199 | Each buffer has one major mode at a time. Every major mode is |
| 200 | there is a function to switch to that mode in the current buffer; its | 200 | associated with a @dfn{major mode command}, whose name should end in |
| 201 | name should end in @samp{-mode}. These functions work by setting | 201 | @samp{-mode}. This command takes care of switching to that mode in the |
| 202 | buffer-local variable bindings and other data associated with the | 202 | current buffer, by setting various buffer-local variables such as a |
| 203 | buffer, such as a local keymap. The effect lasts until you switch | 203 | local keymap. @xref{Major Mode Conventions}. |
| 204 | to another major mode in the same buffer. | 204 | |
| 205 | The least specialized major mode is called @dfn{Fundamental mode}, | ||
| 206 | which has no mode-specific definitions or variable settings. | ||
| 207 | |||
| 208 | @deffn Command fundamental-mode | ||
| 209 | This is the major mode command for Fundamental mode. Unlike other mode | ||
| 210 | commands, it does @emph{not} run any mode hooks (@pxref{Major Mode | ||
| 211 | Conventions}), since you are not supposed to customize this mode. | ||
| 212 | @end deffn | ||
| 213 | |||
| 214 | The easiest way to write a major mode is to use the macro | ||
| 215 | @code{define-derived-mode}, which sets up the new mode as a variant of | ||
| 216 | an existing major mode. @xref{Derived Modes}. We recommend using | ||
| 217 | @code{define-derived-mode} even if the new mode is not an obvious | ||
| 218 | derivative of another mode, as it automatically enforces many coding | ||
| 219 | conventions for you. @xref{Basic Major Modes}, for common modes to | ||
| 220 | derive from. | ||
| 221 | |||
| 222 | The standard GNU Emacs Lisp directory tree contains the code for | ||
| 223 | several major modes, in files such as @file{text-mode.el}, | ||
| 224 | @file{texinfo.el}, @file{lisp-mode.el}, and @file{rmail.el}. You can | ||
| 225 | study these libraries to see how modes are written. | ||
| 226 | |||
| 227 | @defopt major-mode | ||
| 228 | The buffer-local value of this variable holds the symbol for the current | ||
| 229 | major mode. Its default value holds the default major mode for new | ||
| 230 | buffers. The standard default value is @code{fundamental-mode}. | ||
| 231 | |||
| 232 | If the default value is @code{nil}, then whenever Emacs creates a new | ||
| 233 | buffer via a command such as @kbd{C-x b} (@code{switch-to-buffer}), the | ||
| 234 | new buffer is put in the major mode of the previously current buffer. | ||
| 235 | As an exception, if the major mode of the previous buffer has a | ||
| 236 | @code{mode-class} symbol property with value @code{special}, the new | ||
| 237 | buffer is put in Fundamental mode (@pxref{Major Mode Conventions}). | ||
| 238 | @end defopt | ||
| 205 | 239 | ||
| 206 | @menu | 240 | @menu |
| 207 | * Major Mode Basics:: | 241 | * Major Mode Conventions:: Coding conventions for keymaps, etc. |
| 208 | * Major Mode Conventions:: Coding conventions for keymaps, etc. | 242 | * Auto Major Mode:: How Emacs chooses the major mode automatically. |
| 209 | * Auto Major Mode:: How Emacs chooses the major mode automatically. | 243 | * Mode Help:: Finding out how to use a mode. |
| 210 | * Mode Help:: Finding out how to use a mode. | 244 | * Derived Modes:: Defining a new major mode based on another major |
| 211 | * Derived Modes:: Defining a new major mode based on another major | ||
| 212 | mode. | 245 | mode. |
| 213 | * Generic Modes:: Defining a simple major mode that supports | 246 | * Basic Major Modes:: Modes that other modes are often derived from. |
| 247 | * Generic Modes:: Defining a simple major mode that supports | ||
| 214 | comment syntax and Font Lock mode. | 248 | comment syntax and Font Lock mode. |
| 215 | * Mode Hooks:: Hooks run at the end of major mode functions. | 249 | * Mode Hooks:: Hooks run at the end of major mode commands. |
| 216 | * Example Major Modes:: Text mode and Lisp modes. | 250 | * Example Major Modes:: Text mode and Lisp modes. |
| 217 | @end menu | 251 | @end menu |
| 218 | 252 | ||
| 219 | @node Major Mode Basics | ||
| 220 | @subsection Major Mode Basics | ||
| 221 | @cindex Fundamental mode | ||
| 222 | |||
| 223 | The least specialized major mode is called @dfn{Fundamental mode}. | ||
| 224 | This mode has no mode-specific definitions or variable settings, so each | ||
| 225 | Emacs command behaves in its default manner, and each option is in its | ||
| 226 | default state. All other major modes redefine various keys and options. | ||
| 227 | For example, Lisp Interaction mode provides special key bindings for | ||
| 228 | @kbd{C-j} (@code{eval-print-last-sexp}), @key{TAB} | ||
| 229 | (@code{lisp-indent-line}), and other keys. | ||
| 230 | |||
| 231 | When you need to write several editing commands to help you perform a | ||
| 232 | specialized editing task, creating a new major mode is usually a good | ||
| 233 | idea. In practice, writing a major mode is easy (in contrast to | ||
| 234 | writing a minor mode, which is often difficult). | ||
| 235 | |||
| 236 | If the new mode is similar to an old one, it is often unwise to | ||
| 237 | modify the old one to serve two purposes, since it may become harder | ||
| 238 | to use and maintain. Instead, copy and rename an existing major mode | ||
| 239 | definition and alter the copy---or use the @code{define-derived-mode} | ||
| 240 | macro to define a @dfn{derived mode} (@pxref{Derived Modes}). For | ||
| 241 | example, Rmail Edit mode is a major mode that is very similar to Text | ||
| 242 | mode except that it provides two additional commands. Its definition | ||
| 243 | is distinct from that of Text mode, but uses that of Text mode. | ||
| 244 | |||
| 245 | Even if the new mode is not an obvious derivative of any other mode, | ||
| 246 | we recommend to use @code{define-derived-mode}, since it automatically | ||
| 247 | enforces the most important coding conventions for you. | ||
| 248 | |||
| 249 | For a very simple programming language major mode that handles | ||
| 250 | comments and fontification, you can use @code{define-generic-mode}. | ||
| 251 | @xref{Generic Modes}. | ||
| 252 | |||
| 253 | Rmail Edit mode offers an example of changing the major mode | ||
| 254 | temporarily for a buffer, so it can be edited in a different way (with | ||
| 255 | ordinary Emacs commands rather than Rmail commands). In such cases, the | ||
| 256 | temporary major mode usually provides a command to switch back to the | ||
| 257 | buffer's usual mode (Rmail mode, in this case). You might be tempted to | ||
| 258 | present the temporary redefinitions inside a recursive edit and restore | ||
| 259 | the usual ones when the user exits; but this is a bad idea because it | ||
| 260 | constrains the user's options when it is done in more than one buffer: | ||
| 261 | recursive edits must be exited most-recently-entered first. Using an | ||
| 262 | alternative major mode avoids this limitation. @xref{Recursive | ||
| 263 | Editing}. | ||
| 264 | |||
| 265 | The standard GNU Emacs Lisp library directory tree contains the code | ||
| 266 | for several major modes, in files such as @file{text-mode.el}, | ||
| 267 | @file{texinfo.el}, @file{lisp-mode.el}, @file{c-mode.el}, and | ||
| 268 | @file{rmail.el}. They are found in various subdirectories of the | ||
| 269 | @file{lisp} directory. You can study these libraries to see how modes | ||
| 270 | are written. Text mode is perhaps the simplest major mode aside from | ||
| 271 | Fundamental mode. Rmail mode is a complicated and specialized mode. | ||
| 272 | |||
| 273 | @node Major Mode Conventions | 253 | @node Major Mode Conventions |
| 274 | @subsection Major Mode Conventions | 254 | @subsection Major Mode Conventions |
| 275 | @cindex major mode conventions | 255 | @cindex major mode conventions |
| 276 | @cindex conventions for writing major modes | 256 | @cindex conventions for writing major modes |
| 277 | 257 | ||
| 278 | The code for existing major modes follows various coding conventions, | 258 | The code for every major mode should follow various coding |
| 279 | including conventions for local keymap and syntax table initialization, | 259 | conventions, including conventions for local keymap and syntax table |
| 280 | global names, and hooks. Please follow these conventions when you | 260 | initialization, function and variable names, and hooks. |
| 281 | define a new major mode. (Fundamental mode is an exception to many | 261 | |
| 282 | of these conventions, because its definition is to present the global | 262 | If you use the @code{define-derived-mode} macro, it will take care of |
| 283 | state of Emacs.) | 263 | many of these conventions automatically. @xref{Derived Modes}. Note |
| 264 | also that fundamental mode is an exception to many of these conventions, | ||
| 265 | because its definition is to present the global state of Emacs. | ||
| 284 | 266 | ||
| 285 | This list of conventions is only partial, because each major mode | 267 | The following list of conventions is only partial. Each major mode |
| 286 | should aim for consistency in general with other Emacs major modes. | 268 | should aim for consistency in general with other Emacs major modes, as |
| 287 | This makes Emacs as a whole more coherent. It is impossible to list | 269 | this makes Emacs as a whole more coherent. It is impossible to list |
| 288 | here all the possible points where this issue might come up; if the | 270 | here all the possible points where this issue might come up; if the |
| 289 | Emacs developers point out an area where your major mode deviates from | 271 | Emacs developers point out an area where your major mode deviates from |
| 290 | the usual conventions, please make it compatible. | 272 | the usual conventions, please make it compatible. |
| 291 | 273 | ||
| 292 | @itemize @bullet | 274 | @itemize @bullet |
| 293 | @item | 275 | @item |
| 294 | Define a command whose name ends in @samp{-mode}, with no arguments, | 276 | Define a major mode command whose name ends in @samp{-mode}. When |
| 295 | that switches to the new mode in the current buffer. This command | 277 | called with no arguments, this command should switch to the new mode in |
| 296 | should set up the keymap, syntax table, and buffer-local variables in an | 278 | the current buffer by setting up the keymap, syntax table, and |
| 297 | existing buffer, without changing the buffer's contents. | 279 | buffer-local variables in an existing buffer. It should not change the |
| 280 | buffer's contents. | ||
| 298 | 281 | ||
| 299 | @item | 282 | @item |
| 300 | Write a documentation string for this command that describes the | 283 | Write a documentation string for this command that describes the special |
| 301 | special commands available in this mode. @kbd{C-h m} | 284 | commands available in this mode. @xref{Mode Help}. |
| 302 | (@code{describe-mode}) in your mode will display this string. | ||
| 303 | 285 | ||
| 304 | The documentation string may include the special documentation | 286 | The documentation string may include the special documentation |
| 305 | substrings, @samp{\[@var{command}]}, @samp{\@{@var{keymap}@}}, and | 287 | substrings, @samp{\[@var{command}]}, @samp{\@{@var{keymap}@}}, and |
| 306 | @samp{\<@var{keymap}>}, which enable the documentation to adapt | 288 | @samp{\<@var{keymap}>}, which allow the help display to adapt |
| 307 | automatically to the user's own key bindings. @xref{Keys in | 289 | automatically to the user's own key bindings. @xref{Keys in |
| 308 | Documentation}. | 290 | Documentation}. |
| 309 | 291 | ||
| @@ -421,28 +403,7 @@ setting up a buffer-local value for the variable | |||
| 421 | 403 | ||
| 422 | @item | 404 | @item |
| 423 | Each face that the mode defines should, if possible, inherit from an | 405 | Each face that the mode defines should, if possible, inherit from an |
| 424 | existing Emacs face. This reduces the chance of conflicting with a | 406 | existing Emacs face. @xref{Basic Faces}, and @ref{Faces for Font Lock}. |
| 425 | user's face customizations. Useful faces include: | ||
| 426 | |||
| 427 | @table @asis | ||
| 428 | @item @code{highlight} | ||
| 429 | for stretches of text that should temporarily stand out. | ||
| 430 | |||
| 431 | @item @code{match} | ||
| 432 | for text matching a search command. | ||
| 433 | |||
| 434 | @item @code{link} and @code{link-visited} | ||
| 435 | for clickable text buttons that send the user to a different buffer or | ||
| 436 | ``location''. | ||
| 437 | |||
| 438 | @item @code{button} | ||
| 439 | for clickable text buttons that perform other actions. | ||
| 440 | |||
| 441 | @item @asis{Font Lock faces} | ||
| 442 | for other kinds of syntactic highlighting, if highlighting is not | ||
| 443 | handled by Font Lock mode or some Font Lock faces are not in use. | ||
| 444 | @xref{Faces for Font Lock}, for how to assign Font Lock faces. | ||
| 445 | @end table | ||
| 446 | 407 | ||
| 447 | @item | 408 | @item |
| 448 | The mode should specify how Imenu should find the definitions or | 409 | The mode should specify how Imenu should find the definitions or |
| @@ -505,27 +466,31 @@ this mode to any other major mode, this mode can set up a buffer-local | |||
| 505 | value for @code{change-major-mode-hook} (@pxref{Creating Buffer-Local}). | 466 | value for @code{change-major-mode-hook} (@pxref{Creating Buffer-Local}). |
| 506 | 467 | ||
| 507 | @item | 468 | @item |
| 508 | If this mode is appropriate only for specially-prepared text, then the | 469 | If this mode is appropriate only for specially-prepared text produced by |
| 509 | major mode command symbol should have a property named @code{mode-class} | 470 | the mode itself (rather than by the user typing at the keyboard or by an |
| 510 | with value @code{special}, put on as follows: | 471 | external file), then the major mode command symbol should have a |
| 472 | property named @code{mode-class} with value @code{special}, put on as | ||
| 473 | follows: | ||
| 511 | 474 | ||
| 512 | @kindex mode-class @r{(property)} | 475 | @kindex mode-class @r{(property)} |
| 513 | @cindex @code{special} | 476 | @cindex @code{special} modes |
| 514 | @example | 477 | @example |
| 515 | (put 'funny-mode 'mode-class 'special) | 478 | (put 'funny-mode 'mode-class 'special) |
| 516 | @end example | 479 | @end example |
| 517 | 480 | ||
| 518 | @noindent | 481 | @noindent |
| 519 | This tells Emacs that new buffers created while the current buffer is | 482 | This tells Emacs that new buffers created while the current buffer is in |
| 520 | in Funny mode should not inherit Funny mode, in case the default value | 483 | Funny mode should not be put in Funny mode, even though the default |
| 521 | of @code{major-mode} is @code{nil}. Modes such as Dired, Rmail, | 484 | value of @code{major-mode} is @code{nil}. By default, the value of |
| 522 | and Buffer List use this feature. | 485 | @code{nil} for @code{major-mode} means to use the current buffer's major |
| 486 | mode when creating new buffers (@pxref{Auto Major Mode}), but with such | ||
| 487 | @code{special} modes, Fundamental mode is used instead. Modes such as | ||
| 488 | Dired, Rmail, and Buffer List use this feature. | ||
| 523 | 489 | ||
| 524 | The @code{define-derived-mode} macro automatically marks the derived | 490 | The @code{define-derived-mode} macro automatically marks the derived |
| 525 | mode as special if the parent mode is special. The special mode | 491 | mode as special if the parent mode is special. Special mode is a |
| 526 | @code{special-mode} provides a convenient parent for other special | 492 | convenient parent for such modes to inherit from; @xref{Basic Major |
| 527 | modes to inherit from; it sets @code{buffer-read-only} to @code{t}, | 493 | Modes}. |
| 528 | and does little else. | ||
| 529 | 494 | ||
| 530 | @item | 495 | @item |
| 531 | If you want to make the new mode the default for files with certain | 496 | If you want to make the new mode the default for files with certain |
| @@ -559,16 +524,6 @@ Even if you never load the file more than once, someone else will. | |||
| 559 | automatically selects a major mode for the new buffer when a file is | 524 | automatically selects a major mode for the new buffer when a file is |
| 560 | visited. It also processes local variables specified in the file text. | 525 | visited. It also processes local variables specified in the file text. |
| 561 | 526 | ||
| 562 | @deffn Command fundamental-mode | ||
| 563 | Fundamental mode is a major mode that is not specialized for anything | ||
| 564 | in particular. Other major modes are defined in effect by comparison | ||
| 565 | with this one---their definitions say what to change, starting from | ||
| 566 | Fundamental mode. The @code{fundamental-mode} function does @emph{not} | ||
| 567 | run any mode hooks; you're not supposed to customize it. (If you want Emacs | ||
| 568 | to behave differently in Fundamental mode, change the @emph{global} | ||
| 569 | state of Emacs.) | ||
| 570 | @end deffn | ||
| 571 | |||
| 572 | @deffn Command normal-mode &optional find-file | 527 | @deffn Command normal-mode &optional find-file |
| 573 | This function establishes the proper major mode and buffer-local variable | 528 | This function establishes the proper major mode and buffer-local variable |
| 574 | bindings for the current buffer. First it calls @code{set-auto-mode} | 529 | bindings for the current buffer. First it calls @code{set-auto-mode} |
| @@ -594,23 +549,22 @@ by the default value of @code{major-mode} (see below). | |||
| 594 | 549 | ||
| 595 | @cindex file mode specification error | 550 | @cindex file mode specification error |
| 596 | @code{normal-mode} uses @code{condition-case} around the call to the | 551 | @code{normal-mode} uses @code{condition-case} around the call to the |
| 597 | major mode function, so errors are caught and reported as a @samp{File | 552 | major mode command, so errors are caught and reported as a @samp{File |
| 598 | mode specification error}, followed by the original error message. | 553 | mode specification error}, followed by the original error message. |
| 599 | @end deffn | 554 | @end deffn |
| 600 | 555 | ||
| 601 | @defun set-auto-mode &optional keep-mode-if-same | 556 | @defun set-auto-mode &optional keep-mode-if-same |
| 602 | @cindex visited file mode | 557 | @cindex visited file mode |
| 603 | This function selects the major mode that is appropriate for the | 558 | This function selects the major mode that is appropriate for the |
| 604 | current buffer. It bases its decision (in order of precedence) on | 559 | current buffer. It bases its decision (in order of precedence) on the |
| 605 | the @w{@samp{-*-}} line, on any @samp{mode:} local variable near the | 560 | @w{@samp{-*-}} line, on any @samp{mode:} local variable near the end of |
| 606 | end of a file, on the @w{@samp{#!}} line (using | 561 | a file, on the @w{@samp{#!}} line (using @code{interpreter-mode-alist}), |
| 607 | @code{interpreter-mode-alist}), on the text at the beginning of the | 562 | on the text at the beginning of the buffer (using |
| 608 | buffer (using @code{magic-mode-alist}), and finally on the visited | 563 | @code{magic-mode-alist}), and finally on the visited file name (using |
| 609 | file name (using @code{auto-mode-alist}). @xref{Choosing Modes, , How | 564 | @code{auto-mode-alist}). @xref{Choosing Modes, , How Major Modes are |
| 610 | Major Modes are Chosen, emacs, The GNU Emacs Manual}. | 565 | Chosen, emacs, The GNU Emacs Manual}. If @code{enable-local-variables} |
| 611 | If @code{enable-local-variables} is @code{nil}, @code{set-auto-mode} | 566 | is @code{nil}, @code{set-auto-mode} does not check the @w{@samp{-*-}} |
| 612 | does not check the @w{@samp{-*-}} line, or near the end of the file, | 567 | line, or near the end of the file, for any mode tag. |
| 613 | for any mode tag. | ||
| 614 | 568 | ||
| 615 | If @var{keep-mode-if-same} is non-@code{nil}, this function does not | 569 | If @var{keep-mode-if-same} is non-@code{nil}, this function does not |
| 616 | call the mode command if the buffer is already in the proper major | 570 | call the mode command if the buffer is already in the proper major |
| @@ -619,21 +573,6 @@ mode. For instance, @code{set-visited-file-name} sets this to | |||
| 619 | have set. | 573 | have set. |
| 620 | @end defun | 574 | @end defun |
| 621 | 575 | ||
| 622 | @defopt major-mode | ||
| 623 | The buffer-local value of this variable holds the major mode | ||
| 624 | currently active. The default value of this variable holds the | ||
| 625 | default major mode for new buffers. The standard default value is | ||
| 626 | @code{fundamental-mode}. | ||
| 627 | |||
| 628 | If the default value of @code{major-mode} is @code{nil}, Emacs uses | ||
| 629 | the (previously) current buffer's major mode as the default major mode | ||
| 630 | of a new buffer. However, if that major mode symbol has a @code{mode-class} | ||
| 631 | property with value @code{special}, then it is not used for new buffers; | ||
| 632 | Fundamental mode is used instead. The modes that have this property are | ||
| 633 | those such as Dired and Rmail that are useful only with text that has | ||
| 634 | been specially prepared. | ||
| 635 | @end defopt | ||
| 636 | |||
| 637 | @defun set-buffer-major-mode buffer | 576 | @defun set-buffer-major-mode buffer |
| 638 | This function sets the major mode of @var{buffer} to the default value of | 577 | This function sets the major mode of @var{buffer} to the default value of |
| 639 | @code{major-mode}; if that is @code{nil}, it uses the | 578 | @code{major-mode}; if that is @code{nil}, it uses the |
| @@ -740,38 +679,30 @@ init file.) | |||
| 740 | @cindex help for major mode | 679 | @cindex help for major mode |
| 741 | @cindex documentation for major mode | 680 | @cindex documentation for major mode |
| 742 | 681 | ||
| 743 | The @code{describe-mode} function is used to provide information | 682 | The @code{describe-mode} function is provides information about major |
| 744 | about major modes. It is normally called with @kbd{C-h m}. The | 683 | modes. It is normally bound to @kbd{C-h m}. It uses the value of the |
| 745 | @code{describe-mode} function uses the value of @code{major-mode}, | 684 | variable @code{major-mode} (@pxref{Major Modes}), which is why every |
| 746 | which is why every major mode function needs to set the | 685 | major mode command needs to set that variable. |
| 747 | @code{major-mode} variable. | ||
| 748 | 686 | ||
| 749 | @deffn Command describe-mode | 687 | @deffn Command describe-mode |
| 750 | This function displays the documentation of the current major mode. | 688 | This function displays the documentation of the current major mode. |
| 751 | 689 | ||
| 752 | The @code{describe-mode} function calls the @code{documentation} | 690 | The @code{describe-mode} function calls the @code{documentation} |
| 753 | function using the value of @code{major-mode} as an argument. Thus, it | 691 | function using the value of @code{major-mode} as an argument. Thus, it |
| 754 | displays the documentation string of the major mode function. | 692 | displays the documentation string of the major mode command. |
| 755 | (@xref{Accessing Documentation}.) | 693 | (@xref{Accessing Documentation}.) |
| 756 | @end deffn | 694 | @end deffn |
| 757 | 695 | ||
| 758 | @defvar major-mode | ||
| 759 | This buffer-local variable holds the symbol for the current buffer's | ||
| 760 | major mode. This symbol should have a function definition that is the | ||
| 761 | command to switch to that major mode. The @code{describe-mode} | ||
| 762 | function uses the documentation string of the function as the | ||
| 763 | documentation of the major mode. | ||
| 764 | @end defvar | ||
| 765 | |||
| 766 | @node Derived Modes | 696 | @node Derived Modes |
| 767 | @subsection Defining Derived Modes | 697 | @subsection Defining Derived Modes |
| 768 | @cindex derived mode | 698 | @cindex derived mode |
| 769 | 699 | ||
| 770 | The recommended way to define a new major mode is to derive it | 700 | The recommended way to define a new major mode is to derive it from an |
| 771 | from an existing one using @code{define-derived-mode}. If there is no | 701 | existing one using @code{define-derived-mode}. If there is no closely |
| 772 | closely related mode, you can inherit from @code{text-mode}, | 702 | related mode, you should inherit from either @code{text-mode}, |
| 773 | @code{special-mode}, @code{prog-mode}, or in the worst case | 703 | @code{special-mode}, or @code{prog-mode}. @xref{Basic Major Modes}. If |
| 774 | @code{fundamental-mode}. | 704 | none of these are suitable, you can inherit from @code{fundamental-mode} |
| 705 | (@pxref{Major Modes}). | ||
| 775 | 706 | ||
| 776 | @defmac define-derived-mode variant parent name docstring keyword-args@dots{} body@dots{} | 707 | @defmac define-derived-mode variant parent name docstring keyword-args@dots{} body@dots{} |
| 777 | This macro defines @var{variant} as a major mode command, using | 708 | This macro defines @var{variant} as a major mode command, using |
| @@ -872,6 +803,64 @@ Do not write an @code{interactive} spec in the definition; | |||
| 872 | @code{define-derived-mode} does that automatically. | 803 | @code{define-derived-mode} does that automatically. |
| 873 | @end defmac | 804 | @end defmac |
| 874 | 805 | ||
| 806 | @defun derived-mode-p &rest modes | ||
| 807 | This function returns non-@code{nil} if the current major mode is | ||
| 808 | derived from any of the major modes given by the symbols @var{modes}. | ||
| 809 | @end defun | ||
| 810 | |||
| 811 | @node Basic Major Modes | ||
| 812 | @subsection Basic Major Modes | ||
| 813 | |||
| 814 | Apart from Fundamental mode, there are three major modes that other | ||
| 815 | major modes commonly derive from: Text mode, Prog mode, and Special | ||
| 816 | mode. While Text mode is useful in its own right (e.g. for editing | ||
| 817 | files ending in @file{.txt}), Prog mode and Special mode exist mainly to | ||
| 818 | let other modes derive from them. | ||
| 819 | |||
| 820 | @vindex prog-mode-hook | ||
| 821 | As far as possible, new major modes should be derived, either directly | ||
| 822 | or indirectly, from one of these three modes. One reason is that this | ||
| 823 | allows users to customize a single mode hook | ||
| 824 | (e.g. @code{prog-mode-hook}) for an entire family of relevant modes | ||
| 825 | (e.g. all programming language modes). | ||
| 826 | |||
| 827 | @deffn Command text-mode | ||
| 828 | Text mode is a major mode for editing human languages. It defines the | ||
| 829 | @samp{"} and @samp{\} characters as having punctuation syntax | ||
| 830 | (@pxref{Syntax Class Table}), and binds @kbd{M-@key{TAB}} to | ||
| 831 | @code{ispell-complete-word} (@pxref{Spelling,,, emacs, The GNU Emacs | ||
| 832 | Manual}). | ||
| 833 | |||
| 834 | An example of a major mode derived from Text mode is HTML mode. | ||
| 835 | @xref{HTML Mode,,SGML and HTML Modes, emacs, The GNU Emacs Manual}. | ||
| 836 | @end deffn | ||
| 837 | |||
| 838 | @deffn Command prog-mode | ||
| 839 | Prog mode is a basic major mode for buffers containing programming | ||
| 840 | language source code. Most of the programming language major modes | ||
| 841 | built into Emacs are derived from it. | ||
| 842 | |||
| 843 | Prog mode binds @code{parse-sexp-ignore-comments} to @code{t} | ||
| 844 | (@pxref{Motion via Parsing}) and @code{bidi-paragraph-direction} to | ||
| 845 | @code{left-to-right} (@pxref{Bidirectional Display}). | ||
| 846 | @end deffn | ||
| 847 | |||
| 848 | @deffn Command special-mode | ||
| 849 | Special mode is a basic major mode for buffers containing text that is | ||
| 850 | produced specially by Emacs, rather than from a file. Major modes | ||
| 851 | derived from Special mode are given a @code{mode-class} property of | ||
| 852 | @code{special} (@pxref{Major Mode Conventions}). | ||
| 853 | |||
| 854 | Special mode sets the buffer to read-only. Its keymap defines several | ||
| 855 | common bindings, including @kbd{q} for @code{quit-window}, @kbd{z} for | ||
| 856 | @code{kill-this-buffer}, and @kbd{g} for @code{revert-buffer} | ||
| 857 | (@pxref{Reverting}). | ||
| 858 | |||
| 859 | An example of a major mode derived from Special mode is Buffer Menu | ||
| 860 | mode, which is used by the @samp{*Buffer List*} buffer. @xref{List | ||
| 861 | Buffers,,Listing Existing Buffers, emacs, The GNU Emacs Manual}. | ||
| 862 | @end deffn | ||
| 863 | |||
| 875 | @node Generic Modes | 864 | @node Generic Modes |
| 876 | @subsection Generic Modes | 865 | @subsection Generic Modes |
| 877 | @cindex generic mode | 866 | @cindex generic mode |
| @@ -916,7 +905,7 @@ before it runs the mode hook variable @code{@var{mode}-hook}. | |||
| 916 | @node Mode Hooks | 905 | @node Mode Hooks |
| 917 | @subsection Mode Hooks | 906 | @subsection Mode Hooks |
| 918 | 907 | ||
| 919 | Every major mode function should finish by running its mode hook and | 908 | Every major mode command should finish by running its mode hook and |
| 920 | the mode-independent normal hook @code{after-change-major-mode-hook}. | 909 | the mode-independent normal hook @code{after-change-major-mode-hook}. |
| 921 | It does this by calling @code{run-mode-hooks}. If the major mode is a | 910 | It does this by calling @code{run-mode-hooks}. If the major mode is a |
| 922 | derived mode, that is if it calls another major mode (the parent mode) | 911 | derived mode, that is if it calls another major mode (the parent mode) |
| @@ -961,7 +950,7 @@ construct. | |||
| 961 | 950 | ||
| 962 | @defvar after-change-major-mode-hook | 951 | @defvar after-change-major-mode-hook |
| 963 | This is a normal hook run by @code{run-mode-hooks}. It is run at the | 952 | This is a normal hook run by @code{run-mode-hooks}. It is run at the |
| 964 | very end of every properly-written major mode function. | 953 | very end of every properly-written major mode command. |
| 965 | @end defvar | 954 | @end defvar |
| 966 | 955 | ||
| 967 | @node Example Major Modes | 956 | @node Example Major Modes |
| @@ -1189,8 +1178,8 @@ And here is the code to set up the keymap for Lisp mode: | |||
| 1189 | @end group | 1178 | @end group |
| 1190 | @end smallexample | 1179 | @end smallexample |
| 1191 | 1180 | ||
| 1192 | Finally, here is the complete major mode function definition for | 1181 | Finally, here is the complete major mode command definition for Lisp |
| 1193 | Lisp mode. | 1182 | mode. |
| 1194 | 1183 | ||
| 1195 | @smallexample | 1184 | @smallexample |
| 1196 | @group | 1185 | @group |
| @@ -2747,10 +2736,10 @@ highlighting patterns. See the variables | |||
| 2747 | @code{c-font-lock-extra-types}, @code{c++-font-lock-extra-types}, | 2736 | @code{c-font-lock-extra-types}, @code{c++-font-lock-extra-types}, |
| 2748 | and @code{java-font-lock-extra-types}, for example. | 2737 | and @code{java-font-lock-extra-types}, for example. |
| 2749 | 2738 | ||
| 2750 | @strong{Warning:} major mode functions must not call | 2739 | @strong{Warning:} major mode commands must not call |
| 2751 | @code{font-lock-add-keywords} under any circumstances, either directly | 2740 | @code{font-lock-add-keywords} under any circumstances, either directly |
| 2752 | or indirectly, except through their mode hooks. (Doing so would lead | 2741 | or indirectly, except through their mode hooks. (Doing so would lead to |
| 2753 | to incorrect behavior for some minor modes.) They should set up their | 2742 | incorrect behavior for some minor modes.) They should set up their |
| 2754 | rules for search-based fontification by setting | 2743 | rules for search-based fontification by setting |
| 2755 | @code{font-lock-keywords}. | 2744 | @code{font-lock-keywords}. |
| 2756 | @end defun | 2745 | @end defun |
diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi index 77337899923..298c7c3d1a8 100644 --- a/doc/lispref/nonascii.texi +++ b/doc/lispref/nonascii.texi | |||
| @@ -369,6 +369,12 @@ replacing each @samp{_} character with a dash @samp{-}. For example, | |||
| 369 | @code{canonical-combining-class}. However, sometimes we shorten the | 369 | @code{canonical-combining-class}. However, sometimes we shorten the |
| 370 | names to make their use easier. | 370 | names to make their use easier. |
| 371 | 371 | ||
| 372 | @cindex unassigned character codepoints | ||
| 373 | Some codepoints are left @dfn{unassigned} by the | ||
| 374 | @acronym{UCD}---they don't correspond to any character. The Unicode | ||
| 375 | Standard defines default values of properties for such codepoints; | ||
| 376 | they are mentioned below for each property. | ||
| 377 | |||
| 372 | Here is the full list of value types for all the character | 378 | Here is the full list of value types for all the character |
| 373 | properties that Emacs knows about: | 379 | properties that Emacs knows about: |
| 374 | 380 | ||
| @@ -376,22 +382,31 @@ properties that Emacs knows about: | |||
| 376 | @item name | 382 | @item name |
| 377 | Corresponds to the @code{Name} Unicode property. The value is a | 383 | Corresponds to the @code{Name} Unicode property. The value is a |
| 378 | string consisting of upper-case Latin letters A to Z, digits, spaces, | 384 | string consisting of upper-case Latin letters A to Z, digits, spaces, |
| 379 | and hyphen @samp{-} characters. | 385 | and hyphen @samp{-} characters. For unassigned codepoints, the value |
| 386 | is an empty string. | ||
| 380 | 387 | ||
| 381 | @cindex unicode general category | 388 | @cindex unicode general category |
| 382 | @item general-category | 389 | @item general-category |
| 383 | Corresponds to the @code{General_Category} Unicode property. The | 390 | Corresponds to the @code{General_Category} Unicode property. The |
| 384 | value is a symbol whose name is a 2-letter abbreviation of the | 391 | value is a symbol whose name is a 2-letter abbreviation of the |
| 385 | character's classification. | 392 | character's classification. For unassigned codepoints, the value |
| 393 | is @code{Cn}. | ||
| 386 | 394 | ||
| 387 | @item canonical-combining-class | 395 | @item canonical-combining-class |
| 388 | Corresponds to the @code{Canonical_Combining_Class} Unicode property. | 396 | Corresponds to the @code{Canonical_Combining_Class} Unicode property. |
| 389 | The value is an integer number. | 397 | The value is an integer number. For unassigned codepoints, the value |
| 398 | is zero. | ||
| 390 | 399 | ||
| 400 | @cindex bidirectional class of characters | ||
| 391 | @item bidi-class | 401 | @item bidi-class |
| 392 | Corresponds to the Unicode @code{Bidi_Class} property. The value is a | 402 | Corresponds to the Unicode @code{Bidi_Class} property. The value is a |
| 393 | symbol whose name is the Unicode @dfn{directional type} of the | 403 | symbol whose name is the Unicode @dfn{directional type} of the |
| 394 | character. | 404 | character. Emacs uses this property when it reorders bidirectional |
| 405 | text for display (@pxref{Bidirectional Display}). For unassigned | ||
| 406 | codepoints, the value depends on the code blocks to which the | ||
| 407 | codepoint belongs: most unassigned codepoints get the value of | ||
| 408 | @code{L} (strong L), but some get values of @code{AL} (Arabic letter) | ||
| 409 | or @code{R} (strong R). | ||
| 395 | 410 | ||
| 396 | @item decomposition | 411 | @item decomposition |
| 397 | Corresponds to the Unicode @code{Decomposition_Type} and | 412 | Corresponds to the Unicode @code{Decomposition_Type} and |
| @@ -403,19 +418,22 @@ Note that the Unicode spec writes these tag names inside | |||
| 403 | brackets; e.g., Unicode specifies @samp{<small>} where Emacs uses | 418 | brackets; e.g., Unicode specifies @samp{<small>} where Emacs uses |
| 404 | @samp{small}. | 419 | @samp{small}. |
| 405 | }; the other elements are characters that give the compatibility | 420 | }; the other elements are characters that give the compatibility |
| 406 | decomposition sequence of this character. | 421 | decomposition sequence of this character. For unassigned codepoints, |
| 422 | the value is the character itself. | ||
| 407 | 423 | ||
| 408 | @item decimal-digit-value | 424 | @item decimal-digit-value |
| 409 | Corresponds to the Unicode @code{Numeric_Value} property for | 425 | Corresponds to the Unicode @code{Numeric_Value} property for |
| 410 | characters whose @code{Numeric_Type} is @samp{Digit}. The value is an | 426 | characters whose @code{Numeric_Type} is @samp{Digit}. The value is an |
| 411 | integer number. | 427 | integer number. For unassigned codepoints, the value is @code{nil}, |
| 428 | which means @acronym{NaN}, or ``not-a-number''. | ||
| 412 | 429 | ||
| 413 | @item digit-value | 430 | @item digit-value |
| 414 | Corresponds to the Unicode @code{Numeric_Value} property for | 431 | Corresponds to the Unicode @code{Numeric_Value} property for |
| 415 | characters whose @code{Numeric_Type} is @samp{Decimal}. The value is | 432 | characters whose @code{Numeric_Type} is @samp{Decimal}. The value is |
| 416 | an integer number. Examples of such characters include compatibility | 433 | an integer number. Examples of such characters include compatibility |
| 417 | subscript and superscript digits, for which the value is the | 434 | subscript and superscript digits, for which the value is the |
| 418 | corresponding number. | 435 | corresponding number. For unassigned codepoints, the value is |
| 436 | @code{nil}, which means @acronym{NaN}. | ||
| 419 | 437 | ||
| 420 | @item numeric-value | 438 | @item numeric-value |
| 421 | Corresponds to the Unicode @code{Numeric_Value} property for | 439 | Corresponds to the Unicode @code{Numeric_Value} property for |
| @@ -424,33 +442,53 @@ this property is an integer or a floating-point number. Examples of | |||
| 424 | characters that have this property include fractions, subscripts, | 442 | characters that have this property include fractions, subscripts, |
| 425 | superscripts, Roman numerals, currency numerators, and encircled | 443 | superscripts, Roman numerals, currency numerators, and encircled |
| 426 | numbers. For example, the value of this property for the character | 444 | numbers. For example, the value of this property for the character |
| 427 | @code{U+2155} (@sc{vulgar fraction one fifth}) is @code{0.2}. | 445 | @code{U+2155} (@sc{vulgar fraction one fifth}) is @code{0.2}. For |
| 446 | unassigned codepoints, the value is @code{nil}, which means | ||
| 447 | @acronym{NaN}. | ||
| 428 | 448 | ||
| 449 | @cindex mirroring of characters | ||
| 429 | @item mirrored | 450 | @item mirrored |
| 430 | Corresponds to the Unicode @code{Bidi_Mirrored} property. The value | 451 | Corresponds to the Unicode @code{Bidi_Mirrored} property. The value |
| 431 | of this property is a symbol, either @code{Y} or @code{N}. | 452 | of this property is a symbol, either @code{Y} or @code{N}. For |
| 453 | unassigned codepoints, the value is @code{N}. | ||
| 454 | |||
| 455 | @item mirroring | ||
| 456 | Corresponds to the Unicode @code{Bidi_Mirroring_Glyph} property. The | ||
| 457 | value of this property is a character whose glyph represents the | ||
| 458 | mirror image of the character's glyph, or @code{nil} if there's no | ||
| 459 | defined mirroring glyph. All the characters whose @code{mirrored} | ||
| 460 | property is @code{N} have @code{nil} as their @code{mirroring} | ||
| 461 | property; however, some characters whose @code{mirrored} property is | ||
| 462 | @code{Y} also have @code{nil} for @code{mirroring}, because no | ||
| 463 | appropriate characters exist with mirrored glyphs. Emacs uses this | ||
| 464 | property to display mirror images of characters when appropriate | ||
| 465 | (@pxref{Bidirectional Display}). For unassigned codepoints, the value | ||
| 466 | is @code{nil}. | ||
| 432 | 467 | ||
| 433 | @item old-name | 468 | @item old-name |
| 434 | Corresponds to the Unicode @code{Unicode_1_Name} property. The value | 469 | Corresponds to the Unicode @code{Unicode_1_Name} property. The value |
| 435 | is a string. | 470 | is a string. For unassigned codepoints, the value is an empty string. |
| 436 | 471 | ||
| 437 | @item iso-10646-comment | 472 | @item iso-10646-comment |
| 438 | Corresponds to the Unicode @code{ISO_Comment} property. The value is | 473 | Corresponds to the Unicode @code{ISO_Comment} property. The value is |
| 439 | a string. | 474 | a string. For unassigned codepoints, the value is an empty string. |
| 440 | 475 | ||
| 441 | @item uppercase | 476 | @item uppercase |
| 442 | Corresponds to the Unicode @code{Simple_Uppercase_Mapping} property. | 477 | Corresponds to the Unicode @code{Simple_Uppercase_Mapping} property. |
| 443 | The value of this property is a single character. | 478 | The value of this property is a single character. For unassigned |
| 479 | codepoints, the value is @code{nil}, which means the character itself. | ||
| 444 | 480 | ||
| 445 | @item lowercase | 481 | @item lowercase |
| 446 | Corresponds to the Unicode @code{Simple_Lowercase_Mapping} property. | 482 | Corresponds to the Unicode @code{Simple_Lowercase_Mapping} property. |
| 447 | The value of this property is a single character. | 483 | The value of this property is a single character. For unassigned |
| 484 | codepoints, the value is @code{nil}, which means the character itself. | ||
| 448 | 485 | ||
| 449 | @item titlecase | 486 | @item titlecase |
| 450 | Corresponds to the Unicode @code{Simple_Titlecase_Mapping} property. | 487 | Corresponds to the Unicode @code{Simple_Titlecase_Mapping} property. |
| 451 | @dfn{Title case} is a special form of a character used when the first | 488 | @dfn{Title case} is a special form of a character used when the first |
| 452 | character of a word needs to be capitalized. The value of this | 489 | character of a word needs to be capitalized. The value of this |
| 453 | property is a single character. | 490 | property is a single character. For unassigned codepoints, the value |
| 491 | is @code{nil}, which means the character itself. | ||
| 454 | @end table | 492 | @end table |
| 455 | 493 | ||
| 456 | @defun get-char-code-property char propname | 494 | @defun get-char-code-property char propname |
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi index 6d63bb7b750..26def7858b7 100644 --- a/doc/lispref/objects.texi +++ b/doc/lispref/objects.texi | |||
| @@ -597,6 +597,7 @@ FOO ; @r{A symbol named @samp{FOO}, different from @samp{foo}.} | |||
| 597 | @end group | 597 | @end group |
| 598 | @end example | 598 | @end example |
| 599 | 599 | ||
| 600 | @cindex @samp{##} read syntax | ||
| 600 | @ifinfo | 601 | @ifinfo |
| 601 | @c This uses ``colon'' instead of a literal `:' because Info cannot | 602 | @c This uses ``colon'' instead of a literal `:' because Info cannot |
| 602 | @c cope with a `:' in a menu | 603 | @c cope with a `:' in a menu |
| @@ -605,9 +606,12 @@ FOO ; @r{A symbol named @samp{FOO}, different from @samp{foo}.} | |||
| 605 | @ifnotinfo | 606 | @ifnotinfo |
| 606 | @cindex @samp{#:} read syntax | 607 | @cindex @samp{#:} read syntax |
| 607 | @end ifnotinfo | 608 | @end ifnotinfo |
| 608 | Normally the Lisp reader interns all symbols (@pxref{Creating | 609 | As an exception to the rule that a symbol's name serves as its |
| 609 | Symbols}). To prevent interning, you can write @samp{#:} before the | 610 | printed representation, @samp{##} is the printed representation for an |
| 610 | name of the symbol. | 611 | interned symbol whose name is an empty string. Furthermore, |
| 612 | @samp{#:@var{foo}} is the printed representation for an uninterned | ||
| 613 | symbol whose name is @var{foo}. (Normally, the Lisp reader interns | ||
| 614 | all symbols; @pxref{Creating Symbols}.) | ||
| 611 | 615 | ||
| 612 | @node Sequence Type | 616 | @node Sequence Type |
| 613 | @subsection Sequence Types | 617 | @subsection Sequence Types |
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 5f422065c5b..7d05f8f3468 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -544,10 +544,11 @@ parent process normally resumes control. The low-level primitive for | |||
| 544 | killing Emacs is @code{kill-emacs}. | 544 | killing Emacs is @code{kill-emacs}. |
| 545 | 545 | ||
| 546 | @deffn Command kill-emacs &optional exit-data | 546 | @deffn Command kill-emacs &optional exit-data |
| 547 | This command exits the Emacs process and kills it. | 547 | This command calls the hook @code{kill-emacs-hook}, then exits the |
| 548 | Emacs process and kills it. | ||
| 548 | 549 | ||
| 549 | If @var{exit-data} is an integer, then it is used as the exit status | 550 | If @var{exit-data} is an integer, that is used as the exit status of |
| 550 | of the Emacs process. (This is useful primarily in batch operation; see | 551 | the Emacs process. (This is useful primarily in batch operation; see |
| 551 | @ref{Batch Mode}.) | 552 | @ref{Batch Mode}.) |
| 552 | 553 | ||
| 553 | If @var{exit-data} is a string, its contents are stuffed into the | 554 | If @var{exit-data} is a string, its contents are stuffed into the |
| @@ -555,35 +556,44 @@ terminal input buffer so that the shell (or whatever program next reads | |||
| 555 | input) can read them. | 556 | input) can read them. |
| 556 | @end deffn | 557 | @end deffn |
| 557 | 558 | ||
| 558 | All the information in the Emacs process, aside from files that have | 559 | @cindex SIGTERM |
| 559 | been saved, is lost when the Emacs process is killed. Because killing | 560 | @cindex SIGHUP |
| 560 | Emacs inadvertently can lose a lot of work, Emacs queries for | 561 | @cindex SIGINT |
| 561 | confirmation before actually terminating if you have buffers that need | 562 | @cindex operating system signal |
| 562 | saving or subprocesses that are running. This is done in the function | 563 | The @code{kill-emacs} function is normally called via the |
| 563 | @code{save-buffers-kill-emacs}, the higher level function from which | 564 | higher-level command @kbd{C-x C-c} |
| 564 | @code{kill-emacs} is usually called. | 565 | (@code{save-buffers-kill-terminal}). @xref{Exiting,,, emacs, The GNU |
| 566 | Emacs Manual}. It is also called automatically if Emacs receives a | ||
| 567 | @code{SIGTERM} or @code{SIGHUP} operating system signal (e.g. when the | ||
| 568 | controlling terminal is disconnected), or if it receives a | ||
| 569 | @code{SIGINT} signal while running in batch mode (@pxref{Batch Mode}). | ||
| 565 | 570 | ||
| 566 | @defvar kill-emacs-query-functions | 571 | @defvar kill-emacs-hook |
| 567 | After asking the standard questions, @code{save-buffers-kill-emacs} | 572 | This normal hook is run by @code{kill-emacs}, before it kills Emacs. |
| 568 | calls the functions in the list @code{kill-emacs-query-functions}, in | 573 | |
| 569 | order of appearance, with no arguments. These functions can ask for | 574 | Because @code{kill-emacs} can be called in situations where user |
| 570 | additional confirmation from the user. If any of them returns | 575 | interaction is impossible (e.g. when the terminal is disconnected), |
| 571 | @code{nil}, @code{save-buffers-kill-emacs} does not kill Emacs, and | 576 | functions on this hook should not attempt to interact with the user. |
| 572 | does not run the remaining functions in this hook. Calling | 577 | If you want to interact with the user when Emacs is shutting down, use |
| 573 | @code{kill-emacs} directly does not run this hook. | 578 | @code{kill-emacs-query-functions}, described below. |
| 574 | @end defvar | 579 | @end defvar |
| 575 | 580 | ||
| 576 | @defvar kill-emacs-hook | 581 | When Emacs is killed, all the information in the Emacs process, |
| 577 | This variable is a normal hook; once @code{save-buffers-kill-emacs} is | 582 | aside from files that have been saved, is lost. Because killing Emacs |
| 578 | finished with all file saving and confirmation, it calls | 583 | inadvertently can lose a lot of work, the |
| 579 | @code{kill-emacs} which runs the functions in this hook. | 584 | @code{save-buffers-kill-terminal} command queries for confirmation if |
| 580 | 585 | you have buffers that need saving or subprocesses that are running. | |
| 581 | @code{kill-emacs} may be invoked directly (that is not via | 586 | It also runs the abnormal hook @code{kill-emacs-query-functions}: |
| 582 | @code{save-buffers-kill-emacs}) if the terminal is disconnected, or in | 587 | |
| 583 | similar situations where interaction with the user is not possible. | 588 | @defvar kill-emacs-query-functions |
| 584 | Thus, if your hook needs to interact with the user, put it on | 589 | When @code{save-buffers-kill-terminal} is killing Emacs, it calls the |
| 585 | @code{kill-emacs-query-functions}; if it needs to run regardless of | 590 | functions in this hook, after asking the standard questions and before |
| 586 | how Emacs is killed, put it on @code{kill-emacs-hook}. | 591 | calling @code{kill-emacs}. The functions are called in order of |
| 592 | appearance, with no arguments. Each function can ask for additional | ||
| 593 | confirmation from the user. If any of them returns @code{nil}, | ||
| 594 | @code{save-buffers-kill-emacs} does not kill Emacs, and does not run | ||
| 595 | the remaining functions in this hook. Calling @code{kill-emacs} | ||
| 596 | directly does not run this hook. | ||
| 587 | @end defvar | 597 | @end defvar |
| 588 | 598 | ||
| 589 | @node Suspending Emacs | 599 | @node Suspending Emacs |
| @@ -1143,6 +1153,18 @@ get with the function @code{file-attributes}. | |||
| 1143 | @xref{Definition of file-attributes}. | 1153 | @xref{Definition of file-attributes}. |
| 1144 | @end defun | 1154 | @end defun |
| 1145 | 1155 | ||
| 1156 | @defun float-time &optional time-value | ||
| 1157 | This function returns the current time as a floating-point number of | ||
| 1158 | seconds since the epoch. The argument @var{time-value}, if given, | ||
| 1159 | specifies a time to convert instead of the current time. The argument | ||
| 1160 | should have the same form as for @code{current-time-string} (see | ||
| 1161 | above). Thus, it accepts the output of @code{current-time} and | ||
| 1162 | @code{file-attributes} (@pxref{Definition of file-attributes}). | ||
| 1163 | |||
| 1164 | @emph{Warning}: Since the result is floating point, it may not be | ||
| 1165 | exact. Do not use this function if precise time stamps are required. | ||
| 1166 | @end defun | ||
| 1167 | |||
| 1146 | @defun current-time-zone &optional time-value | 1168 | @defun current-time-zone &optional time-value |
| 1147 | This function returns a list describing the time zone that the user is | 1169 | This function returns a list describing the time zone that the user is |
| 1148 | in. | 1170 | in. |
| @@ -1165,25 +1187,11 @@ times obtained from @code{current-time} (see above) and from | |||
| 1165 | @code{file-attributes}. @xref{Definition of file-attributes}. | 1187 | @code{file-attributes}. @xref{Definition of file-attributes}. |
| 1166 | @end defun | 1188 | @end defun |
| 1167 | 1189 | ||
| 1168 | @defun set-time-zone-rule tz | 1190 | The current time zone is determined by the @samp{TZ} environment |
| 1169 | This function specifies the local time zone according to @var{tz}. If | 1191 | variable. @xref{System Environment}. For example, you can tell Emacs |
| 1170 | @var{tz} is @code{nil}, that means to use an implementation-defined | 1192 | to use universal time with @code{(setenv "TZ" "UTC0")}. If @samp{TZ} |
| 1171 | default time zone. If @var{tz} is @code{t}, that means to use | 1193 | is not in the environment, Emacs uses a platform-dependent default |
| 1172 | Universal Time. Otherwise, @var{tz} should be a string specifying a | 1194 | time zone. |
| 1173 | time zone rule. | ||
| 1174 | @end defun | ||
| 1175 | |||
| 1176 | @defun float-time &optional time-value | ||
| 1177 | This function returns the current time as a floating-point number of | ||
| 1178 | seconds since the epoch. The argument @var{time-value}, if given, | ||
| 1179 | specifies a time to convert instead of the current time. The argument | ||
| 1180 | should have the same form as for @code{current-time-string} (see | ||
| 1181 | above). Thus, it accepts the output of @code{current-time} and | ||
| 1182 | @code{file-attributes} (@pxref{Definition of file-attributes}). | ||
| 1183 | |||
| 1184 | @emph{Warning}: Since the result is floating point, it may not be | ||
| 1185 | exact. Do not use this function if precise time stamps are required. | ||
| 1186 | @end defun | ||
| 1187 | 1195 | ||
| 1188 | @node Time Conversion | 1196 | @node Time Conversion |
| 1189 | @section Time Conversion | 1197 | @section Time Conversion |
diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi index 6272301dbb4..fe7c805c6f7 100644 --- a/doc/lispref/searching.texi +++ b/doc/lispref/searching.texi | |||
| @@ -717,11 +717,15 @@ the characters that stand for them. | |||
| 717 | @cindex @samp{\S} in regexp | 717 | @cindex @samp{\S} in regexp |
| 718 | matches any character whose syntax is not @var{code}. | 718 | matches any character whose syntax is not @var{code}. |
| 719 | 719 | ||
| 720 | @cindex category, regexp search for | ||
| 720 | @item \c@var{c} | 721 | @item \c@var{c} |
| 721 | matches any character whose category is @var{c}. Here @var{c} is a | 722 | matches any character whose category is @var{c}. Here @var{c} is a |
| 722 | character that represents a category: thus, @samp{c} for Chinese | 723 | character that represents a category: thus, @samp{c} for Chinese |
| 723 | characters or @samp{g} for Greek characters in the standard category | 724 | characters or @samp{g} for Greek characters in the standard category |
| 724 | table. | 725 | table. You can see the list of all the currently defined categories |
| 726 | with @kbd{M-x describe-categories @key{RET}}. You can also define | ||
| 727 | your own categories in addition to the standard ones using the | ||
| 728 | @code{define-category} function (@pxref{Categories}). | ||
| 725 | 729 | ||
| 726 | @item \C@var{c} | 730 | @item \C@var{c} |
| 727 | matches any character whose category is not @var{c}. | 731 | matches any character whose category is not @var{c}. |
diff --git a/doc/lispref/syntax.texi b/doc/lispref/syntax.texi index 31ee7eb4e7d..0d7a0c0bed4 100644 --- a/doc/lispref/syntax.texi +++ b/doc/lispref/syntax.texi | |||
| @@ -1084,6 +1084,24 @@ defaults to the current buffer's category table. | |||
| 1084 | @defun define-category char docstring &optional table | 1084 | @defun define-category char docstring &optional table |
| 1085 | This function defines a new category, with name @var{char} and | 1085 | This function defines a new category, with name @var{char} and |
| 1086 | documentation @var{docstring}, for the category table @var{table}. | 1086 | documentation @var{docstring}, for the category table @var{table}. |
| 1087 | |||
| 1088 | Here's an example of defining a new category for characters that have | ||
| 1089 | strong right-to-left directionality (@pxref{Bidirectional Display}) | ||
| 1090 | and using it in a special category table: | ||
| 1091 | |||
| 1092 | @example | ||
| 1093 | (defvar special-category-table-for-bidi | ||
| 1094 | (let ((category-table (make-category-table)) | ||
| 1095 | (uniprop-table (unicode-property-table-internal 'bidi-class))) | ||
| 1096 | (define-category ?R "Characters of bidi-class R, AL, or RLO" | ||
| 1097 | category-table) | ||
| 1098 | (map-char-table | ||
| 1099 | #'(lambda (key val) | ||
| 1100 | (if (memq val '(R AL RLO)) | ||
| 1101 | (modify-category-entry key ?R category-table))) | ||
| 1102 | uniprop-table) | ||
| 1103 | category-table)) | ||
| 1104 | @end example | ||
| 1087 | @end defun | 1105 | @end defun |
| 1088 | 1106 | ||
| 1089 | @defun category-docstring category &optional table | 1107 | @defun category-docstring category &optional table |
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index b91afb044f0..2348e3706dc 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi | |||
| @@ -3015,6 +3015,11 @@ near the character. For this purpose, ``near'' means that all text | |||
| 3015 | between the character and where the mouse is have the same | 3015 | between the character and where the mouse is have the same |
| 3016 | @code{mouse-face} property value. | 3016 | @code{mouse-face} property value. |
| 3017 | 3017 | ||
| 3018 | Emacs ignores all face attributes from the @code{mouse-face} property | ||
| 3019 | that alter the text size (e.g. @code{:height}, @code{:weight}, and | ||
| 3020 | @code{:slant}). Those attributes are always the same as for the | ||
| 3021 | unhighlighted text. | ||
| 3022 | |||
| 3018 | @item fontified | 3023 | @item fontified |
| 3019 | @kindex fontified @r{(text property)} | 3024 | @kindex fontified @r{(text property)} |
| 3020 | This property says whether the text is ready for display. If | 3025 | This property says whether the text is ready for display. If |
diff --git a/doc/lispref/vol1.texi b/doc/lispref/vol1.texi index 3b7718814b5..1275628cc94 100644 --- a/doc/lispref/vol1.texi +++ b/doc/lispref/vol1.texi | |||
| @@ -786,8 +786,7 @@ Major and Minor Modes | |||
| 786 | * Major Modes:: Defining major modes. | 786 | * Major Modes:: Defining major modes. |
| 787 | * Minor Modes:: Defining minor modes. | 787 | * Minor Modes:: Defining minor modes. |
| 788 | * Mode Line Format:: Customizing the text that appears in the mode line. | 788 | * Mode Line Format:: Customizing the text that appears in the mode line. |
| 789 | * Imenu:: How a mode can provide a menu | 789 | * Imenu:: Providing a menu of definitions made in a buffer. |
| 790 | of definitions in the buffer. | ||
| 791 | * Font Lock Mode:: How modes can highlight text according to syntax. | 790 | * Font Lock Mode:: How modes can highlight text according to syntax. |
| 792 | * Desktop Save Mode:: How modes can have buffer state saved between | 791 | * Desktop Save Mode:: How modes can have buffer state saved between |
| 793 | Emacs sessions. | 792 | Emacs sessions. |
| @@ -799,15 +798,15 @@ Hooks | |||
| 799 | 798 | ||
| 800 | Major Modes | 799 | Major Modes |
| 801 | 800 | ||
| 802 | * Major Mode Basics:: | ||
| 803 | * Major Mode Conventions:: Coding conventions for keymaps, etc. | 801 | * Major Mode Conventions:: Coding conventions for keymaps, etc. |
| 804 | * Auto Major Mode:: How Emacs chooses the major mode automatically. | 802 | * Auto Major Mode:: How Emacs chooses the major mode automatically. |
| 805 | * Mode Help:: Finding out how to use a mode. | 803 | * Mode Help:: Finding out how to use a mode. |
| 806 | * Derived Modes:: Defining a new major mode based on another major | 804 | * Derived Modes:: Defining a new major mode based on another major |
| 807 | mode. | 805 | mode. |
| 806 | * Basic Major Modes:: Modes that other modes are often derived from. | ||
| 808 | * Generic Modes:: Defining a simple major mode that supports | 807 | * Generic Modes:: Defining a simple major mode that supports |
| 809 | comment syntax and Font Lock mode. | 808 | comment syntax and Font Lock mode. |
| 810 | * Mode Hooks:: Hooks run at the end of major mode functions. | 809 | * Mode Hooks:: Hooks run at the end of major mode commands. |
| 811 | * Example Major Modes:: Text mode and Lisp modes. | 810 | * Example Major Modes:: Text mode and Lisp modes. |
| 812 | 811 | ||
| 813 | Minor Modes | 812 | Minor Modes |
| @@ -1330,6 +1329,7 @@ Faces | |||
| 1330 | * Face Remapping:: Remapping faces to alternative definitions. | 1329 | * Face Remapping:: Remapping faces to alternative definitions. |
| 1331 | * Face Functions:: How to define and examine faces. | 1330 | * Face Functions:: How to define and examine faces. |
| 1332 | * Auto Faces:: Hook for automatic face assignment. | 1331 | * Auto Faces:: Hook for automatic face assignment. |
| 1332 | * Basic Faces:: Faces that are defined by default. | ||
| 1333 | * Font Selection:: Finding the best available font for a face. | 1333 | * Font Selection:: Finding the best available font for a face. |
| 1334 | * Font Lookup:: Looking up the names of available fonts | 1334 | * Font Lookup:: Looking up the names of available fonts |
| 1335 | and information about them. | 1335 | and information about them. |
diff --git a/doc/lispref/vol2.texi b/doc/lispref/vol2.texi index 22a51d3235c..3d849fa2dcf 100644 --- a/doc/lispref/vol2.texi +++ b/doc/lispref/vol2.texi | |||
| @@ -785,8 +785,7 @@ Major and Minor Modes | |||
| 785 | * Major Modes:: Defining major modes. | 785 | * Major Modes:: Defining major modes. |
| 786 | * Minor Modes:: Defining minor modes. | 786 | * Minor Modes:: Defining minor modes. |
| 787 | * Mode Line Format:: Customizing the text that appears in the mode line. | 787 | * Mode Line Format:: Customizing the text that appears in the mode line. |
| 788 | * Imenu:: How a mode can provide a menu | 788 | * Imenu:: Providing a menu of definitions made in a buffer. |
| 789 | of definitions in the buffer. | ||
| 790 | * Font Lock Mode:: How modes can highlight text according to syntax. | 789 | * Font Lock Mode:: How modes can highlight text according to syntax. |
| 791 | * Desktop Save Mode:: How modes can have buffer state saved between | 790 | * Desktop Save Mode:: How modes can have buffer state saved between |
| 792 | Emacs sessions. | 791 | Emacs sessions. |
| @@ -798,15 +797,15 @@ Hooks | |||
| 798 | 797 | ||
| 799 | Major Modes | 798 | Major Modes |
| 800 | 799 | ||
| 801 | * Major Mode Basics:: | ||
| 802 | * Major Mode Conventions:: Coding conventions for keymaps, etc. | 800 | * Major Mode Conventions:: Coding conventions for keymaps, etc. |
| 803 | * Auto Major Mode:: How Emacs chooses the major mode automatically. | 801 | * Auto Major Mode:: How Emacs chooses the major mode automatically. |
| 804 | * Mode Help:: Finding out how to use a mode. | 802 | * Mode Help:: Finding out how to use a mode. |
| 805 | * Derived Modes:: Defining a new major mode based on another major | 803 | * Derived Modes:: Defining a new major mode based on another major |
| 806 | mode. | 804 | mode. |
| 805 | * Basic Major Modes:: Modes that other modes are often derived from. | ||
| 807 | * Generic Modes:: Defining a simple major mode that supports | 806 | * Generic Modes:: Defining a simple major mode that supports |
| 808 | comment syntax and Font Lock mode. | 807 | comment syntax and Font Lock mode. |
| 809 | * Mode Hooks:: Hooks run at the end of major mode functions. | 808 | * Mode Hooks:: Hooks run at the end of major mode commands. |
| 810 | * Example Major Modes:: Text mode and Lisp modes. | 809 | * Example Major Modes:: Text mode and Lisp modes. |
| 811 | 810 | ||
| 812 | Minor Modes | 811 | Minor Modes |
| @@ -1329,6 +1328,7 @@ Faces | |||
| 1329 | * Face Remapping:: Remapping faces to alternative definitions. | 1328 | * Face Remapping:: Remapping faces to alternative definitions. |
| 1330 | * Face Functions:: How to define and examine faces. | 1329 | * Face Functions:: How to define and examine faces. |
| 1331 | * Auto Faces:: Hook for automatic face assignment. | 1330 | * Auto Faces:: Hook for automatic face assignment. |
| 1331 | * Basic Faces:: Faces that are defined by default. | ||
| 1332 | * Font Selection:: Finding the best available font for a face. | 1332 | * Font Selection:: Finding the best available font for a face. |
| 1333 | * Font Lookup:: Looking up the names of available fonts | 1333 | * Font Lookup:: Looking up the names of available fonts |
| 1334 | and information about them. | 1334 | and information about them. |