aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref
diff options
context:
space:
mode:
Diffstat (limited to 'doc/lispref')
-rw-r--r--doc/lispref/commands.texi13
-rw-r--r--doc/lispref/control.texi43
-rw-r--r--doc/lispref/display.texi34
-rw-r--r--doc/lispref/functions.texi1
-rw-r--r--doc/lispref/modes.texi2
-rw-r--r--doc/lispref/os.texi72
-rw-r--r--doc/lispref/sequences.texi15
-rw-r--r--doc/lispref/strings.texi11
-rw-r--r--doc/lispref/variables.texi16
9 files changed, 173 insertions, 34 deletions
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index bd31798d431..0583179ed31 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -2778,12 +2778,12 @@ To test the signal handler, you can make Emacs send a signal to itself:
2778@end smallexample 2778@end smallexample
2779 2779
2780@cindex @code{sleep-event} event 2780@cindex @code{sleep-event} event
2781@item (sleep-event @var{sleep-wake}) 2781@item (sleep-event @var{state})
2782This event is injected when the device Emacs is running on enters or 2782This event is injected when the device Emacs is running on is about to
2783leaves the sleep state. A non-@code{nil} @var{sleep-wake} indicates 2783enter a sleep state, or has just awoken from one. @var{state} will be
2784entering the sleep state. 2784the symbol @code{pre-sleep} or @code{post-wake}.
2785 2785
2786This is implemented only on GNU/Linux. 2786This is implemented on GNU/Linux, macOS, and MS-Windows.
2787 2787
2788@cindex @code{language-change} event 2788@cindex @code{language-change} event
2789@item language-change 2789@item language-change
@@ -4062,7 +4062,8 @@ definition to find the actual event.
4062user signals like @code{sigusr1} are normally handled in this way. 4062user signals like @code{sigusr1} are normally handled in this way.
4063The keymap which defines how to handle special events---and which 4063The keymap which defines how to handle special events---and which
4064events are special---is in the variable @code{special-event-map} 4064events are special---is in the variable @code{special-event-map}
4065(@pxref{Controlling Active Maps}). 4065(@pxref{Controlling Active Maps}). @xref{Misc Events}, for more details
4066about these and other special events.
4066 4067
4067@defun insert-special-event 4068@defun insert-special-event
4068@cindex inserting special events 4069@cindex inserting special events
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index a4776030cf2..85e13952cfb 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -1493,25 +1493,27 @@ argument:
1493@subsection The @code{cond*} macro 1493@subsection The @code{cond*} macro
1494@findex cond*@r{, a macro} 1494@findex cond*@r{, a macro}
1495 1495
1496 The @code{cond*} macro is an alternative to @code{pcase}, and supports 1496 You can use the @code{cond*} macro as an alternative to @code{pcase}
1497the same functionality, but using syntax that some might find less 1497if you find @code{pcase}'s syntax too cryptic. In addition,
1498cryptic. 1498@code{cond*} offers some new forms of control flow that aren't related
1499to being an alternative to @code{pcase}.
1499 1500
1500@defmac cond* &rest clauses 1501@defmac cond* &rest clauses
1501The @code{cond*} macro is an extended form of the traditional 1502The @code{cond*} macro is an extended form of the traditional
1502@code{cond}. A @code{cond*} expression contains a series of 1503@code{cond}. A @code{cond*} expression contains a series of
1503@var{clauses}, each of which can use @code{bind*} to specify binding 1504@var{clauses}, each of which can use @code{bind*} or @code{bind-and*} to
1504variables, use @code{match*} to specify matching a pattern as a 1505specify binding variables, use @code{match*} or @code{pcase*} to specify
1505condition, or specify an expression as a condition to evaluate as a 1506matching a pattern as a condition, or specify an expression as a
1506test. 1507condition to evaluate as a test.
1507 1508
1508Each clause normally has the form @w{@code{(@var{condition} 1509Each clause normally has the form @w{@code{(@var{condition}
1509@var{body}@dots{})}}. 1510@var{body}@dots{})}}.
1510 1511
1511@var{condition} can be a Lisp expression, as in @code{cond} 1512@var{condition} can be a Lisp expression, as in @code{cond}
1512(@pxref{Conditionals}). Or it can be @w{@code{(bind* 1513(@pxref{Conditionals}). Or it can be @w{@code{(bind*
1513@var{bindings}@dots{})}} or @w{@code{(match* @var{pattern} 1514@var{bindings}@dots{})}}, @w{@code{(match* @var{pattern} @var{datum})}},
1514@var{datum})}}. 1515@w{@code{(bind-and* @var{bindings}@dots{})}} or @w{@code{(pcase*
1516@var{pattern} @var{datum})}}
1515 1517
1516@findex bind* 1518@findex bind*
1517@code{(bind* @var{bindings}@dots{})} means to bind @var{bindings} (like 1519@code{(bind* @var{bindings}@dots{})} means to bind @var{bindings} (like
@@ -1536,21 +1538,22 @@ bind to the parts of @var{datum} that they match.
1536@code{(pcase* @var{pattern} @var{datum})} works in the same way except it 1538@code{(pcase* @var{pattern} @var{datum})} works in the same way except it
1537uses the Pcase syntax for @var{pattern}. 1539uses the Pcase syntax for @var{pattern}.
1538 1540
1539@code{bind*}, @code{match*}, and @code{pcase*} normally bind their bindings over 1541@code{match*}, and @code{pcase*} normally bind their bindings over the
1540the execution of the whole containing clause. However, if the clause is 1542execution of the whole containing clause. However, if the clause is
1541written to specify ``non-exit'', the clause's bindings cover the whole 1543written to specify ``non-exit'' (see below), the clause's bindings cover
1542rest of the @code{cond*}. 1544the whole rest of the @code{cond*}.
1543 1545
1544When a clause's condition is true, and it exits the @code{cond*} or is 1546When a clause's condition is true, and it exits the @code{cond*} or is
1545the last clause, the value of the last expression in the clause's body 1547the last clause, the value of the last expression in the clause's body
1546becomes the return value of the @code{cond*} construct. 1548becomes the return value of the @code{cond*} construct.
1547 1549
1548@subheading Non-exit clause 1550@subheading Non-exit clauses
1549 1551
1550If a clause has only one element, or if its first element is @code{t}, 1552If a clause has only one element, or if its first element is @code{t} or
1551or if it ends with the keyword @code{:non-exit}, then this clause never 1553a @code{bind*} form, or if it ends with the keyword @code{:non-exit},
1552exits the @code{cond*} construct. Instead, control falls through to the 1554then this clause never exits the @code{cond*} construct. Instead,
1553next clause (if any). The bindings made in @var{condition} for the 1555control falls through to the next clause (if any). Except for a
1556@code{bind-and*} clause, the bindings made in @var{condition} for the
1554@var{body} of the non-exit clause are passed along to the rest of the 1557@var{body} of the non-exit clause are passed along to the rest of the
1555clauses in this @code{cond*} construct. 1558clauses in this @code{cond*} construct.
1556 1559
@@ -2344,7 +2347,9 @@ the other usual filtering mechanisms say it should. @xref{Error Debugging}.
2344The macro @code{condition-case-unless-debug} provides another way to 2347The macro @code{condition-case-unless-debug} provides another way to
2345handle debugging of such forms. It behaves exactly like 2348handle debugging of such forms. It behaves exactly like
2346@code{condition-case}, unless the variable @code{debug-on-error} is 2349@code{condition-case}, unless the variable @code{debug-on-error} is
2347non-@code{nil}, in which case it does not handle any errors at all. 2350non-@code{nil}, in which case it causes Emacs to enter the debugger
2351before executing any applicable handler. (The applicable handler, if
2352any, will still run when the debugger exits.)
2348@end defmac 2353@end defmac
2349 2354
2350 Once Emacs decides that a certain handler handles the error, it 2355 Once Emacs decides that a certain handler handles the error, it
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 4211b435db5..464c0badc36 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -2243,6 +2243,9 @@ means hide the excess parts of @var{string} with a @code{display} text
2243property (@pxref{Display Property}) showing the ellipsis, instead of 2243property (@pxref{Display Property}) showing the ellipsis, instead of
2244actually truncating the string. 2244actually truncating the string.
2245 2245
2246See also the function @code{truncate-string-pixelwise} for pixel-level
2247resolution.
2248
2246@example 2249@example
2247@group 2250@group
2248(truncate-string-to-width "\tab\t" 12 4) 2251(truncate-string-to-width "\tab\t" 12 4)
@@ -2440,6 +2443,37 @@ non-@code{nil}, use any face remappings (@pxref{Face Remapping}) from
2440that buffer when computing the width of @var{string}. 2443that buffer when computing the width of @var{string}.
2441@end defun 2444@end defun
2442 2445
2446@defun truncate-string-pixelwise string max-pixels &optional buffer ellipsis ellipsis-pixels
2447This is a convenience function that uses @code{window-text-pixel-size}
2448to truncate @var{string} to @var{max-pixels} pixels. Caveat: if you
2449call this function to measure the width of a string with embedded
2450newlines, it will then return the width of the widest substring that
2451does not include newlines. The meaning of this result is the widest
2452line taken by the string if inserted into a buffer. If @var{buffer} is
2453non-@code{nil}, use any face remappings (@pxref{Face Remapping}) from
2454that buffer when computing the width of @var{string}.
2455
2456If @var{ellipsis} is non-@code{nil}, it should be a string which will
2457replace the end of @var{string} when it is truncated. In this case,
2458more characters will be removed from @var{string} to free enough space
2459for @var{ellipsis} to fit within @var{max-pixels} pixels. However, if
2460the pixel width of @var{string} is less than the pixel width of
2461@var{ellipsis}, @var{ellipsis} will not be appended to the result. If
2462@var{ellipsis} is non-@code{nil} and not a string, it stands for the
2463value returned by the function @code{truncate-string-ellipsis},
2464described above.
2465
2466If @var{ellipsis-pixels} is non-@code{nil} and @var{ellipsis} is
2467non-@code{nil}, it should be the number of pixels of @var{ellipsis} that
2468you should precompute using @code{string-pixel-width}, specifying the
2469same buffer. This is useful to avoid the cost of recomputing this value
2470repeatedly when you have many strings to truncate using the same
2471ellipsis string.
2472
2473See also the function @code{truncate-string-to-width} for
2474character-level resolution.
2475@end defun
2476
2443@defun line-pixel-height 2477@defun line-pixel-height
2444This function returns the height in pixels of the line at point in the 2478This function returns the height in pixels of the line at point in the
2445selected window. The value includes the line spacing of the line 2479selected window. The value includes the line spacing of the line
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index c64ec3ea715..5444cea7fa9 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -674,6 +674,7 @@ variable; these two uses of a symbol are independent and do not
674conflict. (This is not the case in some dialects of Lisp, like 674conflict. (This is not the case in some dialects of Lisp, like
675Scheme.) 675Scheme.)
676 676
677@cindex internal functions, naming conventions
677 By convention, if a function's symbol consists of two names 678 By convention, if a function's symbol consists of two names
678separated by @samp{--}, the function is intended for internal use and 679separated by @samp{--}, the function is intended for internal use and
679the first part names the file defining the function. For example, a 680the first part names the file defining the function. For example, a
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 2214a30c170..13a8ec46a8a 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -5026,7 +5026,7 @@ should return the @var{offset} to use to indent @var{arg} itself.
5026@item 5026@item
5027@code{:elem}, in which case the function should return either the offset 5027@code{:elem}, in which case the function should return either the offset
5028to use to indent function arguments (if @var{arg} is the symbol 5028to use to indent function arguments (if @var{arg} is the symbol
5029@code{arg}) or the basic indentation step (if @var{arg} is the symbol 5029@code{args}) or the basic indentation step (if @var{arg} is the symbol
5030@code{basic}). 5030@code{basic}).
5031@item 5031@item
5032@code{:list-intro}, in which case @var{arg} is a token and the function 5032@code{:list-intro}, in which case @var{arg} is a token and the function
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index f5ca6efa21b..ccc0f69a12d 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -35,6 +35,7 @@ terminal and the screen.
35* Session Management:: Saving and restoring state with X Session Management. 35* Session Management:: Saving and restoring state with X Session Management.
36* Desktop Notifications:: Desktop notifications. 36* Desktop Notifications:: Desktop notifications.
37* System Taskbar:: Controlling system GUI taskbar features. 37* System Taskbar:: Controlling system GUI taskbar features.
38* System Sleep:: Block system sleep and process sleep events.
38* File Notifications:: File notifications. 39* File Notifications:: File notifications.
39* Dynamic Libraries:: On-demand loading of support libraries. 40* Dynamic Libraries:: On-demand loading of support libraries.
40* Security Considerations:: Running Emacs in an unfriendly environment. 41* Security Considerations:: Running Emacs in an unfriendly environment.
@@ -2285,7 +2286,7 @@ be protected by wrapping the timer function body with
2285 2286
2286@lisp 2287@lisp
2287@group 2288@group
2288(ignore-error 'remote-file-error 2289(ignore-error remote-file-error
2289 @dots{}) 2290 @dots{})
2290@end group 2291@end group
2291@end lisp 2292@end lisp
@@ -3493,6 +3494,75 @@ Examples of system taskbar functions:
3493@end group 3494@end group
3494@end lisp 3495@end lisp
3495 3496
3497@node System Sleep
3498@section Block System Sleep and Process Sleep Events
3499@cindex system sleep
3500@cindex mode, system sleep
3501
3502@defun system-sleep-block-sleep &optional why allow-display-sleep
3503This function blocks the system from entering its idle sleep state.
3504
3505It returns a token that must be passed to
3506@code{system-sleep-unblock-sleep} to unblock this specific block (other
3507sleep blocks may be simultaneously in force for other purposes).
3508Otherwise, it returns @code{nil} if the sleep blocking fails.
3509
3510@var{why} is a string and, when non-@code{nil}, is used to identify the
3511sleep block as it may appear on the system's inspectable block lists.
3512It defaults to @samp{Emacs}.
3513
3514If @var{allow-display-sleep} is non-@code{nil}, allow the display to
3515sleep. By default, the display is kept active.
3516
3517Note that when the Emacs process terminates, blocks are released on all
3518platforms.
3519@end defun
3520
3521@defun system-sleep-unblock-sleep token
3522This function unblocks the sleep block associated with @var{token}. It
3523returns non-@code{nil} on success, otherwise it returns @code{nil}.
3524@end defun
3525
3526@defmac with-system-sleep-block (&optional why allow-display-sleep) body@dots{}
3527This is a convenience macro that lets you wrap the forms in @var{body}
3528with a sleep block that is unblocked for you when @var{body} completes.
3529This guarantees that the system will never go to sleep while @var{body}
3530executes. The arguments have the same meaning as in
3531@code{system-sleep-block-sleep}, above.
3532@end defmac
3533
3534@defun system-sleep-sleep-blocked-p
3535This predicate function returns non-@code{nil} if there are any
3536active @code{system-sleep} blocks, otherwise it returns @code{nil}.
3537@end defun
3538
3539@defun system-sleep-unblock-all-sleep-blocks
3540This function unblocks all active sleep blocks. It is unlikely that you
3541will need to call this function.
3542@end defun
3543
3544@defopt system-sleep-event-functions
3545When the system is about to enter a sleep state or after it wakes from
3546one, each function on this abnormal hook is called with one argument,
3547@var{event}, a sleep event. Its state can be retrieved via
3548@samp{@code{(sleep-event-state event)}}. State will be one of the
3549symbols @code{pre-sleep} or @code{post-wake}.
3550
3551Handling @code{pre-sleep} events should be done as fast as possible and
3552avoid user prompting. Systems often grant a very short pre-sleep
3553processing interval, typically ranging between 2 and 5 seconds. The
3554system may sleep even if your processing is not complete, so be sure you
3555do as little as possible. For example, your function could close active
3556connections or serial ports.
3557
3558Handling @code{post-wake} events offers more leeway. Use this, for
3559example, to reestablish connections.
3560
3561Note: Your code, or the functions it calls, should not raise any signals
3562or all hooks will be halted. You can wrap your code in a
3563@code{condition-case} block (@pxref{Errors}).
3564@end defopt
3565
3496@node File Notifications 3566@node File Notifications
3497@section Notifications on File Changes 3567@section Notifications on File Changes
3498@cindex file notifications 3568@cindex file notifications
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi
index 4de739aa915..afee255346c 100644
--- a/doc/lispref/sequences.texi
+++ b/doc/lispref/sequences.texi
@@ -1110,9 +1110,9 @@ instead of the default @code{equal}.
1110@cindex sequences, intersection of 1110@cindex sequences, intersection of
1111@cindex intersection of sequences 1111@cindex intersection of sequences
1112 This function returns a copy of @var{sequence1} from which the 1112 This function returns a copy of @var{sequence1} from which the
1113elements that appear in @var{sequence2} where removed. If the optional 1113elements that do not appear in @var{sequence2} were removed. If the
1114argument @var{function} is non-@code{nil}, it is a function of two 1114optional argument @var{function} is non-@code{nil}, it is a function of
1115arguments to use to compare elements instead of the default 1115two arguments to use to compare elements instead of the default
1116@code{equal}. 1116@code{equal}.
1117 1117
1118@example 1118@example
@@ -1125,10 +1125,11 @@ arguments to use to compare elements instead of the default
1125 1125
1126 1126
1127@defun seq-difference sequence1 sequence2 &optional function 1127@defun seq-difference sequence1 sequence2 &optional function
1128 This function returns a list of the elements that appear in 1128 This function returns a copy of @var{sequence1} from which the
1129@var{sequence1} but not in @var{sequence2}. If the optional argument 1129elements that appear in @var{sequence2} were removed. If the optional
1130@var{function} is non-@code{nil}, it is a function of two arguments to 1130argument @var{function} is non-@code{nil}, it is a function of two
1131use to compare elements instead of the default @code{equal}. 1131arguments to use to compare elements instead of the default
1132@code{equal}.
1132 1133
1133@example 1134@example
1134@group 1135@group
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 44be529d562..d073d3ffe2f 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -281,6 +281,17 @@ another string, alter a constant string in the program, or even raise
281an error. To obtain a string that you can safely mutate, use 281an error. To obtain a string that you can safely mutate, use
282@code{copy-sequence} on the result. 282@code{copy-sequence} on the result.
283 283
284If you need to create a string made from @var{n} copies of a given
285source string @var{source}, you can use @code{concat} as follows:
286
287@lisp
288 (apply #'concat (make-list @var{n} @var{source}))
289@end lisp
290
291@noindent
292This uses the fact that @code{concat} can take any kind of sequence as
293its arguments.
294
284For information about other concatenation functions, see the 295For information about other concatenation functions, see the
285description of @code{mapconcat} in @ref{Mapping Functions}, 296description of @code{mapconcat} in @ref{Mapping Functions},
286@code{vconcat} in @ref{Vector Functions}, and @code{append} in @ref{Building 297@code{vconcat} in @ref{Vector Functions}, and @code{append} in @ref{Building
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 29a272eec92..e89b28eb0c0 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -617,6 +617,8 @@ float-pi
617 617
618@node Tips for Defining 618@node Tips for Defining
619@section Tips for Defining Variables Robustly 619@section Tips for Defining Variables Robustly
620@cindex variables, naming conventions
621@cindex naming conventions, variables
620 622
621 When you define a variable whose value is a function, or a list of 623 When you define a variable whose value is a function, or a list of
622functions, use a name that ends in @samp{-function} or 624functions, use a name that ends in @samp{-function} or
@@ -659,6 +661,7 @@ The value is a whole shell command.
659@item @dots{}-switches 661@item @dots{}-switches
660The value specifies options for a command. 662The value specifies options for a command.
661 663
664@cindex internal variables, naming conventions
662@item @var{prefix}--@dots{} 665@item @var{prefix}--@dots{}
663The variable is intended for internal use and is defined in the file 666The variable is intended for internal use and is defined in the file
664@file{@var{prefix}.el}. (Emacs code contributed before 2018 may 667@file{@var{prefix}.el}. (Emacs code contributed before 2018 may
@@ -2653,6 +2656,19 @@ This macro returns the connection-local value of @var{symbol} for
2653 2656
2654If @var{symbol} does not have a connection-local 2657If @var{symbol} does not have a connection-local
2655binding, the value is the default binding of the variable. 2658binding, the value is the default binding of the variable.
2659
2660The difference to @code{with-connection-local@{-application@}-variables}
2661is, that @code{symbol} is not set buffer-local. A typical usage pattern
2662is to use only the the connection value of a variable if it exists, and
2663not to use its default value otherwise (using @code{my-app-variable}
2664initialized above):
2665
2666@lisp
2667(if (connection-local-p my-app-variable 'my-app)
2668 (connection-local-value my-app-variable 'my-app)
2669 ;; Something else.
2670 )
2671@end lisp
2656@end defmac 2672@end defmac
2657 2673
2658@defvar enable-connection-local-variables 2674@defvar enable-connection-local-variables