-
Notifications
You must be signed in to change notification settings - Fork 12
/
compat.texi
3735 lines (3110 loc) · 132 KB
/
compat.texi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\input texinfo @c -*- texinfo -*-
@c %**start of header
@setfilename compat.info
@settitle "Compat" Manual
@documentencoding UTF-8
@documentlanguage en
@c %**end of header
@copying
Copyright @copyright{} 2022-2025 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with the Front-Cover Texts being “A GNU Manual,”
and with the Back-Cover Texts as in (a) below. A copy of the license
is included in the section entitled “GNU Free Documentation License.”
(a) The FSF’s Back-Cover Text is: “You have the freedom to copy and
modify this GNU manual.”
@end quotation
@end copying
@dircategory Emacs
@direntry
* Compat: (compat). Compatibility Library for Emacs Lisp.
@end direntry
@finalout
@titlepage
@title "Compat" Manual
@subtitle For version 30.0.2.0
@author Philip Kaludercic, Daniel Mendler
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@contents
@ifnottex
@node Top
@top "Compat" Manual
This manual documents the usage of the "Compat" Emacs lisp library,
the forward-compatibility library for Emacs Lisp, corresponding to
version 30.0.2.0.
@insertcopying
@end ifnottex
@menu
* Introduction::
* Support::
* Development::
* Function Index::
* Variable Index::
@detailmenu
--- The Detailed Node Listing ---
Introduction
* Overview::
* Usage::
* Limitations::
Support
* Emacs 25.1:: Compatibility support for Emacs 25.1
* Emacs 26.1:: Compatibility support for Emacs 26.1
* Emacs 27.1:: Compatibility support for Emacs 27.1
* Emacs 28.1:: Compatibility support for Emacs 28.1
* Emacs 29.1:: Compatibility support for Emacs 29.1
* Emacs 30.1:: Compatibility support for Emacs 30.1
@end detailmenu
@end menu
@node Introduction
@chapter Introduction
@menu
* Overview::
* Usage::
* Limitations::
@end menu
@node Overview
@section Overview
The objective of Compat is to provide "forwards compatibility" library
for Emacs Lisp. By using Compat, an Elisp package does not have to
make the decision to either use new and useful functionality or
support old versions of Emacs.
The library provides support back until Emacs 24.4. The intended
audience are package developers that are interested in using newer
developments, without having to break compatibility.
@node Usage
@section Usage
The intended use-case for this library is for package developers to
add as a dependency in the header. The version of the Compat library
mirrors the version of Emacs releases. The current version of Compat
corresponds to the current Emacs release.
@example
;; Package-Requires: ((emacs "24.4") (compat "30.0.2.0"))
@end example
There is no need to depend on @code{emacs 24.4} specifically. One can
choose any newer version, if features not provided by Compat
necessitate it, for example bug fixes or UI improvements.
In any file where compatibility forms are used, a
@example
(require 'compat)
@end example
should be added early on. This will load all necessary Compat
definitions. Compat loads the @code{seq} library which is preloaded
by default on Emacs 29. Note that if Compat is installed on a recent
version of Emacs, all of the definitions are disabled at compile time,
such that no negative performance impact is incurred.
A minimal version of Compat will be present in Emacs version 30 and
newer. Packages which are part of Emacs itself and want to take
advantage of Compat, can also use @code{(require 'compat)}. The
advantage of the inclusion of a minimal Compat in Emacs is that Compat
will not be installed if you require a version newer or equal than the
current Emacs version. For example, if a package depending on Emacs
25.1 and Compat 29.1 is installed on Emacs 30.1, Compat will not be
pulled in as dependency, since Emacs 30.1 already provides the
required functionality.
Compat provides replacement functions with extended functionality for
functions that are already defined, e.g., @code{sort} or @code{assoc}.
These functions may have changed their calling convention (additional
optional arguments) or may have changed their behavior. These
functions must be looked up explicitly with @code{compat-function} or
called explicitly with @code{compat-call}. We call them @dfn{Extended
Definitions}. In contrast, newly @dfn{Added Definitions} can be
called as usual. The Compat manual explicitly documents the calling
convention of each compatibility function.
@example
(compat-call assoc key alist testfn) ;; Call extended `assoc'
(mapcan fun seq) ;; Call newly added `mapcan'
@end example
@defmac compat-call fun &rest args
This macro calls the compatibility function @var{fun} with @var{args}.
Many functions provided by Compat can be called directly without this
macro. However in the case where Compat provides an alternative
version of an existing function, the function call has to go through
@code{compat-call}. This happens for example when the calling
convention of a function has changed.
@end defmac
@defmac compat-function fun
This macro returns the compatibility function symbol for @var{fun}.
See @code{compat-call} for a more convenient macro to directly call
compatibility functions.
@end defmac
If Compat is used in Emacs core packages, the macros
@code{compat-call} and @code{compat-function} will be available in
Emacs version 30 and newer.
The macros @code{compat-call} and @code{compat-function} are
introduced by Compat, since Compat does not advise or override
existing functions. Generally Compat is written in defensive style
which is supposed to reduce potential breakage, and to increase the
chances of staying binary compatible across releases. The extensive
test coverage ensures that we can maintain high quality, which is
crucial for Compat which is not restricted to a namespace like usual
libraries.
If you intend to use a compatibility function in your code it is
recommended that you take a look at the test suite
@file{compat-tests.el}. There you can see the supported calling
conventions, which are guaranteed to work on the supported Emacs
versions. We ensure this using continuous integration. All functions
provided by Compat are covered by the test suite. There is a link to
the corresponding test on the first line of each definition.
You may want to subscribe to the
@uref{https://lists.sr.ht/~pkal/compat-announce, compat-announce}
mailing list to be notified when new versions are released or relevant
changes are made. We also provide a
@uref{https://lists.sr.ht/~pkal/compat-devel, development mailing
list} (@email{~pkal/compat-devel@@lists.sr.ht,
~pkal/compat-devel@@lists.sr.ht}).
@node Limitations
@section Limitations
The Compat library has a number of limitations. Complete backwards
compatibility cannot be provided due to the scope of Compat and for
technical reasons. The scope is intentionally restricted in order to
limit the size of Compat and to ensure that the library stays
maintainable.
Emacs version 24.4 is chosen as the oldest version supported by
Compat, since Elisp has seen significant changes at that version.
Since 24.4 Emacs major versions consistently bump the major version
number. On the library level, subr-x was introduced in 24.4. Most
popular Emacs packages already require 24.4 or even newer versions of
Emacs. Supporting for more historical Emacs versions would complicate
maintenance while only few packages and users would benefit.
Below we list a number of reasons why certain functionality cannot be
provided. Note that in some special cases exceptions can be made and
functions can still be added to Compat even if they satisfy the
criteria from the list. In case you miss functionality which you think
should belong here, a @ref{Development, , report} would be much
appreciated.
@itemize
@item
The additional functionality is a command or a user-facing minor or
major mode. Compat is limited to functionality on the ``library
level''. Generally functions provided by Compat are non-interactive,
such that the user interface (M-x) is unaffected by the presence of
Compat.
@item
The function is not useful for package authors or not intended to be
used by packages, but is only useful on the configuration level. The
macro @code{setopt} is such an example.
@item
Private (double dashed) functions are not ported back. If Compat
includes some private functions, they are meant purely for internal
usage.
@item
The added or extended function belongs to the ``application level''
and not the ``library level''. Features which are not preloaded often
belong to the ``application level''. Application examples are
programming modes or modes like Dired, IRC and Gnus. If these modes
are extended with new functions, these are not ported back.
@item
An existing function or macro was extended by some new functionality.
To support these cases, the function or macro would have to be
advised. Since this is invasive and adds significant overhead, even
when the new feature is not used, Compat does not use advices. As a
compromise, compatibility functions and macros with a changed calling
convention or behavior can be accessed via the @code{compat-function}
and @code{compat-call} macros. In this manual we call such
definitions @dfn{Extended Definitions}. An example is the function
@code{plist-get}. Note that extended functions are subject to closer
scrutiny, since their usage via @code{compat-call} is not completely
painless. If a particular extended function does not see much usage
or the extension yields only marginal benefits, we may not provide it
as part of Compat.
@item
Bug fixes are usually not ported back as part of Compat. Sometimes
library functions show wrong behavior for edge cases. In those cases
Compat could in principle provide a compatibility function which is
invoked via @code{compat-call}. Such extended definitions would
increase the maintenance burden of Compat. At the same time the
benefits would be small given that Compat does not override existing
definitions.
@item
The definition belongs to an Emacs core package, which is also
distributed via ELPA. Compat does not have to provide backward
compatibility for core packages since the updated package can be
installed directly from ELPA. Examples include the libraries xref,
project, seq, map and transient.
@item
New functionality depends on an entire new, non-trivial core library,
which is infeasible to duplicate within Compat. If a backport of such
a library is required, the preferred approach is to either release the
library separately on GNU ELPA as a core package or as a separately
maintained GNU ELPA package. An example is the iso8601 library.
@item
New functionality was implemented in the C core, or depends on
external libraries that cannot be reasonably duplicated in the scope
of a compatibility library. Sometimes new functions on the C level
rely on internal data structures, which we cannot access, rendering a
backport impossible. For example a missing libxml or libtreesitter
cannot be emulated.
@item
The semantics of Elisp changed on a deep level. For example the
addition of big integer support in Emacs 27.1 cannot be replicated on
the level of Compat.
@end itemize
@node Support
@chapter Support
This section goes into the features that Compat manages and doesn't
manage to provide for each Emacs version.
@menu
* Emacs 25.1:: Compatibility support for Emacs 25.1
* Emacs 26.1:: Compatibility support for Emacs 26.1
* Emacs 27.1:: Compatibility support for Emacs 27.1
* Emacs 28.1:: Compatibility support for Emacs 28.1
* Emacs 29.1:: Compatibility support for Emacs 29.1
* Emacs 30.1:: Compatibility support for Emacs 30.1
@end menu
@node Emacs 25.1
@section Emacs 25.1
@subsection Added Definitions
The following functions and macros are implemented in Emacs
25.1. These functions are made available by Compat on Emacs versions
older than 25.1.
@c copied from lispref/help.texi
@defopt text-quoting-style
The value of this user option is a symbol that specifies the style
Emacs should use for single quotes in the wording of help and
messages. If the option's value is @code{curve}, the style is
@t{‘like this’} with curved single quotes. If the value is
@code{straight}, the style is @t{'like this'} with straight
apostrophes. If the value is @code{grave}, quotes are not translated
and the style is @t{`like this'} with grave accent and apostrophe, the
standard style before Emacs version 25. The default value @code{nil}
acts like @code{curve} if curved single quotes seem to be displayable,
and like @code{grave} otherwise.
This option is useful on platforms that have problems with curved
quotes. You can customize it freely according to your personal
preference.
@end defopt
@c based on lisp/simple.el
@defun region-bounds
Return the boundaries of the region. Value is a list of one or more
cons cells of the form @code{(start . end)}. It will have more than
one cons cell when the region is non-contiguous, see
@code{region-noncontiguous-p} and @code{extract-rectangle-bounds}.
@end defun
@c based on lisp/simple.el
@defun region-noncontiguous-p
Return non-nil if the region contains several pieces. An example is a
rectangular region handled as a list of separate contiguous regions
for each line.
@end defun
@c copied from lispref/positions.texi
@defmac save-mark-and-excursion body@dots{}
This macro is like @code{save-excursion}, but also saves and restores
the mark location and @code{mark-active}. This macro does what
@code{save-excursion} did before Emacs 25.1.
@end defmac
@c copied from lispref/strings.texi
@defun format-message string &rest objects
This function acts like @code{format}, except it also converts any
grave accents (@t{`}) and apostrophes (@t{'}) in @var{string} as per
the value of @code{text-quoting-style}.
Typically grave accent and apostrophe in the format translate to
matching curved quotes, e.g., @t{"Missing `%s'"} might result in
@t{"Missing ‘foo’"}. @xref{Text Quoting Style,,,elisp}, for how to
influence or inhibit this translation.
@ref{Formatting Strings,,,elisp}.
@end defun
@c copied from lispref/files.texi
@defun directory-name-p filename
This function returns non-@code{nil} if @var{filename} ends with a
directory separator character. This is the forward slash @samp{/} on
GNU and other POSIX-like systems; MS-Windows and MS-DOS recognize both
the forward slash and the backslash @samp{\} as directory separators.
@xref{Directory Names,,,elisp}.
@end defun
@c copied from lispref/strings.texi
@defun string-greaterp string1 string2
This function returns the result of comparing @var{string1} and
@var{string2} in the opposite order, i.e., it is equivalent to calling
@code{(string-lessp @var{string2} @var{string1})}.
@xref{Text Comparison,,,elisp}.
@end defun
@c copied from lispref/files.texi
@defmac with-file-modes mode body@dots{}
This macro evaluates the @var{body} forms with the default permissions
for new files temporarily set to @var{modes} (whose value is as for
@code{set-file-modes} above). When finished, it restores the original
default file permissions, and returns the value of the last form in
@var{body}.
This is useful for creating private files, for example.
@xref{Changing Files,,,elisp}.
@end defmac
@c copied from lispref/lists.texi
@defun alist-get key alist &optional default remove
This function is similar to @code{assq}. It finds the first association
@w{@code{(@var{key} . @var{value})}} by comparing @var{key} with
@var{alist} elements, and, if found, returns the @var{value} of that
association. If no association is found, the function returns
@var{default}.
This is a generalized variable (@pxref{Generalized Variables,,,elisp})
that can be used to change a value with @code{setf}. When using it to
set a value, optional argument @var{remove} non-@code{nil} means to
remove @var{key}'s association from @var{alist} if the new value is
@code{eql} to @var{default}.
@ref{Association Lists,,,elisp}.
@end defun
@defmac if-let (bindings@dots{}) then &rest else@dots{}
As with @code{let*}, @var{bindings} will consist of
@code{(@var{symbol} @var{value-form})} entries that are evaluated and
bound sequentially. If all @var{value-form} evaluate to
non-@code{nil} values, then @var{then} is evaluated as were the case
with a regular @code{let*} expression, with all the variables bound.
If any @var{value-form} evaluates to @code{nil}, @var{else} is
evaluated, without any bound variables.
A binding may also optionally drop the @var{symbol}, and simplify to
@code{(@var{value-form})} if only the test is of interest.
For the sake of backwards compatibility, it is possible to write a
single binding without a binding list:
@example
@group
(if-let* (@var{symbol} (test)) foo bar)
@equiv{}
(if-let* ((@var{symbol} (test))) foo bar)
@end group
@end example
@end defmac
@defmac when-let (bindings@dots{}) &rest body
As with @code{when}, if one is only interested in the case where all
@var{bindings} are non-nil. Otherwise @var{bindings} are interpreted
just as they are by @code{if-let*}.
@end defmac
@c based on lisp/subr-x.el
@defun hash-table-empty hash-table
Check whether @var{hash-table} is empty (has 0 elements).
@end defun
@c based on lisp/subr-x.el
@defmac thread-first &rest forms
Combine @var{forms} into a single expression by ``threading'' each
element as the @emph{first} argument of their successor. Elements of
@var{forms} can either be an list of an atom.
For example, consider the threading expression and it's equivalent
macro expansion:
@example
(thread-first
5
(+ 20)
(/ 25)
-
(+ 40))
@equiv{}
(+ (- (/ (+ 5 20) 25)) 40)
@end example
Note how the single @code{-} got converted into a list before threading.
This example uses arithmetic functions, but @code{thread-first} is not
restricted to arithmetic or side-effect free code.
@end defmac
@defmac thread-last &rest forms
Combine @var{forms} into a single expression by ``threading'' each
element as the @emph{last} argument of their successor. Elements of
@var{forms} can either be an list of an atom.
For example, consider the threading expression and it's equivalent
macro expansion:
@example
(thread-first
5
(+ 20)
(/ 25)
-
(+ 40))
@equiv{}
(+ 40 (- (/ 25 (+ 20 5))))
@end example
Note how the single @code{-} got converted into a list before threading.
This example uses arithmetic functions, but @code{thread-last} is not
restricted to arithmetic or side-effect free code.
@end defmac
@c copied from lispref/macros.texi
@defun macroexpand-1 form &optional environment
This function expands macros like @code{macroexpand}, but it only
performs one step of the expansion: if the result is another macro call,
@code{macroexpand-1} will not expand it.
@xref{Expansion,Expansion,,elisp}.
@end defun
@c based on lisp/emacs-lisp/macroexp.el
@defun macroexp-quote e
Return an expression @var{e} such that @code{(eval e)} is @var{v}.
@end defun
@c based on lisp/emacs-lisp/macroexp.el
@defun macroexp-parse body
Parse a function @var{body} into @code{(declarations . exps)}.
@end defun
@defun bool-vector &rest objects
This function creates and returns a bool-vector whose elements are the
arguments, @var{objects}.
@xref{Bool-Vectors,,,elisp}.
@end defun
@subsection Missing Definitions
Compat does not provide support for the following Lisp features
implemented in 25.1:
@itemize
@item
The function @code{macroexp-macroexpand}.
@item
The macro @code{macroexp-let2*}.
@item
The function @code{directory-files-recursively}.
@item
New @code{pcase} patterns.
@item
The hook @code{prefix-command-echo-keystrokes-functions} and
@code{prefix-command-preserve-state-hook}.
@item
The hook @code{pre-redisplay-functions}.
@item
The function @code{make-process}.
@item
Support for the variable @code{inhibit-message}.
@item
The @code{define-inline} functionality.
@item
The functions @code{string-collate-lessp} and
@code{string-collate-equalp}.
@item
The function @code{funcall-interactively}.
@item
The function @code{buffer-substring-with-bidi-context}.
@item
The function @code{font-info}.
@item
The function @code{default-font-width}.
@item
The function @code{window-font-height} and @code{window-font-width}.
@item
The function @code{window-max-chars-per-line}.
@item
The function @code{set-binary-mode}.
@item
The functions @code{bufferpos-to-filepos} and
@code{filepos-to-bufferpos}.
@item
The @code{thunk} library.
@end itemize
@node Emacs 26.1
@section Emacs 26.1
@subsection Added Definitions
The following functions and macros are implemented in Emacs
26.1. These functions are made available by Compat on Emacs versions
older than 26.1.
@c based on lispref/lists.texi
@defun assoc-delete-all key alist
This function is like @code{assq-delete-all} except that it uses
@code{equal} to compare elements.
@end defun
@c copied from lispref/minibuf.texi
@defun read-answer question answers
This function prompts the user with text in @var{question}, which
should end in the @samp{SPC} character. The function includes in the
prompt the possible responses in @var{answers} by appending them to
the end of @var{question}. The possible responses are provided in
@var{answers} as an alist whose elements are of the following form:
@lisp
(@var{long-answer} @var{short-answer} @var{help-message})
@end lisp
@noindent
where @var{long-answer} is the complete text of the user response, a
string; @var{short-answer} is a short form of the same response, a
single character or a function key; and @var{help-message} is the text
that describes the meaning of the answer. If the variable
@code{read-answer-short} is non-@code{nil}, the prompt will show the
short variants of the possible answers and the user is expected to
type the single characters/keys shown in the prompt; otherwise the
prompt will show the long variants of the answers, and the user is
expected to type the full text of one of the answers and end by
pressing @key{RET}. If @code{use-dialog-box} is non-@code{nil}, and
this function was invoked by mouse events, the question and the
answers will be displayed in a GUI dialog box.
The function returns the text of the @var{long-answer} selected by the
user, regardless of whether long or short answers were shown in the
prompt and typed by the user.
Here is an example of using this function:
@lisp
(let ((read-answer-short t))
(read-answer "Foo "
'(("yes" ?y "perform the action")
("no" ?n "skip to the next")
("all" ?! "perform for the rest without more questions")
("help" ?h "show help")
("quit" ?q "exit"))))
@end lisp
@end defun
@c copied from lispref/functions.texi
@defun mapcan function sequence
This function applies @var{function} to each element of
@var{sequence}, like @code{mapcar}, but instead of collecting the
results into a list, it returns a single list with all the elements of
the results (which must be lists), by altering the results (using
@code{nconc}; @pxref{Rearrangement,,,elisp}). Like with
@code{mapcar}, @var{sequence} can be of any type except a char-table.
@example
@group
;; @r{Contrast this:} (mapcar #'list '(a b c d)) @result{} ((a) (b) (c)
(d)) ;; @r{with this:} (mapcan #'list '(a b c d)) @result{} (a b c d)
@end group
@end example
@xref{Mapping Functions,,,elisp}.
@end defun
@defun cXXXr
@end defun
@defun cXXXXr
@xref{List Elements,,,elisp}.
@end defun
@c copied from lispref/symbols.texi
@defun gensym &optional prefix
This function returns a symbol using @code{make-symbol}, whose name is
made by appending @code{gensym-counter} to @var{prefix} and
incrementing that counter, guaranteeing that no two calls to this
function will generate a symbol with the same name. The prefix
defaults to @code{"g"}.
@end defun
@defvar gensym-counter
See @code{gensym}.
@end defvar
@c copied from lispref/text.texi
@defun buffer-hash &optional buffer-or-name
Return a hash of @var{buffer-or-name}. If @code{nil}, this defaults
to the current buffer. As opposed to @code{secure-hash}, this
function computes the hash based on the internal representation of the
buffer, disregarding any coding systems. It's therefore only useful
when comparing two buffers running in the same Emacs, and is not
guaranteed to return the same hash between different Emacs versions.
It should be somewhat more efficient on larger buffers than
@code{secure-hash} is, and should not allocate more memory.
@c Note that we do not document what hashing function we're using, or
@c even whether it's a cryptographic hash, since that may change
@c according to what we find useful.
@end defun
@c copied from lispref/files.texi
@defmac file-name-unquote name
This macro removes the quotation prefix @samp{/:} from the file
@var{name}, if any. If @var{name} is a remote file name, the local
part of @var{name} is unquoted.
@end defmac
@c copied from lispref/files.texi
@defun file-name-quoted-p name
This macro returns non-@code{nil}, when @var{name} is quoted with the
prefix @samp{/:}. If @var{name} is a remote file name, the local part
of @var{name} is checked.
@xref{File Name Expansion,,,elisp}.
@end defun
@c copied from lispref/files.texi
@defun file-name-quote name
This macro adds the quotation prefix @samp{/:} to the file @var{name}.
For a local file @var{name}, it prefixes @var{name} with @samp{/:}. If
@var{name} is a remote file name, the local part of @var{name}
(@pxref{Magic File Names,,,elisp}) is quoted. If @var{name} is already
a quoted file name, @var{name} is returned unchanged.
@example
@group
(substitute-in-file-name (compat-call file-name-quote "bar/~/foo")) @result{}
"/:bar/~/foo"
@end group
@group
(substitute-in-file-name (compat-call file-name-quote "/ssh:host:bar/~/foo"))
@result{} "/ssh:host:/:bar/~/foo"
@end group
@end example
The macro cannot be used to suppress file name handlers from magic file
names (@pxref{Magic File Names,,,elisp}).
@xref{File Name Expansion,,,elisp}.
@end defun
@c copied from lispref/files.texi
@defun make-nearby-temp-file prefix &optional dir-flag suffix
This function is similar to @code{make-temp-file}, but it creates a
temporary file as close as possible to @code{default-directory}. If
@var{prefix} is a relative file name, and @code{default-directory} is a
remote file name or located on a mounted file systems, the temporary
file is created in the directory returned by the function
@code{temporary-file-directory}. Otherwise, the function
@code{make-temp-file} is used. @var{prefix}, @var{dir-flag} and
@var{suffix} have the same meaning as in @code{make-temp-file}.
@example
@group
(let ((default-directory "/ssh:remotehost:")) (make-nearby-temp-file
"foo")) @result{} "/ssh:remotehost:/tmp/foo232J6v"
@end group
@end example
@end defun
@c based on lisp/files.el
@defvar mounted-file-systems
A regular expression matching files names that are probably on a
mounted file system.
@end defvar
@c copied from lispref/fiels.texi
@defun temporary-file-directory
The directory for writing temporary files via
@code{make-nearby-temp-file}. In case of a remote
@code{default-directory}, this is a directory for temporary files on
that remote host. If such a directory does not exist, or
@code{default-directory} ought to be located on a mounted file system
(see @code{mounted-file-systems}), the function returns
@code{default-directory}. For a non-remote and non-mounted
@code{default-directory}, the value of the variable
@code{temporary-file-directory} is returned.
@xref{Unique File Names,,,elisp}.
@end defun
@defmac if-let* (bindings@dots{}) then &rest else
@code{if-let*} is mostly equivalent to @code{if-let}, with the
exception that the legacy @code{(if (@var{var} (test)) foo bar)}
syntax is not permitted.
@end defmac
@defmac when-let* (bindings@dots{}) then &rest else
@code{when-let*} is mostly equivalent to @code{when-let}, with the
exception that the legacy @code{(when-let (@var{var} (test)) foo bar)}
syntax is not permitted.
@end defmac
@defmac and-let* (bindings@dots{}) &rest body
A combination of @var{let*} and @var{and}, analogous to
@code{when-let*}. If all @var{bindings} are non-@code{nil} and
@var{body} is @code{nil}, then the result of the @code{and-let*} form
will be the last value bound in @var{bindings}.
@strong{@strong{Please Note:}} The implementation provided by Compat
does not include a bug that was observed with Emacs 26 (see
@uref{https://debbugs.gnu.org/cgi/bugreport.cgi?bug=31840}).
@end defmac
@c copied from lispref/files.texi
@defun file-local-name filename
This function returns the @emph{local part} of @var{filename}. This
is the part of the file's name that identifies it on the remote host,
and is typically obtained by removing from the remote file name the
parts that specify the remote host and the method of accessing it.
For example:
@smallexample
(file-local-name "/ssh:@var{user}@@@var{host}:/foo/bar") @result{}
"/foo/bar"
@end smallexample
For a remote @var{filename}, this function returns a file name which
could be used directly as an argument of a remote process
(@pxref{Asynchronous Processes,,,elisp}, and @pxref{Synchronous
Processes,,,elisp}), and as the program to run on the remote host. If
@var{filename} is local, this function returns it unchanged.
@xref{Magic File Names,,,elisp}.
@end defun
@defun read-multiple-choice prompt choices
Ask user a multiple choice question. @var{prompt} should be a string
that will be displayed as the prompt.
@var{choices} is an alist where the first element in each entry is a
character to be entered, the second element is a short name for the
entry to be displayed while prompting (if there's room, it might be
shortened), and the third, optional entry is a longer explanation that
will be displayed in a help buffer if the user requests more help.
See @ref{Reading One Event,Reading One Event,,elisp,}.
@end defun
@defun image-property
Defined in @code{image.el}.
This function can also be used as a generalised variable.
@end defun
@defun file-attribute-type
Return the field @emph{type} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@defun file-attribute-link-number
Return the field @emph{link-number} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@defun file-attribute-user-id
Return the field @emph{user-id} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@defun file-attribute-group-id
Return the field @emph{group-id} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@defun file-attribute-access-time
Return the field @emph{access-time} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@defun file-attribute-modification-time
Return the field @emph{modification-time} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@defun file-attribute-status-change-time
Return the field @emph{modification-time} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@defun file-attribute-size
Return the field @emph{size} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@defun file-attribute-modes
Return the field @emph{modes} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@defun file-attribute-inode-number
Return the field @emph{inode-number} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@defun file-attribute-device-number
Return the field @emph{device-number} as generated by @code{file-attributes}.
@xref{File Attributes,,,elisp}.
@end defun
@c based on lisp/files.el
@defun file-attribute-collect attributes &rest attr-names
Filter the file attributes @var{attributes}, as generated by
@code{file-attributes}, according to @var{attr-names}.
Valid attribute names for @var{attr-names} are: type, link-number,
user-id, group-id, access-time, modification-time, status-change-time,
size, modes, inode-number and device-number.
@example
@group
(file-attributes ".") @result{} (t 1 1000 1000 (25329 18215 325481 96000) (25325 15364 530263 840000) (25325 15364 530263 840000) 788 "drwxr-xr-x" t 137819 40)
@end group
@group
(file-attribute-collect (file-attributes ".") 'type 'modes
'inode-number) @result{} (t "drwxr-xr-x" 137819)
@end group
@end example
@end defun
@subsection Extended Definitions
These functions must be called explicitly via @code{compat-call},
since their calling convention or behavior was extended in Emacs 26.1:
@c copied from lispref/files.texi
@defun compat-call@ make-temp-file prefix &optional dir-flag suffix text
This function creates a temporary file and returns its name. Emacs
creates the temporary file's name by adding to @var{prefix} some
random characters that are different in each Emacs job. The result is
guaranteed to be a newly created file, containing @var{text} if that's
given as a string and empty otherwise. On MS-DOS, this function can
truncate @var{prefix} to fit into the 8+3 file-name limits. If
@var{prefix} is a relative file name, it is expanded against
@code{temporary-file-directory}.
The compatibility version adds support for handling the optional
argument @var{TEXT}.
@example
@group
(make-temp-file "foo")
@result{} "/tmp/foo232J6v"
@end group
@end example
When @code{make-temp-file} returns, the file has been created and is
empty. At that point, you should write the intended contents into the
file.
If @var{dir-flag} is non-@code{nil}, @code{make-temp-file} creates an
empty directory instead of an empty file. It returns the file name,
not the directory name, of that directory. @xref{Directory Names,,,elisp}.
If @var{suffix} is non-@code{nil}, @code{make-temp-file} adds it at
the end of the file name.
If @var{text} is a string, @code{make-temp-file} inserts it in the file.
To prevent conflicts among different libraries running in the same
Emacs, each Lisp program that uses @code{make-temp-file} should have its
own @var{prefix}. The number added to the end of @var{prefix}
distinguishes between the same application running in different Emacs
jobs. Additional added characters permit a large number of distinct
names even in one Emacs job.
@end defun
@defun compat-call@ assoc key alist &optional testfn
This function returns the first association for @var{key} in
@var{alist}, comparing @var{key} against the alist elements using
@var{testfn} if it is a function, and @code{equal} otherwise
(@pxref{Equality Predicates,,,elisp}). If @var{testfn} is a function,
it is called with two arguments: the @sc{car} of an element from
@var{alist} and @var{key}. The function returns @code{nil} if no
association in @var{alist} has a @sc{car} equal to @var{key}, as
tested by @var{testfn}.
@xref{Association Lists,,,elisp}.
The compatibility version adds support for handling the optional
argument @var{testfn}.
@end defun
@defun compat-call@ line-number-at-pos &optional pos absolute
This function returns the line number in the current buffer
corresponding to the buffer position @var{pos}. If @var{pos} is
@code{nil} or omitted, the current buffer position is used. If
@var{absolute} is @code{nil}, the default, counting starts at
@code{(point-min)}, so the value refers to the contents of the
accessible portion of the (potentially narrowed) buffer. If
@var{absolute} is non-@code{nil}, ignore any narrowing and return
@xref{Text Lines,,,elisp}.
The compatibility version adds support for handling the optional