Fix permissions bugs with setgid directories etc.
[bpt/emacs.git] / doc / lispref / os.texi
index ac6711f..4b9cdfa 100644 (file)
@@ -3,7 +3,7 @@
 @c Copyright (C) 1990-1995, 1998-1999, 2001-2012
 @c   Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
-@node System Interface, Packaging, Display, Top
+@node System Interface
 @chapter Operating System Interface
 
   This chapter is about starting and getting out of Emacs, access to
@@ -70,13 +70,11 @@ in their turn.  The files @file{subdirs.el} are normally generated
 automatically when Emacs is installed.
 
 @item
-It registers input methods by loading any @file{leim-list.el} file
-found in the @code{load-path}.
-
-@c It removes PWD from the environment if it is not accurate.
-@c It abbreviates default-directory.
-
-@c Now normal-top-level calls command-line.
+If the library @file{leim-list.el} exists, Emacs loads it.  This
+optional library is intended for registering input methods; Emacs
+looks for it in @code{load-path} (@pxref{Library Search}), skipping
+those directories containing the standard Emacs libraries (since
+@file{leim-list.el} should not exist in those directories).
 
 @vindex before-init-time
 @item
@@ -447,7 +445,7 @@ is found whose name is identical to the terminal's name, Emacs strips
 from the terminal's name the last hyphen or underscore and everything that follows
 it, and tries again.  This process is repeated until Emacs finds a
 matching library, or until there are no more hyphens or underscores in the name
-(i.e.@: there is no terminal-specific library).  For example, if the
+(i.e., there is no terminal-specific library).  For example, if the
 terminal name is @samp{xterm-256color} and there is no
 @file{term/xterm-256color.el} library, Emacs tries to load
 @file{term/xterm.el}.  If necessary, the terminal library can evaluate
@@ -611,7 +609,6 @@ special to Emacs, then switch back to Emacs when you want.)
 @end menu
 
 @node Killing Emacs
-@comment  node-name,  next,  previous,  up
 @subsection Killing Emacs
 @cindex killing Emacs
 
@@ -641,7 +638,7 @@ input) can read them.
 higher-level command @kbd{C-x C-c}
 (@code{save-buffers-kill-terminal}).  @xref{Exiting,,, emacs, The GNU
 Emacs Manual}.  It is also called automatically if Emacs receives a
-@code{SIGTERM} or @code{SIGHUP} operating system signal (e.g. when the
+@code{SIGTERM} or @code{SIGHUP} operating system signal (e.g., when the
 controlling terminal is disconnected), or if it receives a
 @code{SIGINT} signal while running in batch mode (@pxref{Batch Mode}).
 
@@ -649,7 +646,7 @@ controlling terminal is disconnected), or if it receives a
 This normal hook is run by @code{kill-emacs}, before it kills Emacs.
 
 Because @code{kill-emacs} can be called in situations where user
-interaction is impossible (e.g. when the terminal is disconnected),
+interaction is impossible (e.g., when the terminal is disconnected),
 functions on this hook should not attempt to interact with the user.
 If you want to interact with the user when Emacs is shutting down, use
 @code{kill-emacs-query-functions}, described below.
@@ -874,7 +871,7 @@ Hewlett-Packard HPUX operating system.
 Silicon Graphics Irix system.
 
 @item ms-dos
-Microsoft's DOS.  Emacs compiled with DJGPP for MS-DOS binds
+Microsoft's DOS@.  Emacs compiled with DJGPP for MS-DOS binds
 @code{system-type} to @code{ms-dos} even when you run it on MS-Windows.
 
 @item usg-unix-v
@@ -882,7 +879,7 @@ AT&T Unix System V.
 
 @item windows-nt
 Microsoft Windows NT, 9X and later.  The value of @code{system-type}
-is always @code{windows-nt}, e.g. even on Windows 7.
+is always @code{windows-nt}, e.g., even on Windows 7.
 
 @end table
 
@@ -890,7 +887,7 @@ We do not wish to add new symbols to make finer distinctions unless it
 is absolutely necessary!  In fact, we hope to eliminate some of these
 alternatives in the future.  If you need to make a finer distinction
 than @code{system-type} allows for, you can test
-@code{system-configuration}, e.g. against a regexp.
+@code{system-configuration}, e.g., against a regexp.
 @end defvar
 
 @defun system-name
@@ -1160,6 +1157,30 @@ This function returns the effective @acronym{UID} of the user.
 The value may be a floating point number.
 @end defun
 
+@defun group-gid
+This function returns the effective @acronym{GID} of the Emacs process.
+The value may be a floating point number.
+@end defun
+
+@defun group-real-gid
+This function returns the real @acronym{GID} of the Emacs process.
+The value may be a floating point number.
+@end defun
+
+@defun system-users
+This function returns a list of strings, listing the user names on the
+system.  If Emacs cannot retrieve this information, the return value
+is a list containing just the value of @code{user-real-login-name}.
+@end defun
+
+@cindex user groups
+@defun system-groups
+This function returns a list of strings, listing the names of user
+groups on the system.  If Emacs cannot retrieve this information, the
+return value is @code{nil}.
+@end defun
+
+
 @node Time of Day
 @section Time of Day
 
@@ -1167,7 +1188,9 @@ The value may be a floating point number.
 zone.
 
 @cindex epoch
-  Most of these functions represent time as a list of either three
+  Most of these functions represent time as a list of either four
+integers, @code{(@var{sec-high} @var{sec-low} @var{microsec}
+@var{picosec})}, or of three
 integers, @code{(@var{sec-high} @var{sec-low} @var{microsec})}, or of
 two integers, @code{(@var{sec-high} @var{sec-low})}.  The integers
 @var{sec-high} and @var{sec-low} give the high and low bits of an
@@ -1182,12 +1205,15 @@ is the number of seconds from the @dfn{epoch} (0:00 January 1, 1970
 UTC) to the specified time.  The third list element @var{microsec}, if
 present, gives the number of microseconds from the start of that
 second to the specified time.
-
-  The return value of @code{current-time} represents time using three
-integers, while the timestamps in the return value of
-@code{file-attributes} use two integers (@pxref{Definition of
-file-attributes}).  In function arguments, e.g.@: the @var{time-value}
-argument to @code{current-time-string}, both two- and three-integer
+Similarly, the fourth list element @var{picosec}, if present, gives
+the number of picoseconds from the start of that microsecond to the
+specified time.
+
+  The return value of @code{current-time} represents time using four
+integers, as do the timestamps in the return value of
+@code{file-attributes} (@pxref{Definition of
+file-attributes}).  In function arguments, e.g., the @var{time-value}
+argument to @code{current-time-string}, two-, three-, and four-integer
 lists are accepted.  You can convert times from the list
 representation into standard human-readable strings using
 @code{current-time}, or to other forms using the @code{decode-time}
@@ -1217,9 +1243,12 @@ The argument @var{time-value}, if given, specifies a time to format
 @end defun
 
 @defun current-time
-This function returns the current time, represented as a list of three
-integers @code{(@var{sec-high} @var{sec-low} @var{microsec})}.  On
-systems with only one-second time resolutions, @var{microsec} is 0.
+This function returns the current time, represented as a list of four
+integers @code{(@var{sec-high} @var{sec-low} @var{microsec} @var{picosec})}.
+These integers have trailing zeros on systems that return time with
+lower resolutions.  On all current machines @var{picosec} is a
+multiple of 1000, but this may change as higher-resolution clocks
+become available.
 @end defun
 
 @defun float-time &optional time-value
@@ -1260,13 +1289,13 @@ time zone.
 @node Time Conversion
 @section Time Conversion
 
-  These functions convert time values (lists of two or three integers,
+  These functions convert time values (lists of two to four integers,
 as explained in the previous section) into calendrical information and
 vice versa.
 
   Many 32-bit operating systems are limited to time values containing
 32 bits of information; these systems typically handle only the times
-from 1901-12-13 20:45:52 UTC through 2038-01-19 03:14:07 UTC.
+from 1901-12-13 20:45:52 UTC through 2038-01-19 03:14:07 UTC@.
 However, 64-bit and some 32-bit operating systems have larger time
 values, and can represent times far in the past or future.
 
@@ -1354,8 +1383,8 @@ on others, years as early as 1901 do work.
 @node Time Parsing
 @section Parsing and Formatting Times
 
-  These functions convert time values (lists of two or three integers)
-to text in a string, and vice versa.
+  These functions convert time values to text in a string, and vice versa.
+Time values are lists of two to four integers (@pxref{Time of Day}).
 
 @defun date-to-time string
 This function parses the time-string @var{string} and returns the
@@ -1411,8 +1440,6 @@ This stands for a newline.
 This stands for the nanoseconds (000000000-999999999).  To ask for
 fewer digits, use @samp{%3N} for milliseconds, @samp{%6N} for
 microseconds, etc.  Any excess digits are discarded, without rounding.
-Currently Emacs time stamps are at best microsecond resolution so the
-last three digits generated by plain @samp{%N} are always zero.
 @item %p
 This stands for @samp{AM} or @samp{PM}, as appropriate.
 @item %r
@@ -1517,7 +1544,7 @@ The integer number of minutes.
 The integer number of seconds.
 @item %z
 Non-printing control flag.  When it is used, other specifiers must be
-given in the order of decreasing size, i.e.@: years before days, hours
+given in the order of decreasing size, i.e., years before days, hours
 before minutes, etc.  Nothing will be produced in the result string to
 the left of @samp{%z} until the first non-zero conversion is
 encountered.  For example, the default format used by
@@ -1564,18 +1591,9 @@ When called interactively, it prints the uptime in the echo area.
 
 @defun get-internal-run-time
 This function returns the processor run time used by Emacs as a list
-of three integers: @code{(@var{high} @var{low} @var{microsec})}.  The
-integers @var{high} and @var{low} combine to give the number of
-seconds, which is
-@ifnottex
-@var{high} * 2**16 + @var{low}.
-@end ifnottex
-@tex
-$high*2^{16}+low$.
-@end tex
-
-The third element, @var{microsec}, gives the microseconds (or 0 for
-systems that return time with the resolution of only one second).
+of four integers: @code{(@var{high} @var{low} @var{microsec}
+@var{picosec})}, using the same format as @code{current-time}
+(@pxref{Time of Day}).
 
 Note that the time returned by this function excludes the time Emacs
 was not using the processor, and if the Emacs process has several
@@ -1816,62 +1834,65 @@ minutes, and even if there have been garbage collections and autosaves.
 input.  Then it becomes idle again, and all the idle timers that are
 set up to repeat will subsequently run another time, one by one.
 
+  Do not write an idle timer function containing a loop which does a
+certain amount of processing each time around, and exits when
+@code{(input-pending-p)} is non-@code{nil}.  This approach seems very
+natural but has two problems:
+
+@itemize
+@item
+It blocks out all process output (since Emacs accepts process output
+only while waiting).
+
+@item
+It blocks out any idle timers that ought to run during that time.
+@end itemize
+
+@noindent
+Similarly, do not write an idle timer function that sets up another
+idle timer (including the same idle timer) with @var{secs} argument
+less than or equal to the current idleness time.  Such a timer will
+run almost immediately, and continue running again and again, instead
+of waiting for the next time Emacs becomes idle.  The correct approach
+is to reschedule with an appropriate increment of the current value of
+the idleness time, as described below.
+
 @defun current-idle-time
 If Emacs is idle, this function returns the length of time Emacs has
-been idle, as a list of three integers: @code{(@var{sec-high}
-@var{sec-low} @var{microsec})}, where @var{high} and @var{low} are the
-high and low bits for the number of seconds and @var{microsec} is the
-additional number of microseconds (@pxref{Time of Day}).
+been idle, as a list of four integers: @code{(@var{sec-high}
+@var{sec-low} @var{microsec} @var{picosec})}, using the same format as
+@code{current-time} (@pxref{Time of Day}).
 
 When Emacs is not idle, @code{current-idle-time} returns @code{nil}.
 This is a convenient way to test whether Emacs is idle.
+@end defun
 
-The main use of this function is when an idle timer function wants to
-``take a break'' for a while.  It can set up another idle timer to
-call the same function again, after a few seconds more idleness.
-Here's an example:
+  The main use of @code{current-idle-time} is when an idle timer
+function wants to ``take a break'' for a while.  It can set up another
+idle timer to call the same function again, after a few seconds more
+idleness.  Here's an example:
 
-@smallexample
-(defvar resume-timer nil
-  "Timer that `timer-function' used to reschedule itself, or nil.")
+@example
+(defvar my-resume-timer nil
+  "Timer for `my-timer-function' to reschedule itself, or nil.")
 
-(defun timer-function ()
-  ;; @r{If the user types a command while @code{resume-timer}}
+(defun my-timer-function ()
+  ;; @r{If the user types a command while @code{my-resume-timer}}
   ;; @r{is active, the next time this function is called from}
-  ;; @r{its main idle timer, deactivate @code{resume-timer}.}
-  (when resume-timer
-    (cancel-timer resume-timer))
+  ;; @r{its main idle timer, deactivate @code{my-resume-timer}.}
+  (when my-resume-timer
+    (cancel-timer my-resume-timer))
   ...@var{do the work for a while}...
   (when @var{taking-a-break}
-    (setq resume-timer
+    (setq my-resume-timer
           (run-with-idle-timer
             ;; Compute an idle time @var{break-length}
             ;; more than the current value.
             (time-add (current-idle-time)
                       (seconds-to-time @var{break-length}))
             nil
-            'timer-function))))
-@end smallexample
-@end defun
-
-  Do not write an idle timer function containing a loop which does a
-certain amount of processing each time around, and exits when
-@code{(input-pending-p)} is non-@code{nil}.  This approach seems very
-natural but has two problems:
-
-@itemize
-@item
-It blocks out all process output (since Emacs accepts process output
-only while waiting).
-
-@item
-It blocks out any idle timers that ought to run during that time.
-@end itemize
-
-@noindent
-The correct approach is for the idle timer to reschedule itself after
-a brief pause, using the method in the @code{timer-function} example
-above.
+            'my-timer-function))))
+@end example
 
 @node Terminal Input
 @section Terminal Input
@@ -1905,7 +1926,6 @@ If @var{flow} is non-@code{nil}, then Emacs uses @sc{xon/xoff}
 (@kbd{C-q}, @kbd{C-s}) flow control for output to the terminal.  This
 has no effect except in @sc{cbreak} mode.
 
-@c Emacs 19 feature
 The argument @var{meta} controls support for input character codes
 above 127.  If @var{meta} is @code{t}, Emacs converts characters with
 the 8th bit set into Meta characters.  If @var{meta} is @code{nil},
@@ -1914,7 +1934,6 @@ it as a parity bit.  If @var{meta} is neither @code{t} nor @code{nil},
 Emacs uses all 8 bits of input unchanged.  This is good for terminals
 that use 8-bit character sets.
 
-@c Emacs 19 feature
 If @var{quit-char} is non-@code{nil}, it specifies the character to
 use for quitting.  Normally this character is @kbd{C-g}.
 @xref{Quitting}.
@@ -1923,7 +1942,6 @@ use for quitting.  Normally this character is @kbd{C-g}.
 The @code{current-input-mode} function returns the input mode settings
 Emacs is currently using.
 
-@c Emacs 19 feature
 @defun current-input-mode
 This function returns the current mode for reading keyboard input.  It
 returns a list, corresponding to the arguments of @code{set-input-mode},
@@ -1955,7 +1973,7 @@ is the character Emacs currently uses for quitting, usually @kbd{C-g}.
 This function returns a vector containing the last 300 input events from
 the keyboard or mouse.  All input events are included, whether or not
 they were used as parts of key sequences.  Thus, you always get the last
-100 input events, not counting events generated by keyboard macros.
+300 input events, not counting events generated by keyboard macros.
 (These are excluded because they are less interesting for debugging; it
 should be enough to see the events that invoked the macros.)
 
@@ -2108,10 +2126,10 @@ calls the functions in the list @code{play-sound-functions}.
 Each function is called with one argument, @var{sound}.
 @end defun
 
-@defun play-sound-file file &optional volume device
+@deffn Command play-sound-file file &optional volume device
 This function is an alternative interface to playing a sound @var{file}
 specifying an optional @var{volume} and @var{device}.
-@end defun
+@end deffn
 
 @defvar play-sound-functions
 A list of functions to be called before playing a sound.  Each function
@@ -2268,13 +2286,19 @@ These arguments should consist of alternating keyword and value pairs.
 The supported keywords and values are as follows:
 
 @table @code
+@item :bus @var{bus}
+The D-Bus bus.  This argument is needed only if a bus other than
+@code{:session} shall be used.
+
 @item :title @var{title}
 The notification title.
 
 @item :body @var{text}
 The notification body text.  Depending on the implementation of the
 notification server, the text could contain HTML markups, like
-@samp{"<b>bold text</b>"}, hyperlinks, or images.
+@samp{"<b>bold text</b>"}, hyperlinks, or images.  Special HTML
+characters must be encoded, as @samp{"Contact
+&lt;postmaster@@localhost&gt;!"}.
 
 @item :app-name @var{name}
 The name of the application sending the notification.  The default is
@@ -2309,7 +2333,10 @@ When this keyword is given, the @var{title} string of the actions is
 interpreted as icon name.
 
 @item :category @var{category}
-The type of notification this is, a string.
+The type of notification this is, a string.  See the
+@uref{http://developer.gnome.org/notification-spec/#categories,
+Desktop Notifications Specification} for a list of standard
+categories.
 
 @item :desktop-entry @var{filename}
 This specifies the name of the desktop filename representing the
@@ -2323,7 +2350,7 @@ channels and image data, respectively.
 @item :image-path @var{path}
 This is represented either as a URI (@samp{file://} is the only URI
 schema supported right now) or a name in a freedesktop.org-compliant
-icon theme from @samp{$XDG_DATA_DIRS/icons}, like @samp{"mail-message-new"}.
+icon theme from @samp{$XDG_DATA_DIRS/icons}.
 
 @item :sound-file @var{filename}
 The path to a sound file to play when the notification pops up.
@@ -2412,13 +2439,17 @@ A message window opens on the desktop.  Press "I agree"
 @end example
 @end defun
 
-@defun notifications-close-notification id
+@defun notifications-close-notification id &optional bus
 This function closes a notification with identifier @var{id}.
+@var{bus} can be a string denoting a D-Bus connection, the default is
+@code{:session}.
 @end defun
 
-@defun notifications-get-capabilities
-Returns the capabilities of the notification server, a list of strings.
-The following capabilities can be expected:
+@defun notifications-get-capabilities &optional bus
+Returns the capabilities of the notification server, a list of
+symbols.  @var{bus} can be a string denoting a D-Bus connection, the
+default is @code{:session}.  The following capabilities can be
+expected:
 
 @table @code
 @item :actions
@@ -2455,6 +2486,30 @@ Further vendor-specific caps start with @code{:x-vendor}, like
 @code{:x-gnome-foo-cap}.
 @end defun
 
+@defun notifications-get-server-information &optional bus
+Return information on the notification server, a list of strings.
+@var{bus} can be a string denoting a D-Bus connection, the default is
+@code{:session}.  The returned list is @code{(@var{name} @var{vendor}
+@var{version} @var{spec-version})}.
+
+@table @var
+@item name
+The product name of the server.
+
+@item vendor
+The vendor name.  For example, @samp{"KDE"}, @samp{"GNOME"}.
+
+@item version
+The server's version number.
+
+@item spec-version
+The specification version the server is compliant with.
+@end table
+
+If @var{SPEC_VERSION} is @code{nil}, the server supports a
+specification prior to @samp{"1.0"}.
+@end defun
+
 
 @node Dynamic Libraries
 @section Dynamically Loaded Libraries
@@ -2474,26 +2529,27 @@ a symbol representing a supported external library, and the rest are
 strings giving alternate filenames for that library.
 
 Emacs tries to load the library from the files in the order they
-appear in the list; if none is found, the running session of Emacs
-won't have access to that library, and the features that depend on the
-library will be unavailable.
+appear in the list; if none is found, the Emacs session won't have
+access to that library, and the features it provides will be
+unavailable.
 
 Image support on some platforms uses this facility.  Here's an example
 of setting this variable for supporting images on MS-Windows:
 
-@lisp
+@example
 (setq dynamic-library-alist
       '((xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll")
         (png "libpng12d.dll" "libpng12.dll" "libpng.dll"
-        "libpng13d.dll" "libpng13.dll")
-        (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
+             "libpng13d.dll" "libpng13.dll")
+        (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll"
+              "jpeg.dll")
         (tiff "libtiff3.dll" "libtiff.dll")
         (gif "giflib4.dll" "libungif4.dll" "libungif.dll")
         (svg "librsvg-2-2.dll")
         (gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
         (glib "libglib-2.0-0.dll")
        (gobject "libgobject-2.0-0.dll")))
-@end lisp
+@end example
 
 Note that image types @code{pbm} and @code{xbm} do not need entries in
 this variable because they do not depend on external libraries and are