aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/emacs/calendar.texi318
-rw-r--r--doc/emacs/custom.texi109
-rw-r--r--doc/emacs/emacs.texi9
-rw-r--r--doc/emacs/files.texi3
-rw-r--r--doc/emacs/maintaining.texi41
-rw-r--r--doc/emacs/package.texi11
-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
-rw-r--r--doc/misc/dbus.texi151
-rw-r--r--doc/misc/tramp.texi10
-rw-r--r--doc/misc/widget.texi14
18 files changed, 657 insertions, 216 deletions
diff --git a/doc/emacs/calendar.texi b/doc/emacs/calendar.texi
index d57d0b442f9..957cfbd9d8f 100644
--- a/doc/emacs/calendar.texi
+++ b/doc/emacs/calendar.texi
@@ -1005,7 +1005,7 @@ entries.
1005* Adding to Diary:: Commands to create diary entries. 1005* Adding to Diary:: Commands to create diary entries.
1006* Special Diary Entries:: Anniversaries, blocks of dates, cyclic entries, etc. 1006* Special Diary Entries:: Anniversaries, blocks of dates, cyclic entries, etc.
1007* Appointments:: Reminders when it's time to do something. 1007* Appointments:: Reminders when it's time to do something.
1008* Importing Diary:: Converting diary events to/from other formats. 1008* Diary Conversion:: Converting diary events to/from other formats.
1009@end menu 1009@end menu
1010 1010
1011@node Format of Diary File 1011@node Format of Diary File
@@ -1549,71 +1549,287 @@ clock. The command @kbd{M-x appt-add} adds entries to the appointment
1549list without affecting your diary file. You delete entries from the 1549list without affecting your diary file. You delete entries from the
1550appointment list with @kbd{M-x appt-delete}. 1550appointment list with @kbd{M-x appt-delete}.
1551 1551
1552@node Importing Diary 1552@node Diary Conversion
1553@subsection Importing and Exporting Diary Entries 1553@subsection Importing and Exporting Diary Entries
1554@cindex importing diary entries 1554@cindex diary import
1555@cindex diary export
1555 1556
1556 You can transfer diary entries between Emacs diary files and a 1557You can transfer diary entries between Emacs diary files and other
1557variety of other formats. 1558formats.
1558 1559
1559@vindex diary-outlook-formats 1560@menu
1560 You can import diary entries from Outlook-generated appointment 1561* Diary iCalendar Import:: Importing iCalendar data to the Diary.
1561messages. While viewing such a message in Rmail or Gnus, do @kbd{M-x 1562* Diary iCalendar Display:: Displaying iCalendar data without importing.
1562diary-from-outlook} to import the entry. You can make this command 1563* Diary iCalendar Export:: Exporting Diary entries to iCalendar.
1563recognize additional appointment message formats by customizing the 1564* Diary Outlook Import:: Importing Outlook appointments to the Diary.
1564variable @code{diary-outlook-formats}. Other mail clients can set 1565@end menu
1565@code{diary-from-outlook-function} to an appropriate value. 1566
1567@node Diary iCalendar Import
1568@subsubsection Importing iCalendar data as Diary Entries
1569@cindex import iCalendar to diary
1570
1571@cindex iCalendar support in diary
1572 @dfn{iCalendar} is an Internet standard format for exchanging calendar
1573data. Many calendar applications can export and import data in
1574iCalendar format. iCalendar data is also often sent as email
1575attachments. iCalendar data usually uses the @file{.ics} file
1576extension, and is sent with the `text/calendar' @acronym{MIME} type in
1577email. (@xref{Mail Misc}, for more information on @acronym{MIME} and
1578email attachments.)
1579
1580The @code{diary-icalendar} package allows you to make use of iCalendar
1581data with the Emacs diary. You can import and export data between
1582iCalendar format and your Emacs diary file, and also display iCalendar
1583data directly in the diary.
1584
1585The following commands will import iCalendar data to your diary file:
1566 1586
1567@c FIXME the name of the RFC is hardly very relevant. 1587@ftable @code
1568@cindex iCalendar support 1588@item diary-icalendar-import-file
1569 The icalendar package allows you to transfer data between your Emacs 1589Imports an iCalendar file to an Emacs diary file.
1570diary file and iCalendar files, which are defined in @cite{RFC 1590
15712445---Internet Calendaring and Scheduling Core Object Specification 1591@item diary-icalendar-import-buffer
1572(iCalendar)} (as well as the earlier vCalendar format). 1592Imports iCalendar data from the current buffer to an Emacs diary file.
1573 1593@end ftable
1574@c Importing works for ordinary (i.e., non-recurring) events, but 1594
1575@c (at present) may not work correctly (if at all) for recurring events. 1595@code{diary-icalendar-import-buffer} is also suitable for importing
1576@c Exporting of diary files into iCalendar files should work correctly 1596iCalendar data from email attachments. For example, with the Rmail mail
1577@c for most diary entries. This feature is a work in progress, so the 1597client, you could use:
1578@c commands may evolve in future.
1579
1580@findex icalendar-import-buffer
1581 The command @code{icalendar-import-buffer} extracts
1582iCalendar data from the current buffer and adds it to your
1583diary file. This function is also suitable for automatic extraction of
1584iCalendar data; for example with the Rmail mail client one could use:
1585 1598
1586@example 1599@example
1587(add-hook 'rmail-show-message-hook 'icalendar-import-buffer) 1600(add-hook 'rmail-show-message-hook #'diary-icalendar-import-buffer)
1588@end example 1601@end example
1589 1602
1590@findex icalendar-import-file 1603Diary import depends on a number of user-customizable variables, which
1591 The command @code{icalendar-import-file} imports an iCalendar file 1604are in the @code{diary-icalendar-import} customization group. You can
1592and adds the results to an Emacs diary file. For example: 1605review and customize these variables with @kbd{M-x customize-group}.
1606@xref{Customization Groups}.
1607
1608iCalendar data is grouped into @dfn{components} which represent calendar
1609events (the VEVENT component), tasks (VTODO), and other text data
1610(VJOURNAL). Because these components contain different types of data,
1611they are imported by different functions, determined by the following
1612variables:
1613
1614@vtable @code
1615@item diary-icalendar-vevent-format-function
1616Function to format VEVENT components for the diary.
1617
1618@item diary-icalendar-vjournal-format-function
1619Function to format VJOURNAL components for the diary.
1620
1621@item diary-icalendar-vtodo-format-function
1622Function to format VTODO components for the diary.
1623@end vtable
1624
1625You can customize the format of the imported diary entries by writing
1626your own formatting functions. It is convenient (but not required) to
1627express such functions as templates called @dfn{skeletons}.
1628@ifinfo
1629@xref{Top, Autotyping, The Autotype Manual, autotype}, for more about
1630skeletons.
1631@end ifinfo
1632
1633For example, suppose you only want to import the date, time, summary,
1634and location of each calendar event, and to write them on a single line
1635like:
1593 1636
1594@example 1637@example
1595(icalendar-import-file "/here/is/calendar.ics" 16382025/11/11 Summary @@ Some Location
1596 "/there/goes/ical-diary")
1597@end example 1639@end example
1598 1640
1599@noindent 1641@noindent
1600You can use an @code{#include} directive to add the import file contents 1642Then you could write the import formatting function as a skeleton and
1601to the main diary file, if these are different files. 1643set it to the value of @code{diary-icalendar-vevent-format-function} as
1602@iftex 1644follows:
1603@xref{Fancy Diary Display,,, emacs-xtra, Specialized Emacs Features}. 1645
1604@end iftex 1646@lisp
1605@ifnottex 1647@group
1606@xref{Fancy Diary Display}. 1648(require 'skeleton)
1607@end ifnottex 1649
1650(defun simple-vevent (_)
1651 "Format a VEVENT summary and location on a single line"
1652 (skeleton-insert
1653 '(nil
1654 ical-start-to-end & " " & ical-summary & " "
1655 (when ical-location "@@ ") & ical-location "\n")))
1656
1657(setopt diary-icalendar-vevent-format-function #'simple-vevent)
1658@end group
1659@end lisp
1660
1661The variables @code{ical-start-to-end}, @code{ical-summary} and
1662@code{ical-location} in this example are dynamically bound to
1663appropriate values when the skeleton is called. See the docstring of
1664@code{diary-icalendar-vevent-format-function} for more information.
1665
1666Any errors encountered during import will be reported in a buffer named
1667@file{*icalendar-errors*}. You can review these errors with the
1668@code{next-error} command. @xref{Compilation Mode}. If you regularly
1669need to import malformed iCalendar data, there are several hooks
1670available for this purpose; see the @code{icalendar-parser}
1671customization group.
1672
1673@node Diary iCalendar Display
1674@subsubsection Displaying iCalendar entries in the Diary
1675@cindex display iCalendar in diary
1676
1677If you primarily store your calendar data outside of Emacs, but still
1678want to see it in the Emacs calendar and diary, you can do so by
1679including an iCalendar file from your diary file.
1680
1681Suppose, for example, that you download your calendar from an
1682external server to a file called @file{Appointments.ics}. Then you can
1683include this file in your diary by writing a line like
1608 1684
1685@example
1686#include "path/to/Appointments.ics"
1687@end example
1688
1689@noindent
1690in your diary file. You must also set up some hooks to display the
1691data in that file as diary entries and mark them in the calendar:
1692
1693@lisp
1694@group
1695(add-hook 'diary-mark-entries-hook
1696 #'diary-mark-included-diary-files)
1697(add-hook 'diary-nongregorian-marking-hook
1698 #'diary-icalendar-mark-entries)
1699(add-hook 'diary-list-entries-hook
1700 #'diary-include-other-diary-files)
1701(add-hook 'diary-nongregorian-listing-hook
1702 #'diary-icalendar-display-entries)
1703@end group
1704@end lisp
1705
1706@noindent
1707Events, tasks, and journal entries in @file{Appointments.ics} will then show
1708up on the appropriate days when you display the diary from the calendar.
1709@xref{Displaying the Diary}.
1710
1711The advantage of doing this is that you don't need to synchronize the
1712data between the calendar server and your diary file. This is simpler
1713and more reliable than regularly importing and exporting between diary
1714and iCalendar format.
1715
1716@findex diary-icalendar-mailcap-viewer
1717 You can also display iCalendar attachments in email messages
1718without importing them to your diary file using the function
1719@code{diary-icalendar-mailcap-viewer}. You can add this function, for
1720example, to the variable @code{mailcap-user-mime-data}; see its docstring
1721for more information.
1722
1723Displaying iCalendar entries uses the same infrastructure as importing
1724them, so customizing the import format will also change the format of
1725the displayed entries. @xref{Diary iCalendar Import}.
1726
1727@node Diary iCalendar Export
1728@subsubsection Exporting Diary Entries to iCalendar
1729@cindex export diary to iCalendar
1730
1731The following commands will export diary entries in iCalendar format:
1732
1733@ftable @code
1734@item diary-icalendar-export-file
1735Exports a diary file to iCalendar format.
1736
1737@item diary-icalendar-export-region
1738Exports a region of diary text to iCalendar format.
1739@end ftable
1740
1741iCalendar export depends on a number of user-customizable variables, which
1742are in the @code{diary-icalendar-export} customization group. You can
1743review and customize these variables with @kbd{M-x customize-group}.
1744@xref{Customization Groups}.
1745
1746Exporting diary entries to iCalendar requires you to respect certain
1747conventions in your diary, so that iCalendar properties can be parsed
1748from your diary entries.
1749
1750By default, the exporter will use the first line of the entry (after the
1751date and time) as the iCalendar summary and the rest of the entry as its
1752iCalendar description. Other iCalendar properties can also be encoded in
1753the entry on separate lines, like this:
1754
1755@example
1756@group
17572025/11/11 Bender's birthday bash
1758 Location: Robot House
1759 Attendees:
1760 Fry <philip.fry@@mars.edu>
1761 Günter <guenter@@mars.edu>
1762@end group
1763@end example
1764
1765@noindent
1766This format matches the format produced by the default import
1767functions.
1768
1769@vindex diary-icalendar-address-regexp
1770@vindex diary-icalendar-class-regexp
1771@vindex diary-icalendar-description-regexp
1772@vindex diary-icalendar-location-regexp
1773@vindex diary-icalendar-organizer-regexp
1774@vindex diary-icalendar-status-regexp
1775@vindex diary-icalendar-summary-regexp
1776@vindex diary-icalendar-todo-regexp
1777@vindex diary-icalendar-uid-regexp
1778@vindex diary-icalendar-url-regexp
1779If you customize the import format, or you want to export diary entries
1780in a different format, you will need to customize the export variables
1781to detect the format of your diary entries. The most common iCalendar
1782properties are parsed from diary entries using regular expressions. See
1783the variables named @code{diary-icalendar-*-regexp} in the
1784@code{diary-icalendar-export} customization group to modify how these
1785properties are parsed.
1786
1787@vindex diary-icalendar-other-properties-parser
1788 If you need to export other iCalendar properties, or do more
1789complicated parsing, you can define a function to do so and set it as
1790the value of the variable @code{diary-icalendar-other-properties-parser};
1791see its docstring for details.
1792
1793@vindex diary-icalendar-export-linewise
1794 By default, the exporter assumes that each diary entry represents a
1795single iCalendar event. If you like to keep your diary in a
1796one-entry-per-day format, with different events on continuation
1797lines within the same entry, you can still export such entries as
1798distinct iCalendar events. To do this, set the variable
1799@code{diary-icalendar-export-linewise} to a non-nil value.
1800
1801For example, after setting this variable, an entry like:
1802
1803@example
1804@group
18052025-05-03
1806 9AM Lab meeting
1807 Günter to present on new assay
1808 Start experiment A
1809 12:30-1:30PM Lunch with Phil
1810 16:00 Experiment A finishes; move to freezer
1811@end group
1812@end example
1813
1814@noindent
1815will be exported as four events, each on the same day, but with
1816different start times (except for the second event, ``Start experiment
1817A'', which has no start time). See the docstring of
1818@code{diary-icalendar-export-linewise} for more information.
1819
1820@node Diary Outlook Import
1821@subsubsection Importing Outlook appointments as Diary Entries
1822@cindex diary outlook import
1823
1824@vindex diary-outlook-formats
1825@vindex diary-from-outlook-function
1826 You can also import diary entries from Outlook-generated appointment
1827messages. While viewing such a message in Rmail or Gnus, do @kbd{M-x
1828diary-from-outlook} to import the entry. You can make this command
1829recognize additional appointment message formats by customizing the
1830variable @code{diary-outlook-formats}. Other mail clients can set
1831@code{diary-from-outlook-function} to an appropriate value.
1609 1832
1610@findex icalendar-export-file
1611@findex icalendar-export-region
1612@cindex export diary
1613 Use @code{icalendar-export-file} to interactively export an entire
1614Emacs diary file to iCalendar format. To export only a part of a diary
1615file, mark the relevant area, and call @code{icalendar-export-region}.
1616In both cases, Emacs appends the result to the target file.
1617 1833
1618@node Daylight Saving 1834@node Daylight Saving
1619@section Daylight Saving Time 1835@section Daylight Saving Time
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index 7663e2b21df..b2fcb3c489f 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -1615,24 +1615,30 @@ your preference, such as @code{ws-butler-mode}.
1615@cindex per-connection local variables 1615@cindex per-connection local variables
1616 1616
1617 Most of the variables reflect the situation on the local machine. 1617 Most of the variables reflect the situation on the local machine.
1618Often, they must use a different value when you operate in buffers 1618Often, they must use a different value when you operate in buffers with
1619with a remote default directory. Think about the behavior when 1619a remote default directory. Think about the behavior when calling
1620calling @code{shell} -- on your local machine, you might use 1620@code{shell} --- on your local machine, you might use @file{/bin/bash}
1621@file{/bin/bash} and rely on termcap, but on a remote machine, it may 1621and rely on termcap, but on a remote machine, it may be @file{/bin/ksh}
1622be @file{/bin/ksh} and terminfo. 1622and terminfo.
1623 1623
1624 This can be accomplished with @dfn{connection-local variables}. 1624 This can be accomplished with @dfn{connection-local variables}. Such
1625Directory and file local variables override connection-local 1625variables are declared depending on the value of
1626variables. Unsafe connection-local variables are handled in the same 1626@code{default-directory} of the current buffer. When a buffer has a
1627way as unsafe file-local variables (@pxref{Safe File Variables}). 1627remote @code{default-directory}, and there exist a connection-local
1628variable which matches @code{default-directory}, this alternative value
1629of the variable is used. Directory and file local variables override
1630connection-local variables. Unsafe connection-local variables are
1631handled in the same way as unsafe file-local variables (@pxref{Safe File
1632Variables}).
1628 1633
1629@findex connection-local-set-profile-variables 1634@findex connection-local-set-profile-variables
1630@findex connection-local-set-profiles 1635@findex connection-local-set-profiles
1631 Connection-local variables are declared as a group of 1636 Connection-local variables are declared as a group of variables/value
1632variables/value pairs in a @dfn{profile}, using the 1637pairs in a @dfn{profile}, using the
1633@code{connection-local-set-profile-variables} function. The function 1638@code{connection-local-set-profile-variables} function. The function
1634@code{connection-local-set-profiles} activates profiles for a given 1639@code{connection-local-set-profiles} declares profiles for a given
1635criteria, identifying a remote machine: 1640criteria (the first argument), identifying a remote machine with respect
1641to @code{default-directory} of the current buffer:
1636 1642
1637@example 1643@example
1638(connection-local-set-profile-variables 'remote-terminfo 1644(connection-local-set-profile-variables 'remote-terminfo
@@ -1654,12 +1660,46 @@ criteria, identifying a remote machine:
1654 1660
1655 This code declares three different profiles, @code{remote-terminfo}, 1661 This code declares three different profiles, @code{remote-terminfo},
1656@code{remote-ksh}, and @code{remote-bash}. The profiles 1662@code{remote-ksh}, and @code{remote-bash}. The profiles
1657@code{remote-terminfo} and @code{remote-ksh} are applied to all 1663@code{remote-terminfo} and @code{remote-ksh} are applied to all buffers
1658buffers which have a remote default directory matching the regexp 1664which have a remote @code{default-directory} matching the string
1659@code{"remotemachine"} as host name. Such a criteria can also 1665@code{"remotemachine"} as host name.
1660discriminate for the properties @code{:protocol} (this is the Tramp 1666
1661method) or @code{:user} (a remote user name). The @code{nil} criteria 1667 Criteria, the first argument of @code{connection-local-set-profiles},
1662matches all buffers with a remote default directory. 1668specifies, how the profiles match @code{default-directory}. It is a
1669plist identifying a connection and the application using this
1670connection. Property names might be @code{:application},
1671@code{:protocol}, @code{:user} and @code{:machine}. The property value
1672of @code{:application} is a symbol, all other property values are
1673strings. In general the symbol @code{tramp} should be used as
1674@code{:application} value. Some packages use a different
1675@code{:application} (for example @code{eshell} or @code{vc-git}); they
1676say it in their documentation then. All properties are optional.
1677
1678 The other properties are used for checking @code{default-directory}.
1679The propertiy @code{:protocol} is used for the method a remote
1680@code{default-directory} uses, the property
1681@code{:user} is the remote user name, and the property @code{:machine}
1682is the remote host name. All checks are performed via
1683@code{string-equal}. The @code{nil} criteria matches all buffers
1684with a remote default directory.
1685
1686 Connection-local variables are not activated by default. A package
1687which uses connection-local variables must activate them for a given
1688buffer, specifying for which @code{:application} it uses them.
1689@xref{Applying Connection Local Variables,,, elisp, The Emacs Lisp
1690Reference Manual}, for details.
1691
1692 After the above definition of profiles and their activation, any
1693connection made by Tramp to the @samp{remotemachine} system will use
1694
1695@itemize
1696@item @code{t} as the connection-specific value of @code{system-uses-terminfo},
1697@item @samp{dumb-emacs-ansi} as the connection-specific value of
1698@code{comint-terminfo-terminal},
1699@item @samp{/bin/ksh} as the connection-specific value of as
1700@code{shell-file-name},
1701@item @samp{-c} as the connection-specific value of @code{shell-command-switch}.
1702@end itemize
1663 1703
1664 Be careful when declaring different profiles with the same variable, 1704 Be careful when declaring different profiles with the same variable,
1665and setting these profiles to criteria which could match in parallel. 1705and setting these profiles to criteria which could match in parallel.
@@ -3098,30 +3138,33 @@ elisp, The Emacs Lisp Reference Manual}.
3098 If the directory specified by @code{user-lisp-directory}, defaulting 3138 If the directory specified by @code{user-lisp-directory}, defaulting
3099to @file{~/.config/emacs/user-lisp/} or @file{~/.emacs.d/user-lisp/}, 3139to @file{~/.config/emacs/user-lisp/} or @file{~/.emacs.d/user-lisp/},
3100exists, then at startup Emacs will prepare Lisp files within that 3140exists, then at startup Emacs will prepare Lisp files within that
3101directory for use in the session. Emacs does the following things: 3141directory for use in the session. Specifically, Emacs does the
3142following:
3102 3143
3103@itemize 3144@itemize
3104@item 3145@item
3105Gather and activate autoload cookies. This means that you can use 3146Gather and activate autoload cookies. This means that you can use
3106autoloaded commands and other entry points for the files in your 3147autoloaded commands and other entry points for the files in your
3107@code{user-lisp-directory} without explicitly loading any of the 3148@code{user-lisp-directory} without explicitly loading any of the
3108files in your initialization file. (@pxref{Autoload,,, elisp, The 3149files in your initialization file. @xref{Autoload,,, elisp, The
3109Emacs Lisp Reference Manual}.) 3150Emacs Lisp Reference Manual}.
3110@item 3151@item
3111Byte-compile all files, and if supported on your system, natively 3152Byte-compile all the files (@pxref{Byte Compilation,,, elisp, The Emacs
3112compile them too. This speeds up the execution of the code in the 3153Lisp Reference Manual}), and if supported by your build of Emacs,
3113files when they are loaded. (@pxref{Byte Compilation,,, elisp, The 3154compile them to native code as well (@pxref{Native Compilation,,, elisp,
3114Emacs Lisp Reference Manual}.) 3155The Emacs Lisp Reference Manual}). This speeds up the execution of the
3156code in those files when they are loaded and when they are executed
3157later.
3115@item 3158@item
3116Adjust @code{load-path} such that all the files can be loaded and 3159Adjust @code{load-path} such that all the files can be loaded and
3117autoloaded in the usual ways. (@pxref{Library Search,,, elisp, The 3160autoloaded in the usual ways. @xref{Library Search,,, elisp, The
3118Emacs Lisp Reference Manual}.) 3161Emacs Lisp Reference Manual}.
3119@end itemize 3162@end itemize
3120 3163
3121 The User Lisp directory is processed before loading the @ref{Init 3164 The User Lisp directory is processed before loading your init file
3122File} file. Therefore any customizations to the user options discussed 3165(@pxref{Init File}). Therefore any customizations to the user
3123below must be made in your early init file (@pxref{Early Init File}) in 3166options discussed below must be made in your early init file
3124order to have any effect. 3167(@pxref{Early Init File}) in order to have any effect.
3125 3168
3126@vindex user-lisp-ignored-directories 3169@vindex user-lisp-ignored-directories
3127@vindex user-lisp-auto-scrape 3170@vindex user-lisp-auto-scrape
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index 49a3ba57b1c..05ced62dd9c 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -1020,7 +1020,14 @@ The Diary
1020* Adding to Diary:: Commands to create diary entries. 1020* Adding to Diary:: Commands to create diary entries.
1021* Special Diary Entries:: Anniversaries, blocks of dates, cyclic entries, etc. 1021* Special Diary Entries:: Anniversaries, blocks of dates, cyclic entries, etc.
1022* Appointments:: Reminders when it's time to do something. 1022* Appointments:: Reminders when it's time to do something.
1023* Importing Diary:: Converting diary events to/from other formats. 1023* Diary Conversion:: Converting diary events to/from other formats.
1024
1025Diary Conversion
1026
1027* Diary iCalendar Import:: Importing iCalendar data to the Diary.
1028* Diary iCalendar Display:: Displaying iCalendar data without importing.
1029* Diary iCalendar Export:: Exporting Diary entries to iCalendar.
1030* Diary Outlook Import:: Importing Outlook appointments to the Diary.
1024 1031
1025@ifnottex 1032@ifnottex
1026More advanced features of the Calendar and Diary 1033More advanced features of the Calendar and Diary
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 567c1492518..a9bcee0b060 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1835,7 +1835,8 @@ the start of the @var{n}th previous file.
1835 1835
1836@findex diff-hunk-kill 1836@findex diff-hunk-kill
1837@item M-k 1837@item M-k
1838Kill the hunk at point (@code{diff-hunk-kill}). 1838Kill the hunk at point (@code{diff-hunk-kill}). If the region is
1839active, kills all hunks the region overlaps.
1839 1840
1840@findex diff-file-kill 1841@findex diff-file-kill
1841@item M-K 1842@item M-K
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index aebe31b478e..1d54af130a9 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -2323,6 +2323,11 @@ configuration (if any), excluding the ``ignored'' files from the output.
2323It has some performance optimizations for listing the files with some of 2323It has some performance optimizations for listing the files with some of
2324the popular VCS systems (currently Git and Mercurial). 2324the popular VCS systems (currently Git and Mercurial).
2325 2325
2326@findex project-remember-projects-under
2327It also uses a time-based cache. If the mode line shows stale project
2328information, you can type @kbd{M-x project-remember-projects-under RET}
2329to refresh the stale cached info.
2330
2326@defopt project-vc-include-untracked 2331@defopt project-vc-include-untracked
2327By default, files which are neither registered with nor ignored by the 2332By default, files which are neither registered with nor ignored by the
2328VCS are considered part of the project. Customize this variable to nil 2333VCS are considered part of the project. Customize this variable to nil
@@ -2569,12 +2574,13 @@ files, and build a database of these references. A backend can then
2569access this database whenever it needs to list or look up references. 2574access this database whenever it needs to list or look up references.
2570The Emacs distribution includes @command{etags}, a command for tagging 2575The Emacs distribution includes @command{etags}, a command for tagging
2571identifier definitions in programs, which supports many programming 2576identifier definitions in programs, which supports many programming
2572languages and other major modes, such as HTML, by extracting 2577languages and other major modes, such as HTML, by extracting references
2573references into @dfn{tags tables}. @xref{Create Tags Table}. Major 2578into @dfn{tags tables}. Major modes for languages supported by
2574modes for languages supported by @command{etags} can use tags tables 2579@command{etags} can use tags tables as basis for their backend. Enable
2575as basis for their backend. (One disadvantage of this kind of backend 2580@code{etags-regen-mode} to have tags tables generated across the current
2576is that tags tables need to be kept reasonably up to date, by 2581project for supported file types and updated automatically upon edit.
2577rebuilding them from time to time.) 2582Alternatively, you can build the table manually to control the set of
2583files and when it is updated, see @ref{Create Tags Table}.
2578@end enumerate 2584@end enumerate
2579 2585
2580@menu 2586@menu
@@ -2648,6 +2654,9 @@ to always prompt, customize @code{xref-prompt-for-identifier} to
2648usual minibuffer completion commands (@pxref{Completion}), with the 2654usual minibuffer completion commands (@pxref{Completion}), with the
2649known identifier names being the completion candidates. 2655known identifier names being the completion candidates.
2650 2656
2657 It uses the current Xref backend, and will signal an error when there
2658is none configured, with some recommendations.
2659
2651@kindex C-x 4 . 2660@kindex C-x 4 .
2652@findex xref-find-definitions-other-window 2661@findex xref-find-definitions-other-window
2653@kindex C-x 5 . 2662@kindex C-x 5 .
@@ -3028,7 +3037,9 @@ writes the tags to a @dfn{tags table file}, or @dfn{tags file} in
3028short. The conventional name for a tags file is @file{TAGS}@. 3037short. The conventional name for a tags file is @file{TAGS}@.
3029@xref{Create Tags Table}. (It is also possible to create a tags table 3038@xref{Create Tags Table}. (It is also possible to create a tags table
3030by using one of the commands from other packages that can produce such 3039by using one of the commands from other packages that can produce such
3031tables in the same format.) 3040tables in the same format.) If you enable the @code{etags-regen-mode}
3041global minor mode, Emacs will generate and update the tags tables
3042automatically as needed.
3032 3043
3033 Emacs uses the tags tables via the @code{etags} package as one of 3044 Emacs uses the tags tables via the @code{etags} package as one of
3034the supported backends for @code{xref}. Because tags tables are 3045the supported backends for @code{xref}. Because tags tables are
@@ -3310,6 +3321,10 @@ You should update a tags table when you define new tags that you want
3310to have listed, or when you move tag definitions from one file to 3321to have listed, or when you move tag definitions from one file to
3311another, or when changes become substantial. 3322another, or when changes become substantial.
3312 3323
3324 If the @code{etags-regen-mode} minor mode, described below, is
3325enabled, Emacs will automatically keep the tags tables up-to-date as
3326needed.
3327
3313 You can make a tags table @dfn{include} another tags table, by 3328 You can make a tags table @dfn{include} another tags table, by
3314passing the @samp{--include=@var{file}} option to @command{etags}. It 3329passing the @samp{--include=@var{file}} option to @command{etags}. It
3315then covers all the files covered by the included tags file, as well 3330then covers all the files covered by the included tags file, as well
@@ -3418,11 +3433,11 @@ Command-line options to pass to the program which regenerates tags
3418tables. 3433tables.
3419 3434
3420@item etags-regen-ignores 3435@item etags-regen-ignores
3421List of glob patterns which specify files to ignore when regenerating 3436List of glob wildcard patterns which specify files to ignore when
3422tags tables. 3437regenerating tags tables.
3423@end vtable 3438@end vtable
3424 3439
3425@cindex tags-reset-tags-tables 3440@findex tags-reset-tags-tables
3426 If you select a tags table manually, with @kbd{M-x visit-tags-table} 3441 If you select a tags table manually, with @kbd{M-x visit-tags-table}
3427(@pxref{Select Tags Table}), @code{etags-regen-mode} effectively 3442(@pxref{Select Tags Table}), @code{etags-regen-mode} effectively
3428disables itself: it will no longer automatically create and update 3443disables itself: it will no longer automatically create and update
@@ -3607,6 +3622,12 @@ to the first directory that contains a file named @file{TAGS}
3607encountered when recursively searching upward from the default 3622encountered when recursively searching upward from the default
3608directory. 3623directory.
3609 3624
3625 If you enable the @code{etags-regen-mode} global minor mode, it will
3626automatically find and visit the tags table file when needed. If you
3627then invoke @code{visit-tags-table} manually to select a tags table,
3628@code{etags-regen-mode} will disable automatic regeneration of the tags
3629table. @xref{Create Tags Table}.
3630
3610@vindex tags-file-name 3631@vindex tags-file-name
3611 Emacs does not actually read in the tags table contents until you 3632 Emacs does not actually read in the tags table contents until you
3612try to use them; all @code{visit-tags-table} does is store the file 3633try to use them; all @code{visit-tags-table} does is store the file
diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi
index e6432678c62..fdb0822e85c 100644
--- a/doc/emacs/package.texi
+++ b/doc/emacs/package.texi
@@ -454,6 +454,17 @@ case, Emacs retrieves packages from this archive via ordinary file
454access. Such local archives are mainly useful for testing. 454access. Such local archives are mainly useful for testing.
455@end defopt 455@end defopt
456 456
457@cindex suggestions
458@findex package-autosuggest
459@findex package-autosuggest-mode
460 Emacs has a built-in database of suggested packages for certain file
461types. If Emacs opens a file with no specific mode, you can use the
462@code{package-autosuggest} command to install the recommended packages
463from ELPA. After enabling @code{package-autosuggest-mode}, Emacs will
464display a clickable hint in the mode-line if it there is a suggested
465package. Using the @code{package-autosuggest-style} user option, you
466can adjust how Emacs presents the hint to install a package.
467
457@anchor{Package Signing} 468@anchor{Package Signing}
458@cindex package security 469@cindex package security
459@cindex package signing 470@cindex package signing
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
diff --git a/doc/misc/dbus.texi b/doc/misc/dbus.texi
index 59685087ae8..5b302c883ad 100644
--- a/doc/misc/dbus.texi
+++ b/doc/misc/dbus.texi
@@ -64,7 +64,7 @@ another. An overview of D-Bus can be found at
64* Alternative Buses:: Alternative buses and environments. 64* Alternative Buses:: Alternative buses and environments.
65* Errors and Events:: Errors and events. 65* Errors and Events:: Errors and events.
66* Monitoring Messages:: Monitoring messages. 66* Monitoring Messages:: Monitoring messages.
67* Inhibitor Locks:: Inhibit system shutdowns and sleep states. 67* File Descriptors:: Handle file descriptors.
68* Index:: Index including concepts, functions, variables. 68* Index:: Index including concepts, functions, variables.
69 69
70* GNU Free Documentation License:: The license for this documentation. 70* GNU Free Documentation License:: The license for this documentation.
@@ -1212,7 +1212,7 @@ which carries the input parameters to the object owning the method to
1212be called, and a reply message returning the resulting output 1212be called, and a reply message returning the resulting output
1213parameters from the object. 1213parameters from the object.
1214 1214
1215@defun dbus-call-method bus service path interface method &optional :timeout timeout :authorizable auth &rest args 1215@defun dbus-call-method bus service path interface method &optional :timeout timeout :authorizable auth :keep-fd &rest args
1216@anchor{dbus-call-method} 1216@anchor{dbus-call-method}
1217This function calls @var{method} on the D-Bus @var{bus}. @var{bus} is 1217This function calls @var{method} on the D-Bus @var{bus}. @var{bus} is
1218either the keyword @code{:system} or the keyword @code{:session}. 1218either the keyword @code{:system} or the keyword @code{:session}.
@@ -1245,6 +1245,11 @@ running):
1245@result{} "/org/freedesktop/systemd1/job/17508" 1245@result{} "/org/freedesktop/systemd1/job/17508"
1246@end lisp 1246@end lisp
1247 1247
1248If the parameter @code{:keep-fd} is given, and the return message has a
1249first argument with a D-Bus type @code{:unix-fd}, the returned file
1250descriptor is kept internally, and can be used in a later call of
1251@code{dbus--close-fd} (@pxref{File Descriptors}).
1252
1248The remaining arguments @var{args} are passed to @var{method} as 1253The remaining arguments @var{args} are passed to @var{method} as
1249arguments. They are converted into D-Bus types as described in 1254arguments. They are converted into D-Bus types as described in
1250@ref{Type Conversion}. 1255@ref{Type Conversion}.
@@ -1324,7 +1329,7 @@ emulate the @code{lshal} command on GNU/Linux systems:
1324@cindex method calls, asynchronous 1329@cindex method calls, asynchronous
1325@cindex asynchronous method calls 1330@cindex asynchronous method calls
1326 1331
1327@defun dbus-call-method-asynchronously bus service path interface method handler &optional :timeout timeout :authorizable auth &rest args 1332@defun dbus-call-method-asynchronously bus service path interface method handler &optional :timeout timeout :authorizable auth :keep-fd &rest args
1328This function calls @var{method} on the D-Bus @var{bus} 1333This function calls @var{method} on the D-Bus @var{bus}
1329asynchronously. @var{bus} is either the keyword @code{:system} or the 1334asynchronously. @var{bus} is either the keyword @code{:system} or the
1330keyword @code{:session}. 1335keyword @code{:session}.
@@ -1347,6 +1352,11 @@ If the parameter @code{:authorizable} is given and the following
1347@var{auth} is non-@code{nil}, the invoked method may interactively 1352@var{auth} is non-@code{nil}, the invoked method may interactively
1348prompt the user for authorization. The default is @code{nil}. 1353prompt the user for authorization. The default is @code{nil}.
1349 1354
1355If the parameter @code{:keep-fd} is given, and the return message has a
1356first argument with a D-Bus type @code{:unix-fd}, the returned file
1357descriptor is kept internally, and can be used in a later call of
1358@code{dbus--close-fd} (@pxref{File Descriptors}).
1359
1350The remaining arguments @var{args} are passed to @var{method} as 1360The remaining arguments @var{args} are passed to @var{method} as
1351arguments. They are converted into D-Bus types as described in 1361arguments. They are converted into D-Bus types as described in
1352@ref{Type Conversion}. 1362@ref{Type Conversion}.
@@ -2205,109 +2215,90 @@ switches to the monitor buffer.
2205@end deffn 2215@end deffn
2206 2216
2207 2217
2208@node Inhibitor Locks 2218@node File Descriptors
2209@chapter Inhibit system shutdowns and sleep states 2219@chapter Handle file descriptors
2210
2211@uref{https://systemd.io/INHIBITOR_LOCKS/, Systemd} includes a logic to
2212inhibit system shutdowns and sleep states. It can be controlled by a
2213D-Bus API@footnote{@uref{https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.login1.html}}.
2214Because this API includes handling of file descriptors, not all
2215functions can be implemented by simple D-Bus method calls. Therefore,
2216the following functions are provided.
2217
2218@defun dbus-make-inhibitor-lock what why &optional block
2219This function creates an inhibitor for system shutdowns and sleep states.
2220
2221@var{what} is a colon-separated string of lock types: @samp{shutdown},
2222@samp{sleep}, @samp{idle}, @samp{handle-power-key},
2223@samp{handle-suspend-key}, @samp{handle-hibernate-key},
2224@samp{handle-lid-switch}. Example: @samp{shutdown:idle}.
2225
2226@c@var{who} is a descriptive string of who is taking the lock. If it is
2227@c@code{nil}, it defaults to @samp{Emacs}.
2228 2220
2229@var{why} is a descriptive string of why the lock is taken. Example: 2221Methods offered by the D-Bus API could return a file descriptor, which
2230@samp{Package Update in Progress}. 2222must be handled further. This is indicated by the @code{:keep-fd}
2223parameter when calling the method (@pxref{dbus-call-method}).
2231 2224
2232The optional @var{block} is the mode of the inhibitor lock, either 2225For example, @uref{https://systemd.io/INHIBITOR_LOCKS/, Systemd}
2233@samp{block} (@var{block} is non-@code{nil}), or @samp{delay}. 2226includes a logic to inhibit system shutdowns and sleep states. It can
2234 2227be controlled by a the method @samp{Inhibit} of interface
2235Note, that the @code{who} argument of the inhibitor lock object of the 2228@samp{org.freedesktop.login1.Manager}@footnote{@uref{https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.login1.html}}.
2236systemd manager is always set to the string @samp{Emacs}. 2229This function returns a file descriptor, which must be used to unlock
2237 2230the locked resource, some of which lock the system. In order to keep
2238It returns a file descriptor or @code{nil}, if the lock cannot be 2231this file descriptor internally, the respective D-Bus method call looks
2239acquired. If there is already an inhibitor lock for the triple 2232like (@var{what}, @var{who}, @var{why} and @var{mode} are
2240@code{(WHAT WHY BLOCK)}, this lock is returned. Example: 2233method-specific string arguments)
2241 2234
2242@lisp 2235@lisp
2243(dbus-make-inhibitor-lock "sleep" "Test") 2236(dbus-call-method
2237 :system
2238 "org.freedesktop.login1" "/org/freedesktop/login1"
2239 "org.freedesktop.login1.Manager" "Inhibit"
2240 :keep-fd WHAT WHO WHY MODE)
2244 2241
2245@result{} 25 2242@result{} 25
2246@end lisp 2243@end lisp
2247@end defun
2248 2244
2249@defun dbus-registered-inhibitor-locks 2245The inhibition lock is unlocked, when the returned file descriptor is
2250Return registered inhibitor locks, an alist. 2246removed from the file system. This cannot be achieved on Lisp level.
2251This allows to check, whether other packages of the running Emacs 2247Therefore, there is the function @code{dbus--fd-close} to performs this
2252instance have acquired an inhibitor lock as well. 2248task (see below).
2249
2250@strong{Note}: When the Emacs process itself dies, all such locks are
2251released.
2253 2252
2254An entry in this list is a list @code{(@var{fd} @var{what} @var{why} 2253@strong{Note}: The following functions are internal to the D-Bus
2255@var{block})}. The car of the list is the file descriptor retrieved 2254implementation of Emacs. Use them with care.
2256from a @code{dbus-make-inhibitor-lock} call. The cdr of the list 2255
2257represents the three arguments @code{dbus-make-inhibitor-lock} was 2256@defun dbus--fd-open filename
2258called with. Example: 2257Open @var{filename} and return the respective read-only file descriptor.
2258This is another function to keep a file descriptor internally. The
2259returned file descriptor can be closed by @code{dbus--fd-close}.
2260Example:
2259 2261
2260@lisp 2262@lisp
2261(dbus-registered-inhibitor-locks) 2263(dbus--fd-open "~/.emacs")
2262 2264
2263@result{} ((25 "sleep" "Test" nil)) 2265@result{} 20
2264@end lisp 2266@end lisp
2265@end defun 2267@end defun
2266 2268
2267@defun dbus-close-inhibitor-lock lock 2269@defun dbus--fd-close fd
2268Close inhibitor lock file descriptor. 2270Close file descriptor @var{fd}.
2269 2271@var{fd} must be the result of a @code{dbus-call-method} or
2270@var{lock}, a file descriptor, must be the result of a 2272@code{dbus--fd-open} call, see @code{dbus--registered-fds}. It returns
2271@code{dbus-make-inhibitor-lock} call. It returns @code{t} in case of 2273@code{t} in case of success, or @code{nil} if it isn’t be possible to
2272success, or @code{nil} if it isn't be possible to close the lock, or if 2274close the file descriptor, or if the file descriptor is closed already.
2273the lock is closed already. Example: 2275Example:
2274 2276
2275@lisp 2277@lisp
2276(dbus-close-inhibitor-lock 25) 2278(dbus--fd-close 25)
2277 2279
2278@result{} t 2280@result{} t
2279
2280@end lisp 2281@end lisp
2281@end defun 2282@end defun
2282 2283
2283A typical scenario for these functions is to register for the 2284@defun dbus--registered-fds
2284D-Bus signal @samp{org.freedesktop.login1.Manager.PrepareForSleep}: 2285Return registered file descriptors, an alist.
2286The key is an open file descriptor, retrieved via
2287@code{dbus-call-method} or @code{dbus--open-fd}. The value is a string
2288@var{object-path} or @var{filename}, which represents the arguments the
2289function was called with. Those values are not needed for further
2290operations; they are just shown for information.
2285 2291
2286@lisp 2292This alist allows to check, whether other packages of the running Emacs
2287(defvar my-inhibitor-lock 2293instance have acquired a file descriptor as well. Example:
2288 (dbus-make-inhibitor-lock "sleep" "Test"))
2289 2294
2290(defun my-dbus-PrepareForSleep-handler (start) 2295@lisp
2291 (if start ;; The system goes down for sleep 2296(dbus--registered-fds)
2292 (progn
2293 @dots{}
2294 ;; Release inhibitor lock.
2295 (when (natnump my-inhibitor-lock)
2296 (dbus-close-inhibitor-lock my-inhibitor-lock)
2297 (setq my-inhibitor-lock nil)))
2298 ;; Reacquire inhibitor lock.
2299 (setq my-inhibitor-lock
2300 (dbus-make-inhibitor-lock "sleep" "Test"))))
2301
2302(dbus-register-signal
2303 :system "org.freedesktop.login1" "/org/freedesktop/login1"
2304 "org.freedesktop.login1.Manager" "PrepareForSleep"
2305 #'my-dbus-PrepareForSleep-handler)
2306 2297
2307@result{} ((:signal :system "org.freedesktop.login1.Manager" "PrepareForSleep") 2298@result{} ((20 . "/home/user/.emacs")
2308 ("org.freedesktop.login1" "/org/freedesktop/login1" 2299 (25 . "/org/freedesktop/login1"))
2309 my-dbus-PrepareForSleep-handler))
2310@end lisp 2300@end lisp
2301@end defun
2311 2302
2312 2303
2313@node Index 2304@node Index
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index c916588a060..73c3e1ed326 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -6658,7 +6658,7 @@ root directory, it is most likely sufficient to make the
6658@code{default-directory} of the process buffer as the root directory. 6658@code{default-directory} of the process buffer as the root directory.
6659 6659
6660 6660
6661@subsection Timers, process filters, process sentinels, redisplay 6661@subsection Timers, process filters, process sentinels, special events, redisplay
6662 6662
6663@vindex remote-file-error 6663@vindex remote-file-error
6664Timers run asynchronously at any time when Emacs is waiting for 6664Timers run asynchronously at any time when Emacs is waiting for
@@ -6678,7 +6678,13 @@ wrapping the timer function body as follows:
6678@end lisp 6678@end lisp
6679 6679
6680A similar problem could happen with process filters, process 6680A similar problem could happen with process filters, process
6681sentinels, and redisplay (updating the mode line). 6681sentinels, special event handlers, and redisplay (updating the mode
6682line).
6683
6684@strong{Note} that @value{tramp} raises a @code{remote-file-error}
6685error for any connection-related problem. You can protect against all
6686such problems with the code snippet above (or with a
6687@code{condition-case} form with a @code{remote-file-error} handler).
6682 6688
6683 6689
6684@node Extension packages 6690@node Extension packages
diff --git a/doc/misc/widget.texi b/doc/misc/widget.texi
index 1cdeab5bbaa..b7ce3f7a262 100644
--- a/doc/misc/widget.texi
+++ b/doc/misc/widget.texi
@@ -785,13 +785,19 @@ The following navigation commands are available:
785 785
786@table @kbd 786@table @kbd
787@item @key{TAB} 787@item @key{TAB}
788@deffn Command widget-forward &optional count 788@deffn Command widget-forward count &optional suppress-echo
789Move point @var{count} buttons or editing fields forward. 789Move point @var{count} buttons or editing fields forward. The optional
790@var{suppress-echo} argument suppresses showing in the echo-area the
791help-echo text, if any, for the final position after the move; it is
792always @code{nil} in interactive invocations.
790@end deffn 793@end deffn
791@item M-@key{TAB} 794@item M-@key{TAB}
792@itemx S-@key{TAB} 795@itemx S-@key{TAB}
793@deffn Command widget-backward &optional count 796@deffn Command widget-backward count &optional suppress-echo
794Move point @var{count} buttons or editing fields backward. 797Move point @var{count} buttons or editing fields backward. The optional
798@var{suppress-echo} argument suppresses showing in the echo-area the
799help-echo text, if any, for the final position after the move; it is
800always @code{nil} in interactive invocations.
795@end deffn 801@end deffn
796@end table 802@end table
797 803