aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/customize.texi2
-rw-r--r--doc/lispref/display.texi55
-rw-r--r--doc/lispref/strings.texi176
-rw-r--r--doc/lispref/text.texi75
-rw-r--r--doc/misc/ede.texi10
-rw-r--r--doc/misc/eieio.texi17
6 files changed, 234 insertions, 101 deletions
diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi
index 172809b29d8..2a72276bc56 100644
--- a/doc/lispref/customize.texi
+++ b/doc/lispref/customize.texi
@@ -1156,7 +1156,7 @@ in that value.
1156 1156
1157The usual reason to specify a documentation string for a type is to 1157The usual reason to specify a documentation string for a type is to
1158provide more information about the meanings of alternatives inside a 1158provide more information about the meanings of alternatives inside a
1159@code{:choice} type or the parts of some other composite type. 1159@code{choice} type or the parts of some other composite type.
1160 1160
1161@item :help-echo @var{motion-doc} 1161@item :help-echo @var{motion-doc}
1162@kindex help-echo@r{, customization keyword} 1162@kindex help-echo@r{, customization keyword}
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 3d738b9965f..6fff199485e 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -2017,36 +2017,45 @@ it contains.
2017 2017
2018@defun window-text-pixel-size &optional window from to x-limit y-limit mode-and-header-line 2018@defun window-text-pixel-size &optional window from to x-limit y-limit mode-and-header-line
2019This function returns the size of the text of @var{window}'s buffer in 2019This function returns the size of the text of @var{window}'s buffer in
2020pixels. @var{window} must be a live window and defaults to the selected 2020pixels. @var{window} must be a live window and defaults to the
2021one. The return value is a cons of the maximum pixel-width of any text 2021selected one. The return value is a cons of the maximum pixel-width
2022line and the maximum pixel-height of all text lines. 2022of any text line and the maximum pixel-height of all text lines. This
2023 2023function exists to allow Lisp programs to adjust the dimensions of
2024The optional argument @var{from}, if non-@code{nil}, specifies the first 2024@var{window} to the buffer text it needs to display.
2025text position to consider and defaults to the minimum accessible 2025
2026position of the buffer. If @var{from} is @code{t}, it uses the minimum 2026The optional argument @var{from}, if non-@code{nil}, specifies the
2027accessible position that is not a newline character. The optional 2027first text position to consider, and defaults to the minimum
2028argument @var{to}, if non-@code{nil}, specifies the last text position 2028accessible position of the buffer. If @var{from} is @code{t}, it
2029to consider and defaults to the maximum accessible position of the 2029stands for the minimum accessible position that is not a newline
2030buffer. If @var{to} is @code{t}, it uses the maximum accessible 2030character. The optional argument @var{to}, if non-@code{nil},
2031position that is not a newline character. 2031specifies the last text position to consider, and defaults to the
2032maximum accessible position of the buffer. If @var{to} is @code{t},
2033it stands for the maximum accessible position that is not a newline
2034character.
2032 2035
2033The optional argument @var{x-limit}, if non-@code{nil}, specifies the 2036The optional argument @var{x-limit}, if non-@code{nil}, specifies the
2034maximum pixel-width that can be returned. @var{x-limit} @code{nil} or 2037maximum X coordinate beyond which text should be ignored; it is
2035omitted, means to use the pixel-width of @var{window}'s body 2038therefore also the largest value of pixel-width that the function can
2036(@pxref{Window Sizes}); this is useful when the caller does not intend 2039return. If @var{x-limit} @code{nil} or omitted, it means to use the
2037to change the width of @var{window}. Otherwise, the caller should 2040pixel-width of @var{window}'s body (@pxref{Window Sizes}); this
2038specify here the maximum width @var{window}'s body may assume. Text 2041default means that text of truncated lines wider than the window will
2039whose x-coordinate is beyond @var{x-limit} is ignored. Since 2042be ignored. This default is useful when the caller does not intend to
2043change the width of @var{window}. Otherwise, the caller should
2044specify here the maximum width @var{window}'s body may assume; in
2045particular, if truncated lines are expected and their text needs to be
2046accounted for, @var{x-limit} should be set to a large value. Since
2040calculating the width of long lines can take some time, it's always a 2047calculating the width of long lines can take some time, it's always a
2041good idea to make this argument as small as needed; in particular, if 2048good idea to make this argument as small as needed; in particular, if
2042the buffer might contain long lines that will be truncated anyway. 2049the buffer might contain long lines that will be truncated anyway.
2043 2050
2044The optional argument @var{y-limit}, if non-@code{nil}, specifies the 2051The optional argument @var{y-limit}, if non-@code{nil}, specifies the
2045maximum pixel-height that can be returned. Text lines whose 2052maximum Y coordinate beyond which text is to be ignored; it is
2046y-coordinate is beyond @var{y-limit} are ignored. Since calculating the 2053therefore also the maximum pixel-height that the function can return.
2047pixel-height of a large buffer can take some time, it makes sense to 2054If @var{y-limit} is nil or omitted, it means to considers all the
2048specify this argument; in particular, if the caller does not know the 2055lines of text till the buffer position specified by @var{to}. Since
2049size of the buffer. 2056calculating the pixel-height of a large buffer can take some time, it
2057makes sense to specify this argument; in particular, if the caller
2058does not know the size of the buffer.
2050 2059
2051The optional argument @var{mode-and-header-line} @code{nil} or omitted 2060The optional argument @var{mode-and-header-line} @code{nil} or omitted
2052means to not include the height of the mode- or header-line of 2061means to not include the height of the mode- or header-line of
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 70c3b3cf4be..4a7bda57c4e 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -28,6 +28,7 @@ keyboard character events.
28* Text Comparison:: Comparing characters or strings. 28* Text Comparison:: Comparing characters or strings.
29* String Conversion:: Converting to and from characters and strings. 29* String Conversion:: Converting to and from characters and strings.
30* Formatting Strings:: @code{format}: Emacs's analogue of @code{printf}. 30* Formatting Strings:: @code{format}: Emacs's analogue of @code{printf}.
31* Custom Format Strings:: Formatting custom @code{format} specifications.
31* Case Conversion:: Case conversion functions. 32* Case Conversion:: Case conversion functions.
32* Case Tables:: Customizing case conversion. 33* Case Tables:: Customizing case conversion.
33@end menu 34@end menu
@@ -1122,6 +1123,181 @@ may be problematic; for example, @samp{%d} and @samp{%g} can mishandle
1122NaNs and can lose precision and type, and @samp{#x%x} and @samp{#o%o} 1123NaNs and can lose precision and type, and @samp{#x%x} and @samp{#o%o}
1123can mishandle negative integers. @xref{Input Functions}. 1124can mishandle negative integers. @xref{Input Functions}.
1124 1125
1126The functions described in this section accept a fixed set of
1127specification characters. The next section describes a function
1128@code{format-spec} which can accept custom specification characters,
1129such as @samp{%a} or @samp{%z}.
1130
1131@node Custom Format Strings
1132@section Custom Format Strings
1133@cindex custom format string
1134@cindex custom @samp{%}-sequence in format
1135
1136Sometimes it is useful to allow users and Lisp programs alike to
1137control how certain text is generated via custom format control
1138strings. For example, a format string could control how to display
1139someone's forename, surname, and email address. Using the function
1140@code{format} described in the previous section, the format string
1141could be something like @w{@code{"%s %s <%s>"}}. This approach
1142quickly becomes impractical, however, as it can be unclear which
1143specification character corresponds to which piece of information.
1144
1145A more convenient format string for such cases would be something like
1146@w{@code{"%f %l <%e>"}}, where each specification character carries
1147more semantic information and can easily be rearranged relative to
1148other specification characters, making such format strings more easily
1149customizable by the user.
1150
1151The function @code{format-spec} described in this section performs a
1152similar function to @code{format}, except it operates on format
1153control strings that use arbitrary specification characters.
1154
1155@defun format-spec template spec-alist &optional only-present
1156This function returns a string produced from the format string
1157@var{template} according to conversions specified in @var{spec-alist},
1158which is an alist (@pxref{Association Lists}) of the form
1159@w{@code{(@var{letter} . @var{replacement})}}. Each specification
1160@code{%@var{letter}} in @var{template} will be replaced by
1161@var{replacement} when formatting the resulting string.
1162
1163The characters in @var{template}, other than the format
1164specifications, are copied directly into the output, including their
1165text properties, if any. Any text properties of the format
1166specifications are copied to their replacements.
1167
1168Using an alist to specify conversions gives rise to some useful
1169properties:
1170
1171@itemize @bullet
1172@item
1173If @var{spec-alist} contains more unique @var{letter} keys than there
1174are unique specification characters in @var{template}, the unused keys
1175are simply ignored.
1176@item
1177If @var{spec-alist} contains more than one association with the same
1178@var{letter}, the closest one to the start of the list is used.
1179@item
1180If @var{template} contains the same specification character more than
1181once, then the same @var{replacement} found in @var{spec-alist} is
1182used as a basis for all of that character's substitutions.
1183@item
1184The order of specifications in @var{template} need not correspond to
1185the order of associations in @var{spec-alist}.
1186@end itemize
1187
1188The optional argument @var{only-present} indicates how to handle
1189specification characters in @var{template} that are not found in
1190@var{spec-alist}. If it is @code{nil} or omitted, the function
1191signals an error. Otherwise, those format specifications and any
1192occurrences of @samp{%%} in @var{template} are left verbatim in the
1193output, including their text properties, if any.
1194@end defun
1195
1196The syntax of format specifications accepted by @code{format-spec} is
1197similar, but not identical, to that accepted by @code{format}. In
1198both cases, a format specification is a sequence of characters
1199beginning with @samp{%} and ending with an alphabetic letter such as
1200@samp{s}.
1201
1202Unlike @code{format}, which assigns specific meanings to a fixed set
1203of specification characters, @code{format-spec} accepts arbitrary
1204specification characters and treats them all equally. For example:
1205
1206@example
1207@group
1208(setq my-site-info
1209 (list (cons ?s system-name)
1210 (cons ?t (symbol-name system-type))
1211 (cons ?c system-configuration)
1212 (cons ?v emacs-version)
1213 (cons ?e invocation-name)
1214 (cons ?p (number-to-string (emacs-pid)))
1215 (cons ?a user-mail-address)
1216 (cons ?n user-full-name)))
1217
1218(format-spec "%e %v (%c)" my-site-info)
1219 @result{} "emacs 27.1 (x86_64-pc-linux-gnu)"
1220
1221(format-spec "%n <%a>" my-site-info)
1222 @result{} "Emacs Developers <emacs-devel@@gnu.org>"
1223@end group
1224@end example
1225
1226A format specification can include any number of the following flag
1227characters immediately after the @samp{%} to modify aspects of the
1228substitution.
1229
1230@table @samp
1231@item 0
1232This flag causes any padding specified by the width to consist of
1233@samp{0} characters instead of spaces.
1234
1235@item -
1236This flag causes any padding specified by the width to be inserted on
1237the right rather than the left.
1238
1239@item <
1240This flag causes the substitution to be truncated on the left to the
1241given width, if specified.
1242
1243@item >
1244This flag causes the substitution to be truncated on the right to the
1245given width, if specified.
1246
1247@item ^
1248This flag converts the substituted text to upper case (@pxref{Case
1249Conversion}).
1250
1251@item _
1252This flag converts the substituted text to lower case (@pxref{Case
1253Conversion}).
1254@end table
1255
1256The result of using contradictory flags (for instance, both upper and
1257lower case) is undefined.
1258
1259As is the case with @code{format}, a format specification can include
1260a width, which is a decimal number that appears after any flags. If a
1261substitution contains fewer characters than its specified width, it is
1262padded on the left:
1263
1264@example
1265@group
1266(format-spec "%8a is padded on the left with spaces"
1267 '((?a . "alpha")))
1268 @result{} " alpha is padded on the left with spaces"
1269@end group
1270@end example
1271
1272Here is a more complicated example that combines several
1273aforementioned features:
1274
1275@example
1276@group
1277(setq my-battery-info
1278 (list (cons ?p "73") ; Percentage
1279 (cons ?L "Battery") ; Status
1280 (cons ?t "2:23") ; Remaining time
1281 (cons ?c "24330") ; Capacity
1282 (cons ?r "10.6"))) ; Rate of discharge
1283
1284(format-spec "%>^-3L : %3p%% (%05t left)" my-battery-info)
1285 @result{} "BAT : 73% (02:23 left)"
1286
1287(format-spec "%>^-3L : %3p%% (%05t left)"
1288 (cons (cons ?L "AC")
1289 my-battery-info))
1290 @result{} "AC : 73% (02:23 left)"
1291@end group
1292@end example
1293
1294As the examples in this section illustrate, @code{format-spec} is
1295often used for selectively formatting an assortment of different
1296pieces of information. This is useful in programs that provide
1297user-customizable format strings, as the user can choose to format
1298with a regular syntax and in any desired order only a subset of the
1299information that the program makes available.
1300
1125@node Case Conversion 1301@node Case Conversion
1126@section Case Conversion in Lisp 1302@section Case Conversion in Lisp
1127@cindex upper case 1303@cindex upper case
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 7c4bed04cb5..d765c95f773 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -58,7 +58,6 @@ the character after point.
58 of another buffer. 58 of another buffer.
59* Decompression:: Dealing with compressed data. 59* Decompression:: Dealing with compressed data.
60* Base 64:: Conversion to or from base 64 encoding. 60* Base 64:: Conversion to or from base 64 encoding.
61* Interpolated Strings:: Formatting Customizable Strings.
62* Checksum/Hash:: Computing cryptographic hashes. 61* Checksum/Hash:: Computing cryptographic hashes.
63* GnuTLS Cryptography:: Cryptographic algorithms imported from GnuTLS. 62* GnuTLS Cryptography:: Cryptographic algorithms imported from GnuTLS.
64* Parsing HTML/XML:: Parsing HTML and XML. 63* Parsing HTML/XML:: Parsing HTML and XML.
@@ -2029,8 +2028,15 @@ non-@code{nil} value.
2029@end enumerate 2028@end enumerate
2030 2029
2031The argument @var{predicate} is the function to use to compare keys. 2030The argument @var{predicate} is the function to use to compare keys.
2032If keys are numbers, it defaults to @code{<}; otherwise it defaults to 2031It is called with two arguments, the keys to compare, and should
2033@code{string<}. 2032return non-@code{nil} if the first key should come before the second
2033in the sorting order. What exactly are the key arguments depends on
2034what @var{startkeyfun} and @var{endkeyfun} return. If @var{predicate}
2035is omitted or @code{nil}, it defaults to @code{<} if the keys are
2036numbers, to @code{compare-buffer-substrings} if the keys are cons
2037cells (whose @code{car} and @code{cdr} are start and end buffer
2038positions of the key), and to @code{string<} otherwise (with keys
2039assumed to be strings).
2034 2040
2035As an example of @code{sort-subr}, here is the complete function 2041As an example of @code{sort-subr}, here is the complete function
2036definition for @code{sort-lines}: 2042definition for @code{sort-lines}:
@@ -4662,69 +4668,6 @@ If optional argument @var{base64url} is non-@code{nil}, then padding
4662is optional, and the URL variant of base 64 encoding is used. 4668is optional, and the URL variant of base 64 encoding is used.
4663@end defun 4669@end defun
4664 4670
4665
4666@node Interpolated Strings
4667@section Formatting Customizable Strings
4668
4669It is, in some circumstances, useful to present users with a string to
4670be customized that can then be expanded programmatically. For
4671instance, @code{erc-header-line-format} is @code{"%n on %t (%m,%l)
4672%o"}, and each of those characters after the percent signs are
4673expanded when the header line is computed. To do this, the
4674@code{format-spec} function is used:
4675
4676@defun format-spec format specification &optional only-present
4677@var{format} is the format specification string as in the example
4678above. @var{specification} is an alist that has elements where the
4679@code{car} is a character and the @code{cdr} is the substitution.
4680
4681If @var{only-present} is @code{nil}, errors will be signaled if a
4682format character has been used that's not present in
4683@var{specification}. If it's non-@code{nil}, that format
4684specification is left verbatim in the result.
4685@end defun
4686
4687Here's a trivial example:
4688
4689@example
4690(format-spec "su - %u %l"
4691 `((?u . ,(user-login-name))
4692 (?l . "ls")))
4693 @result{} "su - foo ls"
4694@end example
4695
4696In addition to allowing padding/limiting to a certain length, the
4697following modifiers can be used:
4698
4699@table @asis
4700@item @samp{0}
4701Pad with zeros instead of the default spaces.
4702
4703@item @samp{-}
4704Pad to the right.
4705
4706@item @samp{^}
4707Use upper case.
4708
4709@item @samp{_}
4710Use lower case.
4711
4712@item @samp{<}
4713If the length needs to be limited, remove characters from the left.
4714
4715@item @samp{>}
4716Same as previous, but remove characters from the right.
4717@end table
4718
4719If contradictory modifiers are used (for instance, both upper and
4720lower case), then what happens is undefined.
4721
4722As an example, @samp{"%<010b"} means ``insert the @samp{b} expansion,
4723but pad with leading zeros if it's less than ten characters, and if
4724it's more than ten characters, shorten by removing characters from the
4725left.''
4726
4727
4728@node Checksum/Hash 4671@node Checksum/Hash
4729@section Checksum/Hash 4672@section Checksum/Hash
4730@cindex MD5 checksum 4673@cindex MD5 checksum
diff --git a/doc/misc/ede.texi b/doc/misc/ede.texi
index 584b0d7ee50..412176986cc 100644
--- a/doc/misc/ede.texi
+++ b/doc/misc/ede.texi
@@ -955,18 +955,16 @@ The example for Makefiles looks like this:
955;;; MAKEFILE 955;;; MAKEFILE
956 956
957(defclass ede-generic-makefile-project (ede-generic-project) 957(defclass ede-generic-makefile-project (ede-generic-project)
958 ((buildfile :initform "Makefile") 958 ((buildfile :initform "Makefile"))
959 )
960 "Generic Project for makefiles.") 959 "Generic Project for makefiles.")
961 960
962(defmethod ede-generic-setup-configuration ((proj ede-generic-makefile-project) config) 961(defmethod ede-generic-setup-configuration ((proj ede-generic-makefile-project) config)
963 "Setup a configuration for Make." 962 "Set up a configuration for Make."
964 (oset config build-command "make -k") 963 (oset config build-command "make -k")
965 (oset config debug-command "gdb ") 964 (oset config debug-command "gdb "))
966 )
967 965
968(ede-generic-new-autoloader "generic-makefile" "Make" 966(ede-generic-new-autoloader "generic-makefile" "Make"
969 "Makefile" 'ede-generic-makefile-project) 967 "Makefile" 'ede-generic-makefile-project)
970@end example 968@end example
971 969
972This example project will detect any directory with the file 970This example project will detect any directory with the file
diff --git a/doc/misc/eieio.texi b/doc/misc/eieio.texi
index 6e7d4386bec..8dd394cb848 100644
--- a/doc/misc/eieio.texi
+++ b/doc/misc/eieio.texi
@@ -744,14 +744,21 @@ slot values, and use the previously mentioned set/ref routines.
744@anchor{slot-value} 744@anchor{slot-value}
745This function retrieves the value of @var{slot} from @var{object}. 745This function retrieves the value of @var{slot} from @var{object}.
746Unlike @code{oref}, the symbol for @var{slot} must be quoted. 746Unlike @code{oref}, the symbol for @var{slot} must be quoted.
747
748This is a generalized variable that can be used with @code{setf} to
749modify the value stored in @var{slot}. @xref{Generalized
750Variables,,,elisp,GNU Emacs Lisp Reference Manual}.
747@end defun 751@end defun
748 752
749@defun set-slot-value object slot value 753@defun set-slot-value object slot value
750@anchor{set-slot-value} 754@anchor{set-slot-value}
751This is not a CLOS function, but is the setter for @code{slot-value} 755This function sets the value of @var{slot} from @var{object}. Unlike
752used by the @code{setf} macro. This
753function sets the value of @var{slot} from @var{object}. Unlike
754@code{oset}, the symbol for @var{slot} must be quoted. 756@code{oset}, the symbol for @var{slot} must be quoted.
757
758This is not a CLOS function, but is the obsolete setter for
759@code{slot-value} used by the @code{setf} macro. It is therefore
760recommended to use @w{@code{(setf (slot-value @var{object} @var{slot})
761@var{value})}} instead.
755@end defun 762@end defun
756 763
757@defun slot-makeunbound object slot 764@defun slot-makeunbound object slot
@@ -1072,7 +1079,7 @@ Return a string of the form @samp{#<object-class myobjname>} for @var{obj}.
1072This should look like Lisp symbols from other parts of Emacs such as 1079This should look like Lisp symbols from other parts of Emacs such as
1073buffers and processes, and is shorter and cleaner than printing the 1080buffers and processes, and is shorter and cleaner than printing the
1074object's record. It is more useful to use @code{object-print} to get 1081object's record. It is more useful to use @code{object-print} to get
1075and object's print form, as this allows the object to add extra display 1082an object's print form, as this allows the object to add extra display
1076information into the symbol. 1083information into the symbol.
1077@end defun 1084@end defun
1078 1085
@@ -1227,7 +1234,7 @@ objects on top of records, and thus everything is technically visible,
1227some functions have been provided. None of these functions are a part 1234some functions have been provided. None of these functions are a part
1228of CLOS. 1235of CLOS.
1229 1236
1230@defun object-slots obj 1237@defun eieio-class-slots obj
1231Return the list of public slots for @var{obj}. 1238Return the list of public slots for @var{obj}.
1232@end defun 1239@end defun
1233 1240