compat.info (148655B)
1 This is doc23GpG6.info, produced by makeinfo version 6.8 from 2 compat.texi. 3 4 Copyright © 2022-2024 Free Software Foundation, Inc. 5 6 Permission is granted to copy, distribute and/or modify this 7 document under the terms of the GNU Free Documentation License, 8 Version 1.3 or any later version published by the Free Software 9 Foundation; with no Invariant Sections, with the Front-Cover Texts 10 being “A GNU Manual,” and with the Back-Cover Texts as in (a) 11 below. A copy of the license is included in the section entitled 12 “GNU Free Documentation License.” 13 14 (a) The FSF’s Back-Cover Text is: “You have the freedom to copy and 15 modify this GNU manual.” 16 17 INFO-DIR-SECTION Emacs 18 START-INFO-DIR-ENTRY 19 * Compat: (compat). Compatibility Library for Emacs Lisp. 20 END-INFO-DIR-ENTRY 21 22 23 File: doc23GpG6.info, Node: Top, Next: Introduction, Up: (dir) 24 25 "Compat" Manual 26 *************** 27 28 This manual documents the usage of the "Compat" Emacs lisp library, the 29 forward-compatibility library for Emacs Lisp, corresponding to version 30 30.0.0.0. 31 32 Copyright © 2022-2024 Free Software Foundation, Inc. 33 34 Permission is granted to copy, distribute and/or modify this 35 document under the terms of the GNU Free Documentation License, 36 Version 1.3 or any later version published by the Free Software 37 Foundation; with no Invariant Sections, with the Front-Cover Texts 38 being “A GNU Manual,” and with the Back-Cover Texts as in (a) 39 below. A copy of the license is included in the section entitled 40 “GNU Free Documentation License.” 41 42 (a) The FSF’s Back-Cover Text is: “You have the freedom to copy and 43 modify this GNU manual.” 44 45 * Menu: 46 47 * Introduction:: 48 * Support:: 49 * Development:: 50 * Function Index:: 51 * Variable Index:: 52 53 — The Detailed Node Listing — 54 55 Introduction 56 57 * Overview:: 58 * Usage:: 59 * Limitations:: 60 61 Support 62 63 * Emacs 25.1:: Compatibility support for Emacs 25.1 64 * Emacs 26.1:: Compatibility support for Emacs 26.1 65 * Emacs 27.1:: Compatibility support for Emacs 27.1 66 * Emacs 28.1:: Compatibility support for Emacs 28.1 67 * Emacs 29.1:: Compatibility support for Emacs 29.1 68 69 70 71 File: doc23GpG6.info, Node: Introduction, Next: Support, Prev: Top, Up: Top 72 73 1 Introduction 74 ************** 75 76 * Menu: 77 78 * Overview:: 79 * Usage:: 80 * Limitations:: 81 82 83 File: doc23GpG6.info, Node: Overview, Next: Usage, Up: Introduction 84 85 1.1 Overview 86 ============ 87 88 The objective of Compat is to provide "forwards compatibility" library 89 for Emacs Lisp. By using Compat, an Elisp package does not have to make 90 the decision to either use new and useful functionality or support old 91 versions of Emacs. 92 93 The library provides support back until Emacs 24.4. The intended 94 audience are package developers that are interested in using newer 95 developments, without having to break compatibility. 96 97 98 File: doc23GpG6.info, Node: Usage, Next: Limitations, Prev: Overview, Up: Introduction 99 100 1.2 Usage 101 ========= 102 103 The intended use-case for this library is for package developers to add 104 as a dependency in the header. The version of the Compat library 105 mirrors the version of Emacs releases. The current version of Compat 106 corresponds to the current Emacs release. 107 108 ;; Package-Requires: ((emacs "24.4") (compat "30.0.0.0")) 109 110 There is no need to depend on ‘emacs 24.4’ specifically. One can 111 choose any newer version, if features not provided by Compat necessitate 112 it, for example bug fixes or UI improvements. 113 114 In any file where compatibility forms are used, a 115 116 (require 'compat) 117 118 should be added early on. This will load all necessary Compat 119 definitions. Compat loads the ‘seq’ library which is preloaded by 120 default on Emacs 29. Note that if Compat is installed on a recent 121 version of Emacs, all of the definitions are disabled at compile time, 122 such that no negative performance impact is incurred. 123 124 A minimal version of Compat will be present in Emacs version 30 and 125 newer. Packages which are part of Emacs itself and want to take 126 advantage of Compat, can also use ‘(require 'compat)’. The advantage of 127 the inclusion of a minimal Compat in Emacs is that Compat will not be 128 installed if you require a version newer or equal than the current Emacs 129 version. For example, if a package depending on Emacs 25.1 and Compat 130 29.1 is installed on Emacs 30.1, Compat will not be pulled in as 131 dependency, since Emacs 30.1 already provides the required 132 functionality. 133 134 Compat provides replacement functions with extended functionality for 135 functions that are already defined, e.g., ‘sort’ or ‘assoc’. These 136 functions may have changed their calling convention (additional optional 137 arguments) or may have changed their behavior. These functions must be 138 looked up explicitly with ‘compat-function’ or called explicitly with 139 ‘compat-call’. We call them “Extended Definitions”. In contrast, newly 140 “Added Definitions” can be called as usual. The Compat manual 141 explicitly documents the calling convention of each compatibility 142 function. 143 144 (compat-call assoc key alist testfn) ;; Call extended `assoc' 145 (mapcan fun seq) ;; Call newly added `mapcan' 146 147 -- Macro: compat-call fun &rest args 148 This macro calls the compatibility function FUN with ARGS. Many 149 functions provided by Compat can be called directly without this 150 macro. However in the case where Compat provides an alternative 151 version of an existing function, the function call has to go 152 through ‘compat-call’. This happens for example when the calling 153 convention of a function has changed. 154 155 -- Macro: compat-function fun 156 This macro returns the compatibility function symbol for FUN. See 157 ‘compat-call’ for a more convenient macro to directly call 158 compatibility functions. 159 160 If Compat is used in Emacs core packages, the macros ‘compat-call’ 161 and ‘compat-function’ will be available in Emacs version 30 and newer. 162 163 The macros ‘compat-call’ and ‘compat-function’ are introduced by 164 Compat, since Compat does not advise or override existing functions. 165 Generally Compat is written in defensive style which is supposed to 166 reduce potential breakage, and to increase the chances of staying binary 167 compatible across releases. The extensive test coverage ensures that we 168 can maintain high quality, which is crucial for Compat which is not 169 restricted to a namespace like usual libraries. 170 171 If you intend to use a compatibility function in your code it is 172 recommended that you take a look at the test suite ‘compat-tests.el’. 173 There you can see the supported calling conventions, which are 174 guaranteed to work on the supported Emacs versions. We ensure this 175 using continuous integration. All functions provided by Compat are 176 covered by the test suite. There is a link to the corresponding test on 177 the first line of each definition. 178 179 You may want to subscribe to the compat-announce 180 (https://lists.sr.ht/~pkal/compat-announce) mailing list to be notified 181 when new versions are released or relevant changes are made. We also 182 provide a development mailing list 183 (https://lists.sr.ht/~pkal/compat-devel) (~pkal/compat-devel@lists.sr.ht 184 <~pkal/compat-devel@lists.sr.ht>). 185 186 187 File: doc23GpG6.info, Node: Limitations, Prev: Usage, Up: Introduction 188 189 1.3 Limitations 190 =============== 191 192 The Compat library has a number of limitations. Complete backwards 193 compatibility cannot be provided due to the scope of Compat and for 194 technical reasons. The scope is intentionally restricted in order to 195 limit the size of Compat and to ensure that the library stays 196 maintainable. 197 198 Emacs version 24.4 is chosen as the oldest version supported by 199 Compat, since Elisp has seen significant changes at that version. Since 200 24.4 Emacs major versions consistently bump the major version number. 201 On the library level, subr-x was introduced in 24.4. Most popular Emacs 202 packages already require 24.4 or even newer versions of Emacs. 203 Supporting for more historical Emacs versions would complicate 204 maintenance while only few packages and users would benefit. 205 206 Below we list a number of reasons why certain functionality cannot be 207 provided. Note that in some special cases exceptions can be made and 208 functions can still be added to Compat even if they satisfy the criteria 209 from the list. In case you miss functionality which you think should 210 belong here, a *note report: Development. would be much appreciated. 211 212 • The additional functionality is a command or a user-facing minor or 213 major mode. Compat is limited to functionality on the “library 214 level”. Generally functions provided by Compat are 215 non-interactive, such that the user interface (M-x) is unaffected 216 by the presence of Compat. 217 218 • The function is not useful for package authors or not intended to 219 be used by packages, but is only useful on the configuration level. 220 The macro ‘setopt’ is such an example. 221 222 • Private (double dashed) functions are not ported back. If Compat 223 includes some private functions, they are meant purely for internal 224 usage. 225 226 • The added or extended function belongs to the “application level” 227 and not the “library level”. Features which are not preloaded 228 often belong to the “application level”. Application examples are 229 programming modes or modes like Dired, IRC and Gnus. If these 230 modes are extended with new functions, these are not ported back. 231 232 • An existing function or macro was extended by some new 233 functionality. To support these cases, the function or macro would 234 have to be advised. Since this is invasive and adds significant 235 overhead, even when the new feature is not used, Compat does not 236 use advices. As a compromise, compatibility functions and macros 237 with a changed calling convention or behavior can be accessed via 238 the ‘compat-function’ and ‘compat-call’ macros. In this manual we 239 call such definitions “Extended Definitions”. An example is the 240 function ‘plist-get’. Note that extended functions are subject to 241 closer scrutiny, since their usage via ‘compat-call’ is not 242 completely painless. If a particular extended function does not 243 see much usage or the extension yields only marginal benefits, we 244 may not provide it as part of Compat. 245 246 • Bug fixes are usually not ported back as part of Compat. Sometimes 247 library functions show wrong behavior for edge cases. In those 248 cases Compat could in principle provide a compatibility function 249 which is invoked via ‘compat-call’. Such extended definitions 250 would increase the maintenance burden of Compat. At the same time 251 the benefits would be small given that Compat does not override 252 existing definitions. 253 254 • The definition belongs to an Emacs core package, which is also 255 distributed via ELPA. Compat does not have to provide backward 256 compatibility for core packages since the updated package can be 257 installed directly from ELPA. Examples include the libraries xref, 258 project, seq, map and transient. 259 260 • New functionality depends on an entire new, non-trivial core 261 library, which is infeasible to duplicate within Compat. If a 262 backport of such a library is required, the preferred approach is 263 to either release the library separately on GNU ELPA as a core 264 package or as a separately maintained GNU ELPA package. An example 265 is the iso8601 library. 266 267 • New functionality was implemented in the C core, or depends on 268 external libraries that cannot be reasonably duplicated in the 269 scope of a compatibility library. Sometimes new functions on the C 270 level rely on internal data structures, which we cannot access, 271 rendering a backport impossible. For example a missing libxml or 272 libtreesitter cannot be emulated. 273 274 • The semantics of Elisp changed on a deep level. For example the 275 addition of big integer support in Emacs 27.1 cannot be replicated 276 on the level of Compat. 277 278 279 File: doc23GpG6.info, Node: Support, Next: Development, Prev: Introduction, Up: Top 280 281 2 Support 282 ********* 283 284 This section goes into the features that Compat manages and doesn’t 285 manage to provide for each Emacs version. 286 287 * Menu: 288 289 * Emacs 25.1:: Compatibility support for Emacs 25.1 290 * Emacs 26.1:: Compatibility support for Emacs 26.1 291 * Emacs 27.1:: Compatibility support for Emacs 27.1 292 * Emacs 28.1:: Compatibility support for Emacs 28.1 293 * Emacs 29.1:: Compatibility support for Emacs 29.1 294 295 296 File: doc23GpG6.info, Node: Emacs 25.1, Next: Emacs 26.1, Up: Support 297 298 2.1 Emacs 25.1 299 ============== 300 301 2.1.1 Added Definitions 302 ----------------------- 303 304 The following functions and macros are implemented in Emacs 25.1. These 305 functions are made available by Compat on Emacs versions older than 306 25.1. 307 308 -- User Option: text-quoting-style 309 The value of this user option is a symbol that specifies the style 310 Emacs should use for single quotes in the wording of help and 311 messages. If the option’s value is ‘curve’, the style is ‘like 312 this’ with curved single quotes. If the value is ‘straight’, the 313 style is 'like this' with straight apostrophes. If the value is 314 ‘grave’, quotes are not translated and the style is `like this' 315 with grave accent and apostrophe, the standard style before Emacs 316 version 25. The default value ‘nil’ acts like ‘curve’ if curved 317 single quotes seem to be displayable, and like ‘grave’ otherwise. 318 319 This option is useful on platforms that have problems with curved 320 quotes. You can customize it freely according to your personal 321 preference. 322 323 -- Function: region-bounds 324 Return the boundaries of the region. Value is a list of one or 325 more cons cells of the form ‘(start . end)’. It will have more 326 than one cons cell when the region is non-contiguous, see 327 ‘region-noncontiguous-p’ and ‘extract-rectangle-bounds’. 328 329 -- Function: region-noncontiguous-p 330 Return non-nil if the region contains several pieces. An example 331 is a rectangular region handled as a list of separate contiguous 332 regions for each line. 333 334 -- Macro: save-mark-and-excursion body... 335 This macro is like ‘save-excursion’, but also saves and restores 336 the mark location and ‘mark-active’. This macro does what 337 ‘save-excursion’ did before Emacs 25.1. 338 339 -- Function: format-message string &rest objects 340 This function acts like ‘format’, except it also converts any grave 341 accents (`) and apostrophes (') in STRING as per the value of 342 ‘text-quoting-style’. 343 344 Typically grave accent and apostrophe in the format translate to 345 matching curved quotes, e.g., "Missing `%s'" might result in 346 "Missing ‘foo’". *Note (elisp)Text Quoting Style::, for how to 347 influence or inhibit this translation. 348 349 *note (elisp)Formatting Strings::. 350 351 -- Function: directory-name-p filename 352 This function returns non-‘nil’ if FILENAME ends with a directory 353 separator character. This is the forward slash ‘/’ on GNU and 354 other POSIX-like systems; MS-Windows and MS-DOS recognize both the 355 forward slash and the backslash ‘\’ as directory separators. 356 357 *Note (elisp)Directory Names::. 358 359 -- Function: string-greaterp string1 string2 360 This function returns the result of comparing STRING1 and STRING2 361 in the opposite order, i.e., it is equivalent to calling 362 ‘(string-lessp STRING2 STRING1)’. 363 364 *Note (elisp)Text Comparison::. 365 366 -- Macro: with-file-modes mode body... 367 This macro evaluates the BODY forms with the default permissions 368 for new files temporarily set to MODES (whose value is as for 369 ‘set-file-modes’ above). When finished, it restores the original 370 default file permissions, and returns the value of the last form in 371 BODY. 372 373 This is useful for creating private files, for example. 374 375 *Note (elisp)Changing Files::. 376 377 -- Function: alist-get key alist &optional default remove 378 This function is similar to ‘assq’. It finds the first association 379 ‘(KEY . VALUE)’ by comparing KEY with ALIST elements, and, if 380 found, returns the VALUE of that association. If no association is 381 found, the function returns DEFAULT. 382 383 This is a generalized variable (*note (elisp)Generalized 384 Variables::) that can be used to change a value with ‘setf’. When 385 using it to set a value, optional argument REMOVE non-‘nil’ means 386 to remove KEY’s association from ALIST if the new value is ‘eql’ to 387 DEFAULT. 388 389 *note (elisp)Association Lists::. 390 391 -- Macro: if-let (bindings...) then &rest else... 392 As with ‘let*’, BINDINGS will consist of ‘(SYMBOL VALUE-FORM)’ 393 entries that are evaluated and bound sequentially. If all 394 VALUE-FORM evaluate to non-‘nil’ values, then THEN is evaluated as 395 were the case with a regular ‘let*’ expression, with all the 396 variables bound. If any VALUE-FORM evaluates to ‘nil’, ELSE is 397 evaluated, without any bound variables. 398 399 A binding may also optionally drop the SYMBOL, and simplify to 400 ‘(VALUE-FORM)’ if only the test is of interest. 401 402 For the sake of backwards compatibility, it is possible to write a 403 single binding without a binding list: 404 405 (if-let* (SYMBOL (test)) foo bar) 406 ≡ 407 (if-let* ((SYMBOL (test))) foo bar) 408 409 -- Macro: when-let (bindings...) &rest body 410 As with ‘when’, if one is only interested in the case where all 411 BINDINGS are non-nil. Otherwise BINDINGS are interpreted just as 412 they are by ‘if-let*’. 413 414 -- Function: hash-table-empty hash-table 415 Check whether HASH-TABLE is empty (has 0 elements). 416 417 -- Macro: thread-first &rest forms 418 Combine FORMS into a single expression by “threading” each element 419 as the _first_ argument of their successor. Elements of FORMS can 420 either be an list of an atom. 421 422 For example, consider the threading expression and it’s equivalent 423 macro expansion: 424 425 (thread-first 426 5 427 (+ 20) 428 (/ 25) 429 - 430 (+ 40)) 431 ≡ 432 (+ (- (/ (+ 5 20) 25)) 40) 433 434 Note how the single ‘-’ got converted into a list before threading. 435 This example uses arithmetic functions, but ‘thread-first’ is not 436 restricted to arithmetic or side-effect free code. 437 438 -- Macro: thread-last &rest forms 439 Combine FORMS into a single expression by “threading” each element 440 as the _last_ argument of their successor. Elements of FORMS can 441 either be an list of an atom. 442 443 For example, consider the threading expression and it’s equivalent 444 macro expansion: 445 446 (thread-first 447 5 448 (+ 20) 449 (/ 25) 450 - 451 (+ 40)) 452 ≡ 453 (+ 40 (- (/ 25 (+ 20 5)))) 454 455 Note how the single ‘-’ got converted into a list before threading. 456 This example uses arithmetic functions, but ‘thread-last’ is not 457 restricted to arithmetic or side-effect free code. 458 459 -- Function: macroexpand-1 form &optional environment 460 This function expands macros like ‘macroexpand’, but it only 461 performs one step of the expansion: if the result is another macro 462 call, ‘macroexpand-1’ will not expand it. 463 464 *Note Expansion: (elisp)Expansion. 465 466 -- Function: macroexp-quote e 467 Return an expression E such that ‘(eval e)’ is V. 468 469 -- Function: macroexp-parse body 470 Parse a function BODY into ‘(declarations . exps)’. 471 472 -- Function: bool-vector &rest objects 473 This function creates and returns a bool-vector whose elements are 474 the arguments, OBJECTS. 475 476 *Note (elisp)Bool-Vectors::. 477 478 2.1.2 Missing Definitions 479 ------------------------- 480 481 Compat does not provide support for the following Lisp features 482 implemented in 25.1: 483 484 • The function ‘macroexp-macroexpand’. 485 • The macro ‘macroexp-let2*’. 486 • The function ‘directory-files-recursively’. 487 • New ‘pcase’ patterns. 488 • The hook ‘prefix-command-echo-keystrokes-functions’ and 489 ‘prefix-command-preserve-state-hook’. 490 • The hook ‘pre-redisplay-functions’. 491 • The function ‘make-process’. 492 • Support for the variable ‘inhibit-message’. 493 • The ‘define-inline’ functionality. 494 • The functions ‘string-collate-lessp’ and ‘string-collate-equalp’. 495 • The function ‘funcall-interactively’. 496 • The function ‘buffer-substring-with-bidi-context’. 497 • The function ‘font-info’. 498 • The function ‘default-font-width’. 499 • The function ‘window-font-height’ and ‘window-font-width’. 500 • The function ‘window-max-chars-per-line’. 501 • The function ‘set-binary-mode’. 502 • The functions ‘bufferpos-to-filepos’ and ‘filepos-to-bufferpos’. 503 • The ‘thunk’ library. 504 505 506 File: doc23GpG6.info, Node: Emacs 26.1, Next: Emacs 27.1, Prev: Emacs 25.1, Up: Support 507 508 2.2 Emacs 26.1 509 ============== 510 511 2.2.1 Added Definitions 512 ----------------------- 513 514 The following functions and macros are implemented in Emacs 26.1. These 515 functions are made available by Compat on Emacs versions older than 516 26.1. 517 518 -- Function: assoc-delete-all key alist 519 This function is like ‘assq-delete-all’ except that it uses ‘equal’ 520 to compare elements. 521 522 -- Function: read-answer question answers 523 This function prompts the user with text in QUESTION, which should 524 end in the ‘SPC’ character. The function includes in the prompt 525 the possible responses in ANSWERS by appending them to the end of 526 QUESTION. The possible responses are provided in ANSWERS as an 527 alist whose elements are of the following form: 528 529 (LONG-ANSWER SHORT-ANSWER HELP-MESSAGE) 530 531 where LONG-ANSWER is the complete text of the user response, a 532 string; SHORT-ANSWER is a short form of the same response, a single 533 character or a function key; and HELP-MESSAGE is the text that 534 describes the meaning of the answer. If the variable 535 ‘read-answer-short’ is non-‘nil’, the prompt will show the short 536 variants of the possible answers and the user is expected to type 537 the single characters/keys shown in the prompt; otherwise the 538 prompt will show the long variants of the answers, and the user is 539 expected to type the full text of one of the answers and end by 540 pressing <RET>. If ‘use-dialog-box’ is non-‘nil’, and this 541 function was invoked by mouse events, the question and the answers 542 will be displayed in a GUI dialog box. 543 544 The function returns the text of the LONG-ANSWER selected by the 545 user, regardless of whether long or short answers were shown in the 546 prompt and typed by the user. 547 548 Here is an example of using this function: 549 550 (let ((read-answer-short t)) 551 (read-answer "Foo " 552 '(("yes" ?y "perform the action") 553 ("no" ?n "skip to the next") 554 ("all" ?! "perform for the rest without more questions") 555 ("help" ?h "show help") 556 ("quit" ?q "exit")))) 557 558 -- Function: mapcan function sequence 559 This function applies FUNCTION to each element of SEQUENCE, like 560 ‘mapcar’, but instead of collecting the results into a list, it 561 returns a single list with all the elements of the results (which 562 must be lists), by altering the results (using ‘nconc’; *note 563 (elisp)Rearrangement::). Like with ‘mapcar’, SEQUENCE can be of 564 any type except a char-table. 565 566 ;; Contrast this: (mapcar #'list '(a b c d)) ⇒ ((a) (b) (c) 567 (d)) ;; with this: (mapcan #'list '(a b c d)) ⇒ (a b c d) 568 569 *Note (elisp)Mapping Functions::. 570 571 -- Function: cXXXr 572 -- Function: cXXXXr 573 *Note (elisp)List Elements::. 574 575 -- Function: gensym &optional prefix 576 This function returns a symbol using ‘make-symbol’, whose name is 577 made by appending ‘gensym-counter’ to PREFIX and incrementing that 578 counter, guaranteeing that no two calls to this function will 579 generate a symbol with the same name. The prefix defaults to 580 ‘"g"’. 581 582 -- Variable: gensym-counter 583 See ‘gensym’. 584 585 -- Function: buffer-hash &optional buffer-or-name 586 Return a hash of BUFFER-OR-NAME. If ‘nil’, this defaults to the 587 current buffer. As opposed to ‘secure-hash’, this function 588 computes the hash based on the internal representation of the 589 buffer, disregarding any coding systems. It’s therefore only 590 useful when comparing two buffers running in the same Emacs, and is 591 not guaranteed to return the same hash between different Emacs 592 versions. It should be somewhat more efficient on larger buffers 593 than ‘secure-hash’ is, and should not allocate more memory. 594 595 -- Macro: file-name-unquote name 596 This macro removes the quotation prefix ‘/:’ from the file NAME, if 597 any. If NAME is a remote file name, the local part of NAME is 598 unquoted. 599 600 -- Function: file-name-quoted-p name 601 This macro returns non-‘nil’, when NAME is quoted with the prefix 602 ‘/:’. If NAME is a remote file name, the local part of NAME is 603 checked. 604 605 *Note (elisp)File Name Expansion::. 606 607 -- Function: file-name-quote name 608 This macro adds the quotation prefix ‘/:’ to the file NAME. For a 609 local file NAME, it prefixes NAME with ‘/:’. If NAME is a remote 610 file name, the local part of NAME (*note (elisp)Magic File Names::) 611 is quoted. If NAME is already a quoted file name, NAME is returned 612 unchanged. 613 614 (substitute-in-file-name (compat-call file-name-quote "bar/~/foo")) ⇒ 615 "/:bar/~/foo" 616 617 (substitute-in-file-name (compat-call file-name-quote "/ssh:host:bar/~/foo")) 618 ⇒ "/ssh:host:/:bar/~/foo" 619 620 The macro cannot be used to suppress file name handlers from magic 621 file names (*note (elisp)Magic File Names::). 622 623 *Note (elisp)File Name Expansion::. 624 625 -- Function: make-nearby-temp-file prefix &optional dir-flag suffix 626 This function is similar to ‘make-temp-file’, but it creates a 627 temporary file as close as possible to ‘default-directory’. If 628 PREFIX is a relative file name, and ‘default-directory’ is a remote 629 file name or located on a mounted file systems, the temporary file 630 is created in the directory returned by the function 631 ‘temporary-file-directory’. Otherwise, the function 632 ‘make-temp-file’ is used. PREFIX, DIR-FLAG and SUFFIX have the 633 same meaning as in ‘make-temp-file’. 634 635 (let ((default-directory "/ssh:remotehost:")) (make-nearby-temp-file 636 "foo")) ⇒ "/ssh:remotehost:/tmp/foo232J6v" 637 638 -- Variable: mounted-file-systems 639 A regular expression matching files names that are probably on a 640 mounted file system. 641 642 -- Function: temporary-file-directory 643 The directory for writing temporary files via 644 ‘make-nearby-temp-file’. In case of a remote ‘default-directory’, 645 this is a directory for temporary files on that remote host. If 646 such a directory does not exist, or ‘default-directory’ ought to be 647 located on a mounted file system (see ‘mounted-file-systems’), the 648 function returns ‘default-directory’. For a non-remote and 649 non-mounted ‘default-directory’, the value of the variable 650 ‘temporary-file-directory’ is returned. 651 652 *Note (elisp)Unique File Names::. 653 654 -- Macro: if-let* (bindings...) then &rest else 655 ‘if-let*’ is mostly equivalent to ‘if-let’, with the exception that 656 the legacy ‘(if (VAR (test)) foo bar)’ syntax is not permitted. 657 658 -- Macro: when-let* (bindings...) then &rest else 659 ‘when-let*’ is mostly equivalent to ‘when-let’, with the exception 660 that the legacy ‘(when-let (VAR (test)) foo bar)’ syntax is not 661 permitted. 662 663 -- Macro: and-let* (bindings...) &rest body 664 A combination of LET* and AND, analogous to ‘when-let*’. If all 665 BINDINGS are non-‘nil’ and BODY is ‘nil’, then the result of the 666 ‘and-let*’ form will be the last value bound in BINDINGS. 667 668 **Please Note:** The implementation provided by Compat does not 669 include a bug that was observed with Emacs 26 (see 670 <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=31840>). 671 672 -- Function: file-local-name filename 673 This function returns the _local part_ of FILENAME. This is the 674 part of the file’s name that identifies it on the remote host, and 675 is typically obtained by removing from the remote file name the 676 parts that specify the remote host and the method of accessing it. 677 For example: 678 679 (file-local-name "/ssh:USER@HOST:/foo/bar") ⇒ 680 "/foo/bar" 681 682 For a remote FILENAME, this function returns a file name which 683 could be used directly as an argument of a remote process (*note 684 (elisp)Asynchronous Processes::, and *note (elisp)Synchronous 685 Processes::), and as the program to run on the remote host. If 686 FILENAME is local, this function returns it unchanged. 687 688 *Note (elisp)Magic File Names::. 689 690 -- Function: read-multiple-choice prompt choices 691 Ask user a multiple choice question. PROMPT should be a string 692 that will be displayed as the prompt. 693 694 CHOICES is an alist where the first element in each entry is a 695 character to be entered, the second element is a short name for the 696 entry to be displayed while prompting (if there’s room, it might be 697 shortened), and the third, optional entry is a longer explanation 698 that will be displayed in a help buffer if the user requests more 699 help. 700 701 See *note Reading One Event: (elisp)Reading One Event. 702 703 -- Function: image-property 704 Defined in ‘image.el’. 705 706 This function can also be used as a generalised variable. 707 708 -- Function: file-attribute-type 709 Return the field _type_ as generated by ‘file-attributes’. 710 711 *Note (elisp)File Attributes::. 712 713 -- Function: file-attribute-link-number 714 Return the field _link-number_ as generated by ‘file-attributes’. 715 716 *Note (elisp)File Attributes::. 717 718 -- Function: file-attribute-user-id 719 Return the field _user-id_ as generated by ‘file-attributes’. 720 721 *Note (elisp)File Attributes::. 722 723 -- Function: file-attribute-group-id 724 Return the field _group-id_ as generated by ‘file-attributes’. 725 726 *Note (elisp)File Attributes::. 727 728 -- Function: file-attribute-access-time 729 Return the field _access-time_ as generated by ‘file-attributes’. 730 731 *Note (elisp)File Attributes::. 732 733 -- Function: file-attribute-modification-time 734 Return the field _modification-time_ as generated by 735 ‘file-attributes’. 736 737 *Note (elisp)File Attributes::. 738 739 -- Function: file-attribute-status-change-time 740 Return the field _modification-time_ as generated by 741 ‘file-attributes’. 742 743 *Note (elisp)File Attributes::. 744 745 -- Function: file-attribute-size 746 Return the field _size_ as generated by ‘file-attributes’. 747 748 *Note (elisp)File Attributes::. 749 750 -- Function: file-attribute-modes 751 Return the field _modes_ as generated by ‘file-attributes’. 752 753 *Note (elisp)File Attributes::. 754 755 -- Function: file-attribute-inode-number 756 Return the field _inode-number_ as generated by ‘file-attributes’. 757 758 *Note (elisp)File Attributes::. 759 760 -- Function: file-attribute-device-number 761 Return the field _device-number_ as generated by ‘file-attributes’. 762 763 *Note (elisp)File Attributes::. 764 765 -- Function: file-attribute-collect attributes &rest attr-names 766 Filter the file attributes ATTRIBUTES, as generated by 767 ‘file-attributes’, according to ATTR-NAMES. 768 769 Valid attribute names for ATTR-NAMES are: type, link-number, 770 user-id, group-id, access-time, modification-time, 771 status-change-time, size, modes, inode-number and device-number. 772 773 (file-attributes ".") ⇒ (t 1 1000 1000 (25329 18215 325481 96000) (25325 15364 530263 840000) (25325 15364 530263 840000) 788 "drwxr-xr-x" t 137819 40) 774 (file-attribute-collect (file-attributes ".") 'type 'modes 775 'inode-number) ⇒ (t "drwxr-xr-x" 137819) 776 777 2.2.2 Extended Definitions 778 -------------------------- 779 780 These functions must be called explicitly via ‘compat-call’, since their 781 calling convention or behavior was extended in Emacs 26.1: 782 783 -- Function: compat-call make-temp-file prefix &optional dir-flag 784 suffix text 785 This function creates a temporary file and returns its name. Emacs 786 creates the temporary file’s name by adding to PREFIX some random 787 characters that are different in each Emacs job. The result is 788 guaranteed to be a newly created file, containing TEXT if that’s 789 given as a string and empty otherwise. On MS-DOS, this function 790 can truncate PREFIX to fit into the 8+3 file-name limits. If 791 PREFIX is a relative file name, it is expanded against 792 ‘temporary-file-directory’. 793 794 The compatibility version adds support for handling the optional 795 argument TEXT. 796 797 (make-temp-file "foo") 798 ⇒ "/tmp/foo232J6v" 799 800 When ‘make-temp-file’ returns, the file has been created and is 801 empty. At that point, you should write the intended contents into 802 the file. 803 804 If DIR-FLAG is non-‘nil’, ‘make-temp-file’ creates an empty 805 directory instead of an empty file. It returns the file name, not 806 the directory name, of that directory. *Note (elisp)Directory 807 Names::. 808 809 If SUFFIX is non-‘nil’, ‘make-temp-file’ adds it at the end of the 810 file name. 811 812 If TEXT is a string, ‘make-temp-file’ inserts it in the file. 813 814 To prevent conflicts among different libraries running in the same 815 Emacs, each Lisp program that uses ‘make-temp-file’ should have its 816 own PREFIX. The number added to the end of PREFIX distinguishes 817 between the same application running in different Emacs jobs. 818 Additional added characters permit a large number of distinct names 819 even in one Emacs job. 820 821 -- Function: compat-call assoc key alist &optional testfn 822 This function returns the first association for KEY in ALIST, 823 comparing KEY against the alist elements using TESTFN if it is a 824 function, and ‘equal’ otherwise (*note (elisp)Equality 825 Predicates::). If TESTFN is a function, it is called with two 826 arguments: the CAR of an element from ALIST and KEY. The function 827 returns ‘nil’ if no association in ALIST has a CAR equal to KEY, as 828 tested by TESTFN. 829 830 *Note (elisp)Association Lists::. 831 832 The compatibility version adds support for handling the optional 833 argument TESTFN. 834 835 -- Function: compat-call line-number-at-pos &optional pos absolute 836 This function returns the line number in the current buffer 837 corresponding to the buffer position POS. If POS is ‘nil’ or 838 omitted, the current buffer position is used. If ABSOLUTE is 839 ‘nil’, the default, counting starts at ‘(point-min)’, so the value 840 refers to the contents of the accessible portion of the 841 (potentially narrowed) buffer. If ABSOLUTE is non-‘nil’, ignore 842 any narrowing and return 843 844 *Note (elisp)Text Lines::. 845 846 The compatibility version adds support for handling the optional 847 argument ABSOLUTE. 848 849 -- Function: compat-call alist-get key alist &optional default remove 850 testfn 851 *Note (elisp)Association Lists::. This function is similar to 852 ‘assq’. It finds the first association ‘(KEY . VALUE)’ by 853 comparing KEY with ALIST elements, and, if found, returns the VALUE 854 of that association. If no association is found, the function 855 returns DEFAULT. Comparison of KEY against ALIST elements uses the 856 function specified by TESTFN, defaulting to ‘eq’. 857 858 *Note (elisp)Association Lists::. 859 860 The compatibility version handles the optional argument TESTFN. It 861 can also be used as a *note Generalized Variables: 862 (elisp)generalised variable. 863 864 -- Function: compat-call string-trim-left string &optional regexp 865 Remove the leading text that matches REGEXP from STRING. REGEXP 866 defaults to ‘[ \t\n\r]+’. 867 868 *Note (elisp)Creating Strings::. 869 870 The compatibility version handles the optional argument REGEXP. 871 872 -- Function: compat-call string-trim-right string &optional regexp 873 Remove the trailing text that matches REGEXP from STRING. REGEXP 874 defaults to ‘[ \t\n\r]+’. 875 876 *Note (elisp)Creating Strings::. 877 878 The compatibility version handles the optional argument REGEXP. 879 880 -- Function: compat-call string-trim string &optional trim-left 881 trim-right 882 Remove the leading text that matches TRIM-LEFT and trailing text 883 that matches TRIM-RIGHT from STRING. Both regexps default to ‘[ 884 \t\n\r]+’. 885 886 *Note (elisp)Creating Strings::. 887 888 The compatibility version handles the optional arguments TRIM-LEFT 889 and TRIM-RIGHT. 890 891 2.2.3 Missing Definitions 892 ------------------------- 893 894 Compat does not provide support for the following Lisp features 895 implemented in 26.1: 896 897 • The function ‘func-arity’. 898 • The function ‘secure-hash-algorithms’. 899 • The function ‘gnutls-available-p’. 900 • Support for records and record functions. 901 • The function ‘mapbacktrace’. 902 • The function ‘file-name-case-insensitive-p’. 903 • The additional elements of ‘parse-partial-sexp’. 904 • The function ‘add-variable-watcher’. 905 • The function ‘undo-amalgamate-change-group’. 906 • The function ‘char-from-name’ 907 • Signalling errors when ‘length’ or ‘member’ deal with list cycles. 908 • The function ‘frame-list-z-order’. 909 • The function ‘frame-restack’. 910 • All changes related to ‘display-buffer’. 911 • The function ‘window-swap-states’. 912 • The function ‘string-version-lessp’. 913 • The ‘xdg’ library. 914 • The ‘svg’ library (published separately as a :core package). 915 916 917 File: doc23GpG6.info, Node: Emacs 27.1, Next: Emacs 28.1, Prev: Emacs 26.1, Up: Support 918 919 2.3 Emacs 27.1 920 ============== 921 922 2.3.1 Added Definitions 923 ----------------------- 924 925 The following functions and macros are implemented in Emacs 27.1. These 926 functions are made available by Compat on Emacs versions older than 927 27.1. 928 929 -- Function: major-mode-suspend 930 This function works like ‘fundamental-mode’, in that it kills all 931 buffer-local variables, but it also records the major mode in 932 effect, so that it could subsequently be restored. This function 933 and ‘major-mode-restore’ (described next) are useful when you need 934 to put a buffer under some specialized mode other than the one 935 Emacs chooses for it automatically, but would also like to be able 936 to switch back to the original mode later. 937 938 -- Function: major-mode-restore &optional avoided-modes 939 This function restores the major mode recorded by 940 ‘major-mode-suspend’. If no major mode was recorded, this function 941 calls ‘normal-mode’, but tries to force it not to choose any modes 942 in AVOIDED-MODES, if that argument is non-‘nil’. 943 944 -- Function: ring-resize ring size 945 Set the size of RING to SIZE. If the new size is smaller, then the 946 oldest items in the ring are discarded. 947 948 -- Function: minibuffer-history-value 949 Return the value of the minibuffer input history list. If 950 MINIBUFFER-HISTORY-VARIABLE points to a buffer-local variable and 951 the minibuffer is active, return the buffer-local value for the 952 buffer that was current when the minibuffer was activated." 953 954 -- Macro: with-minibuffer-selected-window &rest body 955 Execute the forms in BODY from the minibuffer in its original 956 window. When used in a minibuffer window, select the window 957 selected just before the minibuffer was activated, and execute the 958 forms. 959 960 -- Function: read-char-from-minibuffer prompt &optional chars history 961 This function uses the minibuffer to read and return a single 962 character. Optionally, it ignores any input that is not a member 963 of CHARS, a list of accepted characters. The HISTORY argument 964 specifies the history list symbol to use; if it is omitted or 965 ‘nil’, this function doesn’t use the history. 966 967 If you bind ‘help-form’ to a non-‘nil’ value while calling 968 ‘read-char-from-minibuffer’, then pressing ‘help-char’ causes it to 969 evaluate ‘help-form’ and display the result. 970 971 -- Function: bignump object 972 This predicate tests whether its argument is a large integer, and 973 returns ‘t’ if so, ‘nil’ otherwise. Unlike small integers, large 974 integers can be ‘=’ or ‘eql’ even if they are not ‘eq’. 975 976 -- Function: fixnump object 977 This predicate tests whether its argument is a small integer, and 978 returns ‘t’ if so, ‘nil’ otherwise. Small integers can be compared 979 with ‘eq’. 980 981 -- Special Form: with-suppressed-warnings warnings body... 982 In execution, this is equivalent to ‘(progn BODY...)’, but the 983 compiler does not issue warnings for the specified conditions in 984 BODY. WARNINGS is an association list of warning symbols and 985 function/variable symbols they apply to. For instance, if you wish 986 to call an obsolete function called ‘foo’, but want to suppress the 987 compilation warning, say: 988 989 (with-suppressed-warnings ((obsolete foo)) 990 (foo ...)) 991 992 -- Function: proper-list-p object 993 This function returns the length of OBJECT if it is a proper list, 994 ‘nil’ otherwise (*note (elisp)Cons Cells::). In addition to 995 satisfying ‘listp’, a proper list is neither circular nor dotted. 996 997 (proper-list-p '(a b c)) ⇒ 3 998 (proper-list-p '(a b . c)) ⇒ nil 999 1000 *Note (elisp)List-related Predicates::. 1001 1002 -- Function: string-distance string1 string2 &optional bytecompare 1003 This function returns the _Levenshtein distance_ between the source 1004 string STRING1 and the target string STRING2. The Levenshtein 1005 distance is the number of single-character changes—deletions, 1006 insertions, or replacements—required to transform the source string 1007 into the target string; it is one possible definition of the _edit 1008 distance_ between strings. 1009 1010 Letter-case of the strings is significant for the computed 1011 distance, but their text properties are ignored. If the optional 1012 argument BYTECOMPARE is non-‘nil’, the function calculates the 1013 distance in terms of bytes instead of characters. The byte-wise 1014 comparison uses the internal Emacs representation of characters, so 1015 it will produce inaccurate results for multibyte strings that 1016 include raw bytes (*note (elisp)Text Representations::); make the 1017 strings unibyte by encoding them (*note (elisp)Explicit Encoding::) 1018 if you need accurate results with raw bytes. 1019 1020 *Note (elisp)Text Comparison::. 1021 1022 -- Macro: ignore-errors body... 1023 This construct executes BODY, ignoring any errors that occur during 1024 its execution. If the execution is without error, ‘ignore-errors’ 1025 returns the value of the last form in BODY; otherwise, it returns 1026 ‘nil’. 1027 1028 Here’s the example at the beginning of this subsection rewritten 1029 using ‘ignore-errors’: 1030 1031 (ignore-errors (delete-file filename)) 1032 1033 *Note (elisp)Handling Errors::. 1034 1035 -- Macro: dolist-with-progress-reporter (var count [result]) 1036 reporter-or-message body... 1037 This is another convenience macro that works the same way as 1038 ‘dolist’ does, but also reports loop progress using the functions 1039 described above. As in ‘dotimes-with-progress-reporter’, 1040 ‘reporter-or-message’ can be a progress reporter or a string. You 1041 can rewrite the previous example with this macro as follows: 1042 1043 (dolist-with-progress-reporter (k (number-sequence 0 500)) "Collecting 1044 some mana for Emacs..." (sit-for 0.01)) 1045 1046 *Note (elisp)Progress::. 1047 1048 -- Function: flatten-tree tree 1049 This function returns a “flattened” copy of TREE, that is, a list 1050 containing all the non-‘nil’ terminal nodes, or leaves, of the tree 1051 of cons cells rooted at TREE. Leaves in the returned list are in 1052 the same order as in TREE. 1053 1054 (flatten-tree '(1 (2 . 3) nil (4 5 (6)) 7)) ⇒(1 2 3 4 5 6 7) 1055 1056 *Note (elisp)Building Lists::. 1057 1058 -- Function: xor condition1 condition2 1059 This function returns the boolean exclusive-or of CONDITION1 and 1060 CONDITION2. That is, ‘xor’ returns ‘nil’ if either both arguments 1061 are ‘nil’, or both are non-‘nil’. Otherwise, it returns the value 1062 of that argument which is non-‘nil’. 1063 1064 Note that in contrast to ‘or’, both arguments are always evaluated. 1065 1066 *Note (elisp)Combining Conditions::. 1067 1068 -- Variable: regexp-unmatchable 1069 This variable contains a regexp that is guaranteed not to match any 1070 string at all. It is particularly useful as default value for 1071 variables that may be set to a pattern that actually matches 1072 something. 1073 1074 *Note (elisp)Regexp Functions:: 1075 1076 -- Function: decoded-time-second time 1077 Return the SECONDS field of a ‘decoded-time’ record TIME. It can 1078 also be used as a *note Generalized Variables: (elisp)generalised 1079 variable. 1080 1081 -- Function: decoded-time-minute time 1082 Return the MINUTE field of a ‘decoded-time’ record TIME. It can 1083 also be used as a *note Generalized Variables: (elisp)generalised 1084 variable. 1085 1086 -- Function: decoded-time-hour time 1087 Return the HOUR field of a ‘decoded-time’ record TIME. It can also 1088 be used as a *note Generalized Variables: (elisp)generalised 1089 variable. 1090 1091 -- Function: decoded-time-day time 1092 Return the DAY field of a ‘decoded-time’ record TIME. It can also 1093 be used as a *note Generalized Variables: (elisp)generalised 1094 variable. 1095 1096 -- Function: decoded-time-month time 1097 Return the MONTH field of a ‘decoded-time’ record TIME. It can 1098 also be used as a *note Generalized Variables: (elisp)generalised 1099 variable. 1100 1101 -- Function: decoded-time-year time 1102 Return the YEAR field of a ‘decoded-time’ record TIME. It can also 1103 be used as a *note Generalized Variables: (elisp)generalised 1104 variable. 1105 1106 -- Function: decoded-time-weekday time 1107 Return the WEEKDAY field of a ‘decoded-time’ record TIME. It can 1108 also be used as a *note Generalized Variables: (elisp)generalised 1109 variable. 1110 1111 -- Function: decoded-time-dst time 1112 Return the DST (daylight saving time indicator) field of a 1113 ‘decoded-time’ record TIME. It can also be used as a *note 1114 Generalized Variables: (elisp)generalised variable. 1115 1116 -- Function: decoded-time-zone time 1117 Return the ZONE field of a ‘decoded-time’ record TIME. It can also 1118 be used as a *note Generalized Variables: (elisp)generalised 1119 variable. 1120 1121 -- Function: package-get-version 1122 Return the version number of the package in which this is used. 1123 1124 -- Function: time-equal-p t1 t2 1125 This returns ‘t’ if the two time values T1 and T2 are equal. 1126 1127 *Note (elisp)Time Calculations::. 1128 1129 -- Function: date-days-in-month year month 1130 Return the number of days in MONTH in YEAR. For instance, February 1131 2020 has 29 days. 1132 1133 *Note (elisp)Time Calculations::. This function requires the 1134 ‘time-date’ feature to be loaded. 1135 1136 -- Function: date-ordinal-to-time year ordinal 1137 Convert a YEAR/ORDINAL to the equivalent decoded-time structure. 1138 ORDINAL is the number of days since the start of the year, with 1139 January 1st being 1. 1140 1141 *Note (elisp)Time Calculations::. This function requires the 1142 ‘time-date’ feature to be loaded. 1143 1144 -- User Option: exec-path 1145 The value of this variable is a list of directories to search for 1146 programs to run in subprocesses. Each element is either the name 1147 of a directory (i.e., a string), or ‘nil’, which stands for the 1148 default directory (which is the value of ‘default-directory’). 1149 *Note executable-find: (elisp)Locating Files, for the details of 1150 this search. 1151 1152 The value of ‘exec-path’ is used by ‘call-process’ and 1153 ‘start-process’ when the PROGRAM argument is not an absolute file 1154 name. 1155 1156 Generally, you should not modify ‘exec-path’ directly. Instead, 1157 ensure that your ‘PATH’ environment variable is set appropriately 1158 before starting Emacs. Trying to modify ‘exec-path’ independently 1159 of ‘PATH’ can lead to confusing results. 1160 1161 *Note (elisp)Subprocess Creation::. 1162 1163 -- Function: provided-mode-derived-p mode &rest modes 1164 This function returns non-‘nil’ if MODE is derived from any of the 1165 major modes given by the symbols MODES. 1166 1167 -- Function: file-size-human-readable-iec size 1168 Human-readable string for SIZE bytes, using IEC prefixes. 1169 1170 -- Function: make-empty-file filename &optional parents 1171 This function creates an empty file named FILENAME. As 1172 ‘make-directory’, this function creates parent directories if 1173 PARENTS is non-‘nil’. If FILENAME already exists, this function 1174 signals an error. 1175 1176 -- Function: text-property-search-forward prop &optional value 1177 predicate not-current 1178 Search for the next region that has text property PROP set to VALUE 1179 according to PREDICATE. 1180 1181 This function is modeled after ‘search-forward’ and friends in that 1182 it moves point, but it returns a structure that describes the match 1183 instead of returning it in ‘match-beginning’ and friends. 1184 1185 If the text property can’t be found, the function returns ‘nil’. 1186 If it’s found, point is placed at the end of the region that has 1187 this text property match, and a ‘prop-match’ structure is returned. 1188 1189 PREDICATE can either be ‘t’ (which is a synonym for ‘equal’), ‘nil’ 1190 (which means “not equal”), or a predicate that will be called with 1191 two parameters: The first is VALUE, and the second is the value of 1192 the text property we’re inspecting. 1193 1194 If NOT-CURRENT, if point is in a region where we have a match, then 1195 skip past that and find the next instance instead. 1196 1197 The ‘prop-match’ structure has the following accessors: 1198 ‘prop-match-beginning’ (the start of the match), ‘prop-match-end’ 1199 (the end of the match), and ‘prop-match-value’ (the value of 1200 PROPERTY at the start of the match). 1201 1202 In the examples below, imagine that you’re in a buffer that looks 1203 like this: 1204 1205 This is a bold and here's bolditalic and this is the end. 1206 1207 That is, the “bold” words are the ‘bold’ face, and the “italic” 1208 word is in the ‘italic’ face. 1209 1210 With point at the start: 1211 1212 (while (setq match (text-property-search-forward 'face 'bold t)) 1213 (push (buffer-substring (prop-match-beginning match) 1214 (prop-match-end match)) 1215 words)) 1216 1217 This will pick out all the words that use the ‘bold’ face. 1218 1219 (while (setq match (text-property-search-forward 'face nil t)) 1220 (push (buffer-substring (prop-match-beginning match) 1221 (prop-match-end match)) 1222 words)) 1223 1224 This will pick out all the bits that have no face properties, which 1225 will result in the list ‘("This is a " "and here's " "and this is 1226 the end")’ (only reversed, since we used ‘push’). 1227 1228 (while (setq match (text-property-search-forward 'face nil nil)) 1229 (push (buffer-substring (prop-match-beginning match) 1230 (prop-match-end match)) 1231 words)) 1232 1233 This will pick out all the regions where ‘face’ is set to 1234 something, but this is split up into where the properties change, 1235 so the result here will be ‘("bold" "bold" "italic")’. 1236 1237 For a more realistic example where you might use this, consider 1238 that you have a buffer where certain sections represent URLs, and 1239 these are tagged with ‘shr-url’. 1240 1241 (while (setq match (text-property-search-forward 'shr-url nil nil)) 1242 (push (prop-match-value match) urls)) 1243 1244 This will give you a list of all those URLs. 1245 1246 *Note (Property Search)elisp::. 1247 1248 -- Function: text-property-search-backward prop &optional value 1249 predicate not-current 1250 This is just like ‘text-property-search-forward’, but searches 1251 backward instead. Point is placed at the beginning of the matched 1252 region instead of the end, though. 1253 1254 *Note (Property Search)elisp::. 1255 1256 2.3.2 Extended Definitions 1257 -------------------------- 1258 1259 These functions must be called explicitly via ‘compat-call’, since their 1260 calling convention or behavior was extended in Emacs 27.1: 1261 1262 -- Function: compat-call recenter &optional count redisplay 1263 This function scrolls the text in the selected window so that point 1264 is displayed at a specified vertical position within the window. 1265 It does not move point with respect to the text. 1266 1267 *Note (elisp)Textual Scrolling::. 1268 1269 This compatibility version adds support for the optional argument 1270 REDISPLAY. 1271 1272 -- Function: compat-call lookup-key keymap key &optional 1273 accept-defaults 1274 This function returns the definition of KEY in KEYMAP. If the 1275 string or vector KEY is not a valid key sequence according to the 1276 prefix keys specified in KEYMAP, it must be too long and have extra 1277 events at the end that do not fit into a single key sequence. Then 1278 the value is a number, the number of events at the front of KEY 1279 that compose a complete key. 1280 1281 *Note (elisp)Low-Level Key Binding::. 1282 1283 This compatibility version allows for KEYMAP to be a list of 1284 keymaps, instead of just a singular keymap. 1285 1286 -- Macro: compat-call setq-local &rest pairs 1287 PAIRS is a list of variable and value pairs. This macro creates a 1288 buffer-local binding in the current buffer for each of the 1289 variables, and gives them a buffer-local value. It is equivalent 1290 to calling ‘make-local-variable’ followed by ‘setq’ for each of the 1291 variables. The variables should be unquoted symbols. 1292 1293 (setq-local var1 "value1" 1294 var2 "value2") 1295 1296 *Note (elisp)Creating Buffer-Local::. 1297 1298 This compatibility version allows for more than one variable to be 1299 set at once, as can be done with ‘setq’. 1300 1301 -- Function: compat-call regexp-opt strings &optional paren 1302 This function returns an efficient regular expression that will 1303 match any of the strings in the list STRINGS. This is useful when 1304 you need to make matching or searching as fast as possible—for 1305 example, for Font Lock mode. 1306 1307 *Note (elisp)Regexp Functions::. 1308 1309 The compatibility version of this functions handles the case where 1310 STRINGS in an empty list. In that case, a regular expression is 1311 generated that never matches anything (see ‘regexp-unmatchable’). 1312 1313 -- Function: compat-call file-size-human-readable file-size &optional 1314 flavor space unit 1315 Return a string with a human readable representation of FILE-SIZE. 1316 1317 The optional second argument FLAVOR controls the units and the 1318 display format. If FLAVOR is... 1319 1320 • ‘si’, each kilobyte is 1000 bytes and the produced suffixes 1321 are ‘k’, ‘M’, ‘G’, ‘T’, etc. 1322 • ‘iec’, each kilobyte is 1024 bytes and the produced suffixes 1323 are ‘KiB’, ‘MiB’, ‘GiB’, ‘TiB’, etc. 1324 • ‘nil’ or omitted, each kilobyte is 1024 bytes and the produced 1325 suffixes are ‘k’, ‘M’, ‘G’, ‘T’, etc. 1326 1327 The compatibility version handles the optional third (SPACE) and 1328 forth (UNIT) arguments. The argument SPACE can be a string that is 1329 placed between the number and the unit. The argument UNIT 1330 determines the unit to use. By default it will be an empty string, 1331 unless FLAVOR is ‘iec’, in which case it will be ‘B’. 1332 1333 -- Function: compat-call assoc-delete-all key alist &optional test 1334 This function is like ‘assq-delete-all’ except that it accepts an 1335 optional argument TEST, a predicate function to compare the keys in 1336 ALIST. If omitted or ‘nil’, TEST defaults to ‘equal’. As 1337 ‘assq-delete-all’, this function often modifies the original list 1338 structure of ALIST. 1339 1340 *Note (elisp)Association Lists::. 1341 1342 This compatibility version handles the optional third (TESTFN) 1343 argument. 1344 1345 -- Function: compat-call executable-find program &optional remote 1346 This function searches for the executable file of the named PROGRAM 1347 and returns the absolute file name of the executable, including its 1348 file-name extensions, if any. It returns ‘nil’ if the file is not 1349 found. The function searches in all the directories in 1350 ‘exec-path’, and tries all the file-name extensions in 1351 ‘exec-suffixes’ (*note (elisp)Subprocess Creation::). 1352 1353 If REMOTE is non-‘nil’, and ‘default-directory’ is a remote 1354 directory, PROGRAM is searched on the respective remote host. 1355 1356 *Note (elisp)Locating Files::. 1357 1358 This compatibility version adds support to handle the optional 1359 second (REMOTE) argument. 1360 1361 2.3.3 Missing Definitions 1362 ------------------------- 1363 1364 Compat does not provide support for the following Lisp features 1365 implemented in 27.1: 1366 1367 • The functions ‘base64url-encode-*’. 1368 • The function ‘decoded-time-add’. 1369 • The function ‘decoded-time-set-defaults’. 1370 • The function ‘time-convert’. 1371 • The macro ‘benchmark-progn’. 1372 • Support for ‘condition-case’ to handle t. 1373 • The function ‘file-system-info’. 1374 • The function ‘group-name’. 1375 • The function ‘face-extend-p’ and ‘set-face-extend’. 1376 • Additional ‘format-spec’ modifiers. 1377 • Support for additional body forms for 1378 ‘define-globalized-minor-mode’. 1379 • The macro ‘with-connection-local-variables’ and related 1380 functionality. 1381 • The ‘iso8601’ library. 1382 • The ‘exif’ library. 1383 • The ‘image-converter’ library. 1384 1385 1386 File: doc23GpG6.info, Node: Emacs 28.1, Next: Emacs 29.1, Prev: Emacs 27.1, Up: Support 1387 1388 2.4 Emacs 28.1 1389 ============== 1390 1391 2.4.1 Added Definitions 1392 ----------------------- 1393 1394 The following functions and macros are implemented in Emacs 28.1. These 1395 functions are made available by Compat on Emacs versions older than 1396 28.1. 1397 1398 The ‘defcustom’ type ‘natnum’ introduced in Emacs 28.1 is made 1399 available by Compat. 1400 1401 -- Function: process-lines-ignore-status program &rest args 1402 This function is just like ‘process-lines’, but does not signal an 1403 error if PROGRAM exits with a non-zero exit status. 1404 1405 -- Function: process-lines-handling-status program status-handler &rest 1406 args 1407 Execute PROGRAM with ARGS, returning its output as a list of lines. 1408 If STATUS-HANDLER is non-nil, it must be a function with one 1409 argument, which will be called with the exit status of the program 1410 before the output is collected. If STATUS-HANDLER is nil, an error 1411 is signaled if the program returns with a non-zero exit status. 1412 1413 -- Function: text-quoting-style 1414 You should not read the value of the variable ‘text-quoting-style’ 1415 directly. Instead, use this function with the same name to 1416 dynamically compute the correct quoting style on the current 1417 terminal in the ‘nil’ case described above. 1418 1419 -- Function: string-search needle haystack &optional start-pos 1420 Return the position of the first instance of NEEDLE in HAYSTACK, 1421 both of which are strings. If START-POS is non-‘nil’, start 1422 searching from that position in NEEDLE. Return ‘nil’ if no match 1423 was found. This function only considers the characters in the 1424 strings when doing the comparison; text properties are ignored. 1425 Matching is always case-sensitive. 1426 1427 -- Function: length= sequence length 1428 Return non-‘nil’ if the length of SEQUENCE is equal to LENGTH. 1429 1430 -- Function: length< sequence length 1431 Return non-‘nil’ if SEQUENCE is shorter than LENGTH. This may be 1432 more efficient than computing the length of SEQUENCE if SEQUENCE is 1433 a long list. 1434 1435 -- Function: length> sequence length 1436 Return non-‘nil’ if SEQUENCE is longer than LENGTH. 1437 1438 -- Function: file-name-concat directory &rest components 1439 Concatenate COMPONENTS to DIRECTORY, inserting a slash before the 1440 components if DIRECTORY or the preceding component didn’t end with 1441 a slash. 1442 1443 (file-name-concat "/tmp" "foo") ⇒ "/tmp/foo" 1444 1445 A DIRECTORY or components that are ‘nil’ or the empty string are 1446 ignored—they are filtered out first and do not affect the results 1447 in any way. 1448 1449 This is almost the same as using ‘concat’, but DIRNAME (and the 1450 non-final components) may or may not end with slash characters, and 1451 this function will not double those characters. 1452 1453 -- Function: garbage-collect-maybe factor 1454 Suggest to run garbage collection, if _enough_ data has been 1455 allocated. This is determined by the positive numerical argument 1456 FACTOR, that would proportionally increase the likelihood of 1457 garbage collection taking place. 1458 1459 This compatibility function does nothing and ignores any 1460 suggestion. 1461 1462 -- Function: string-replace from-string to-string in-string 1463 This function replaces all occurrences of FROM-STRING with 1464 TO-STRING in IN-STRING and returns the result. It may return one 1465 of its arguments unchanged, a constant string or a new string. 1466 Case is significant, and text properties are ignored. 1467 1468 -- Function: always &rest arguments 1469 This function ignores any ARGUMENTS and returns ‘t’. 1470 1471 *Note (elisp)Calling Functions::. 1472 1473 -- Function: make-separator-line &optional length 1474 Make a string appropriate for usage as a visual separator line. If 1475 LENGTH is nil, use the window width. 1476 1477 -- Function: insert-into-buffer to-buffer &optional start end 1478 This is like ‘insert-buffer-substring’, but works in the opposite 1479 direction: The text is copied from the current buffer into 1480 TO-BUFFER. The block of text is copied to the current point in 1481 TO-BUFFER, and point (in that buffer) is advanced to after the end 1482 of the copied text. Is ‘start’/‘end’ is ‘nil’, the entire text in 1483 the current buffer is copied over. 1484 1485 *Note (elisp)Insertion::. 1486 1487 -- Function: replace-string-in-region regexp replacement &optional 1488 start end 1489 This function replaces all the occurrences of REGEXP with 1490 REPLACEMENT in the region of buffer text between START and END; 1491 START defaults to position of point, and END defaults to the last 1492 accessible position of the buffer. The search for REGEXP is 1493 case-sensitive, and REPLACEMENT is inserted without changing its 1494 letter-case. The REPLACEMENT string can use the same special 1495 elements starting with ‘\’ as ‘replace-match’ does. The function 1496 returns the number of replaced occurrences, or ‘nil’ if REGEXP is 1497 not found. The function preserves the position of point. 1498 1499 (replace-regexp-in-region "foo[ \t]+bar" "foobar") 1500 *Note (elisp)Search and Replace::. 1501 1502 -- Function: replace-regexp-in-string string replacement &optional 1503 start end 1504 This function works similarly to ‘replace-regexp-in-region’, but 1505 searches for, and replaces, literal STRINGs instead of regular 1506 expressions. 1507 1508 *Note (elisp)Search and Replace::. 1509 1510 -- Function: buffer-local-boundp variable buffer 1511 This returns non-‘nil’ if there’s either a buffer-local binding of 1512 VARIABLE (a symbol) in buffer BUFFER, or VARIABLE has a global 1513 binding. 1514 1515 *Note (elisp)Creating Buffer-Local::. 1516 1517 -- Macro: with-existing-directory body... 1518 This macro ensures that ‘default-directory’ is bound to an existing 1519 directory before executing BODY. If ‘default-directory’ already 1520 exists, that’s preferred, and otherwise some other directory is 1521 used. This macro can be useful, for instance, when calling an 1522 external command that requires that it’s running in a directory 1523 that exists. The chosen directory is not guaranteed to be 1524 writable. 1525 1526 *Note (elisp)Testing Accessibility::. 1527 1528 -- Macro: dlet (bindings...) forms... 1529 This special form is like ‘let’, but it binds all variables 1530 dynamically. This is rarely useful—you usually want to bind normal 1531 variables lexically, and special variables (i.e., variables that 1532 are defined with ‘defvar’) dynamically, and this is what ‘let’ 1533 does. 1534 1535 ‘dlet’ can be useful when interfacing with old code that assumes 1536 that certain variables are dynamically bound (*note (elisp)Dynamic 1537 Binding::), but it’s impractical to ‘defvar’ these variables. 1538 ‘dlet’ will temporarily make the bound variables special, execute 1539 the forms, and then make the variables non-special again. 1540 1541 *Note (elisp)Local Variables::. 1542 1543 -- Function: ensure-list object 1544 This function returns OBJECT as a list. If OBJECT is already a 1545 list, the function returns it; otherwise, the function returns a 1546 one-element list containing OBJECT. 1547 1548 This is usually useful if you have a variable that may or may not 1549 be a list, and you can then say, for instance: 1550 1551 (dolist (elem (ensure-list foo)) 1552 (princ elem)) 1553 1554 *Note (elisp)Building Lists::. 1555 1556 -- Function: string-clean-whitespace string 1557 Clean up the whitespace in STRING by collapsing stretches of 1558 whitespace to a single space character, as well as removing all 1559 whitespace from the start and the end of STRING. 1560 1561 *Note (elisp)Creating Strings::. 1562 1563 -- Function: string-fill string length 1564 Attempt to Word-wrap STRING so that no lines are longer than 1565 LENGTH. Filling is done on whitespace boundaries only. If there 1566 are individual words that are longer than LENGTH, these will not be 1567 shortened. 1568 1569 *Note (elisp)Creating Strings::. 1570 1571 -- Function: string-lines string &optional omit-nulls 1572 Split STRING into a list of strings on newline boundaries. If the 1573 optional argument OMIT-NULLS is non-‘nil’, remove empty lines from 1574 the results. Note that this function returns trailing newlines on 1575 Emacs 28, use ‘compat-call string-lines’ instead if you want 1576 consistent behavior. 1577 1578 -- Function: string-pad string length &optional padding start 1579 Pad STRING to be of the given LENGTH using PADDING as the padding 1580 character. PADDING defaults to the space character. If STRING is 1581 longer than LENGTH, no padding is done. If START is ‘nil’ or 1582 omitted, the padding is appended to the characters of STRING, and 1583 if it’s non-‘nil’, the padding is prepended to STRING’s characters. 1584 1585 *Note (elisp)Creating Strings::. 1586 1587 -- Function: string-chop-newline string 1588 Remove the final newline, if any, from STRING. 1589 1590 *Note (elisp)Creating Strings::. 1591 1592 -- Macro: named-let name bindings &rest body 1593 This special form is a looping construct inspired from the Scheme 1594 language. It is similar to ‘let’: It binds the variables in 1595 BINDINGS, and then evaluates BODY. However, ‘named-let’ also binds 1596 NAME to a local function whose formal arguments are the variables 1597 in BINDINGS and whose body is BODY. This allows BODY to call 1598 itself recursively by calling NAME, where the arguments passed to 1599 NAME are used as the new values of the bound variables in the 1600 recursive invocation. 1601 1602 Recursive calls to NAME that occur in _tail positions_ in BODY are 1603 guaranteed to be optimized as _tail calls_, which means that they 1604 will not consume any additional stack space no matter how deeply 1605 the recursion runs. Such recursive calls will effectively jump to 1606 the top of the loop with new values for the variables. 1607 1608 *Note (elisp)Local Variables::. 1609 1610 -- Function: file-name-with-extension filename extension 1611 This function returns FILENAME with its extension set to EXTENSION. 1612 A single leading dot in the EXTENSION will be stripped if there is 1613 one. For example: 1614 1615 (file-name-with-extension "file" "el") 1616 ⇒ "file.el" 1617 (file-name-with-extension "file" ".el") 1618 ⇒ "file.el" 1619 (file-name-with-extension "file.c" "el") 1620 ⇒ "file.el" 1621 1622 Note that this function will error if FILENAME or EXTENSION are 1623 empty, or if the FILENAME is shaped like a directory (i.e., if 1624 ‘directory-name-p’ returns non-‘nil’). 1625 1626 *Note File Name Components: (elisp)File Name Components. 1627 1628 -- Function: directory-empty-p directory 1629 This utility function returns ‘t’ if given DIRECTORY is an 1630 accessible directory and it does not contain any files, i.e., is an 1631 empty directory. It will ignore ‘.’ and ‘..’ on systems that 1632 return them as files in a directory. 1633 1634 Symbolic links to directories count as directories. See 1635 FILE-SYMLINK-P to distinguish symlinks. 1636 1637 *Note (elisp)Contents of Directories::. 1638 1639 -- Function: format-prompt prompt default &rest format-args 1640 Format PROMPT with default value DEFAULT according to the 1641 ‘minibuffer-default-prompt-format’ variable. 1642 1643 ‘minibuffer-default-prompt-format’ is a format string (defaulting 1644 to ‘" (default %s)"’ that says how the “default” bit in prompts 1645 like ‘"Local filename (default somefile): "’ are to be formatted. 1646 1647 To allow the users to customize how this is displayed, code that 1648 prompts the user for a value (and has a default) should look 1649 something along the lines of this code snippet: 1650 1651 (read-file-name 1652 (format-prompt "Local filename" file) 1653 nil file) 1654 1655 If FORMAT-ARGS is ‘nil’, PROMPT is used as a literal string. If 1656 FORMAT-ARGS is non-‘nil’, PROMPT is used as a format control 1657 string, and PROMPT and FORMAT-ARGS are passed to ‘format’ (*note 1658 (elisp)Formatting Strings::). 1659 1660 ‘minibuffer-default-prompt-format’ can be ‘""’, in which case no 1661 default values are displayed. 1662 1663 If DEFAULT is ‘nil’, there is no default value, and therefore no 1664 “default value” string is included in the result value. If DEFAULT 1665 is a non-‘nil’ list, the first element of the list is used in the 1666 prompt. 1667 1668 *Note (elisp)Text from Minibuffer::. 1669 1670 -- Function: thing-at-mouse event thing &optional no-properties 1671 Mouse-EVENT equivalent of ‘thing-at-point’. THING can be ‘symbol’, 1672 ‘list’, ‘sexp’, ‘filename’, ‘url’, ... among other things. 1673 1674 When NO-PROPERTIES has a non-‘nil’ value, any text properties that 1675 might have been present in the buffer are stripped away. 1676 1677 -- Function: bounds-of-thing-at-mouse event thing 1678 Determine start and end locations for THING at mouse click given by 1679 EVENT. Like ‘bounds-of-thing-at-point’, but tries to use the 1680 position in EVENT where the mouse button is clicked to find the 1681 thing nearby. 1682 1683 -- Function: mark-thing-at-mouse click thing 1684 Activate the region around THING found near the mouse CLICK. 1685 1686 -- Function: macroexp-file-name 1687 Return the name of the file in which the code is currently being 1688 evaluated, or ‘nil’ if it cannot be determined. 1689 1690 -- Function: macroexp-warn-and-return msg form &optional category 1691 compile-only arg 1692 Return code equivalent to ‘form’ labeled with warning ‘msg’. 1693 1694 -- Macro: with-environment-variables variables body... 1695 This macro sets the environment variables according to VARIABLES 1696 temporarily when executing BODY. The previous values are restored 1697 when the form finishes. The argument VARIABLES should be a list of 1698 pairs of strings of the form ‘(VAR VALUE)’, where VAR is the name 1699 of the environment variable and VALUE is that variable’s value. 1700 1701 (with-environment-variables (("LANG" "C") 1702 ("LANGUAGE" "en_US:en")) 1703 (call-process "ls" nil t)) 1704 1705 *Note System Environment: (elisp)System Environment. 1706 1707 -- Function: color-dark-p rgb 1708 Whether RGB is more readable against white than black. RGB is a 1709 3-element list (R G B), each component in the range [0,1]. This 1710 predicate can be used both for determining a suitable (black or 1711 white) contrast color with RGB as background and as foreground. 1712 1713 -- Function: color-values-from-color-spec spec 1714 Convert the textual color specification SPEC to a color triple 1715 ‘(RED GREEN blue)’. Each of RED, GREEN and ‘blue’ is a integer 1716 value between 0 and 65535. 1717 1718 The specification SPEC can be one of the following 1719 • ‘#RGB’, where R, G and B are hex numbers of equal length, 1-4 1720 digits each. 1721 • ‘rgb:R/G/B’, where R, G, and B are hex numbers, 1-4 digits 1722 each. 1723 • ‘rgbi:R/G/B’, where R, G and B are floating-point numbers in 1724 [0,1]. 1725 1726 -- Function: file-modes-number-to-symbolic modes 1727 This function converts a numeric file mode specification in MODES 1728 into the equivalent symbolic form. 1729 1730 *Note Changing Files: (elisp)Changing Files. 1731 1732 -- Function: file-backup-file-names filename 1733 This function returns a list of all the backup file names for 1734 FILENAME, or ‘nil’ if there are none. The files are sorted by 1735 modification time, descending, so that the most recent files are 1736 first. 1737 1738 *Note (elisp)Backup Names::. 1739 1740 -- Function: make-lock-file-name filename 1741 Return a string containing a lock file name for FILENAME, obeying 1742 ‘lock-file-name-transforms’. 1743 1744 -- Function: decoded-time-period time 1745 Interpret TIME as a period and return its length in seconds. For 1746 computational purposes, years are 365 days long and months are 30 1747 days long. 1748 1749 -- Function: subr-primitive-p object 1750 Return ‘t’ if OBJECT is a primitive, built-in function. On systems 1751 with native compilation ‘subrp’ does not distinguish between 1752 built-in functions and functions that have been compiled. If 1753 native compilation is not available, this function behaves 1754 identically to ‘subrp’. 1755 1756 -- Function: native-comp-available-p 1757 This function returns non-‘nil’ if the running Emacs process has 1758 the native-compilation support compiled into it. On systems that 1759 load ‘libgccjit’ dynamically, it also makes sure that library is 1760 available and can be loaded. Lisp programs that need to know up 1761 front whether native-compilation is available should use this 1762 predicate. 1763 1764 -- Macro: with-window-non-dedicated window &rest body 1765 Evaluate BODY with WINDOW temporarily made non-dedicated. If 1766 WINDOW is nil, use the selected window. Return the value of the 1767 last form in BODY. 1768 1769 2.4.2 Extended Definitions 1770 -------------------------- 1771 1772 These functions must be called explicitly via ‘compat-call’, since their 1773 calling convention or behavior was extended in Emacs 28.1: 1774 1775 -- Function: compat-call string-width string &optional from to 1776 This function returns the width in columns of the string STRING, if 1777 it were displayed in the current buffer and the selected window. 1778 Optional arguments FROM and TO specify the substring of STRING to 1779 consider, and are interpreted as in ‘substring’ (*note 1780 (elisp)Creating Strings::). 1781 1782 The return value is an approximation: it only considers the values 1783 returned by ‘char-width’ for the constituent characters, always 1784 takes a tab character as taking ‘tab-width’ columns, ignores 1785 display properties and fonts, etc. 1786 1787 *Note (elisp)Size of Displayed Text::. 1788 1789 This compatibility version handles the optional arguments FROM and 1790 TO. 1791 1792 -- Function: compat-call count-windows 1793 Return the number of live windows on the selected frame. 1794 1795 The optional argument MINIBUF specifies whether the minibuffer 1796 window is included in the count. 1797 1798 If ALL-FRAMES is non-‘nil’, count the windows in all frames instead 1799 just the selected frame. 1800 1801 This compatibility version handles the optional argument 1802 ALL-FRAMES. 1803 1804 2.4.3 Missing Definitions 1805 ------------------------- 1806 1807 Compat does not provide support for the following Lisp features 1808 implemented in 28.1: 1809 1810 • Support for ‘interactive’ or ‘declare’ to list applicable modes. 1811 • Support for ‘:interactive’ argument to ‘define-minor-mode’ and 1812 ‘define-derived-mode’. 1813 • Support for ‘:predicate’ argument to 1814 ‘define-globalized-minor-mode’. 1815 • Support for the ‘:success’ handler of ‘condition-case’. 1816 • The function ‘benchmark-call’. 1817 • Additional Edebug keywords. 1818 • The libjansson JSON APIs, e.g., ‘json-parse-string’. 1819 • The macro ‘pcase-setq’. 1820 • The function ‘custom-add-choice’. 1821 • The functions ‘dom-print’ and ‘dom-remove-attribute’. 1822 • The function ‘dns-query-asynchronous’. 1823 • The function ‘get-locale-names’. 1824 • The functions ‘mail-header-parse-addresses-lax’ and 1825 ‘mail-header-parse-address-lax’. 1826 • The function ‘num-processors’. 1827 • The function ‘object-intervals’. 1828 • The function ‘require-theme’. 1829 • The function ‘syntax-class-to-char’. 1830 • The function ‘path-separator’. 1831 • The function ‘null-device’. 1832 • The function ‘macroexp-compiling-p’. 1833 • The function ‘split-string-shell-command’. 1834 • The function ‘string-limit’. 1835 • The functions ‘innermost-minibuffer-p’ and 1836 ‘minibuffer-innermost-command-loop-p’. 1837 • The function ‘max-mini-window-lines’. 1838 • The function ‘lock-file’ and ‘unlock-file’. 1839 • The ‘multisession’ library. 1840 1841 1842 File: doc23GpG6.info, Node: Emacs 29.1, Next: Emacs 30.1, Prev: Emacs 28.1, Up: Support 1843 1844 2.5 Emacs 29.1 1845 ============== 1846 1847 2.5.1 Added Definitions 1848 ----------------------- 1849 1850 The following functions and macros are implemented in Emacs 29.1. These 1851 functions are made available by Compat on Emacs versions older than 1852 29.1. Note that due to upstream changes, it might happen that there 1853 will be the need for changes, so use these functions with care. 1854 1855 The ‘defcustom’ type ‘key’ introduced in Emacs 29.1 is made available 1856 by Compat. 1857 1858 -- Variable: lisp-directory 1859 This variable holds a string naming the directory which holds 1860 Emacs’s own ‘*.el’ and ‘*.elc’ files. This is usually the place 1861 where those files are located in the Emacs installation tree, 1862 unless Emacs is run from its build directory in which case it 1863 points to the ‘lisp’ subdirectory in the source directory from 1864 which Emacs was built. 1865 1866 -- Function: count-sentences start end 1867 Count sentences in current buffer from START to END. 1868 1869 -- Function: readablep object 1870 This predicate says whether OBJECT has “readable syntax”, i.e., it 1871 can be written out and then read back by the Emacs Lisp reader. If 1872 it can’t, this function returns ‘nil’; if it can, this function 1873 returns a printed representation (via ‘prin1’). 1874 1875 -- Function: substitute-quotes string 1876 This function works like ‘substitute-command-keys’, but only 1877 replaces quote characters. 1878 1879 -- Function: get-scratch-buffer-create 1880 Return the *scratch* buffer, creating a new one if needed. 1881 1882 -- Function: use-region-noncontiguous-p 1883 Return non-nil for a non-contiguous region if ‘use-region-p’. 1884 1885 -- Function: use-region-end 1886 Return the end of the region if ‘use-region-p’. 1887 1888 -- Function: use-region-beginning 1889 Return the start of the region if ‘use-region-p’. 1890 1891 -- Macro: buffer-local-set-state variable value... 1892 Minor modes often set buffer-local variables that affect some 1893 features in Emacs. When a minor mode is switched off, the mode is 1894 expected to restore the previous state of these variables. This 1895 convenience macro helps with doing that: It works much like 1896 ‘setq-local’, but returns an object that can be used to restore 1897 these values back to their previous values/states (using the 1898 companion function ‘buffer-local-restore-state’). 1899 1900 -- Function: delete-line 1901 Delete the current line. 1902 1903 -- Function: list-of-strings-p object 1904 Return ‘t’ if OBJECT is ‘nil’ or a list of strings. 1905 1906 -- Function: plistp object 1907 Non-nil if and only if OBJECT is a valid plist. 1908 1909 -- Macro: with-memoization PLACE CODE... 1910 This macro provides a simple way to do memoization. CODE is 1911 evaluated and then stashed in PLACE. If PLACE’s value is 1912 non-‘nil’, return that value instead of evaluating CODE. 1913 1914 -- Special Form: with-restriction start end [:label label] body 1915 This special form saves the current bounds of the accessible 1916 portion of the buffer, sets the accessible portion to start at 1917 START and end at END, evaluates the BODY forms, and restores the 1918 saved bounds. In that case it is equivalent to 1919 1920 (save-restriction 1921 (narrow-to-region start end) 1922 body) 1923 1924 When the optional argument LABEL, a symbol, is present, the 1925 narrowing is “labeled”. A labeled narrowing differs from a 1926 non-labeled one in several ways: 1927 1928 • During the evaluation of the BODY form, ‘narrow-to-region’ and 1929 ‘widen’ can be used only within the START and END limits. 1930 1931 • To lift the restriction introduced by ‘with-restriction’ and 1932 gain access to other portions of the buffer, use 1933 ‘without-restriction’ with the same LABEL argument. (Another 1934 way to gain access to other portions of the buffer is to use 1935 an indirect buffer (*note (elisp)Indirect Buffers::).) 1936 1937 • Labeled narrowings can be nested. 1938 1939 • Labeled narrowings can only be used in Lisp programs: they are 1940 never visible on display, and never interfere with narrowings 1941 set by the user. 1942 1943 If you use ‘with-restriction’ with the optional LABEL argument, we 1944 recommend documenting the LABEL in the doc strings of the functions 1945 which use it, so that other Lisp programs your code calls could 1946 lift the labeled narrowing if and when it needs. 1947 1948 -- Special Form: without-restriction [:label label] body 1949 This special form saves the current bounds of the accessible 1950 portion of the buffer, widens the buffer, evaluates the BODY forms, 1951 and restores the saved bounds. In that case it is equivalent to 1952 1953 (save-restriction 1954 (widen) 1955 body) 1956 1957 When the optional argument LABEL is present, the narrowing set by 1958 ‘with-restriction’ with the same LABEL argument is lifted. 1959 1960 -- Function: pos-bol &optional count 1961 Like ‘line-beginning-position’, but ignores fields (and is more 1962 efficient). 1963 1964 -- Function: pos-eol &optional count 1965 Like ‘line-end-position’, but ignores fields (and is more 1966 efficient). 1967 1968 -- Function: char-uppercase-p char 1969 Return non-‘nil’ if CHAR is an uppercase character according to 1970 Unicode. 1971 1972 -- Macro: with-delayed-message (timeout message) body... 1973 Sometimes it’s unclear whether an operation will take a long time 1974 to execute or not, or it can be inconvenient to implement a 1975 progress reporter. This macro can be used in those situations. 1976 1977 (with-delayed-message (2 (format "Gathering data for %s" entry)) 1978 (setq data (gather-data entry))) 1979 1980 In this example, if the body takes more than two seconds to 1981 execute, the message will be displayed. If it takes a shorter time 1982 than that, the message won’t be displayed. In either case, the 1983 body is evaluated as normally, and the return value of the final 1984 element in the body is the return value of the macro. 1985 1986 The MESSAGE element is evaluated before BODY, and is always 1987 evaluated, whether the message is displayed or not. 1988 1989 -- Function: funcall-with-delayed-message timeout message function 1990 Like ‘funcall’, but display MESSAGE if FUNCTION takes longer than 1991 TIMEOUT. TIMEOUT is a number of seconds, and can be an integer or 1992 a floating point number. 1993 1994 If FUNCTION takes less time to execute than TIMEOUT seconds, 1995 MESSAGE is not displayed. 1996 1997 -- Function: buttonize string callback &optional data help-echo 1998 Sometimes it’s more convenient to make a string into a button 1999 without inserting it into a buffer immediately, for instance when 2000 creating data structures that may then, later, be inserted into a 2001 buffer. This function makes STRING into such a string, and 2002 CALLBACK will be called when the user clicks on the button. The 2003 optional DATA parameter will be used as the parameter when CALLBACK 2004 is called. If ‘nil’, the button is used as the parameter instead. 2005 2006 -- Function: buttonize-region start end callback &optional data 2007 help-echo 2008 Make the region between START and END into a button. When clicked, 2009 CALLBACK will be called with the DATA as the function argument. If 2010 DATA isn’t present (or is nil), the button itself will be used 2011 instead as the function argument. If HELP-ECHO, use that as the 2012 help-echo property. 2013 2014 -- Function: get-display-property position prop &optional object 2015 properties 2016 This convenience function can be used to get a specific display 2017 property, no matter whether the ‘display’ property is a vector, a 2018 list or a simple property. This is like ‘get-text-property’ (*note 2019 Examining Properties: (elisp)Examining Properties.), but works on 2020 the ‘display’ property only. 2021 2022 POSITION is the position in the buffer or string to examine, and 2023 PROP is the ‘display’ property to return. The optional OBJECT 2024 argument should be either a string or a buffer, and defaults to the 2025 current buffer. If the optional PROPERTIES argument is non-‘nil’, 2026 it should be a ‘display’ property, and in that case, POSITION and 2027 OBJECT are ignored. (This can be useful if you’ve already gotten 2028 the ‘display’ property with ‘get-char-property’, for instance 2029 (*note Examining Properties: (elisp)Examining Properties.). 2030 2031 -- Function: add-display-text-property start end prop value &optional 2032 object 2033 Add display property PROP with VALUE to the text from START to END. 2034 If any text in the region has a non-nil ‘display’ property, those 2035 properties are retained. 2036 2037 If OBJECT is non-‘nil’, it should be a string or a buffer. If 2038 ‘nil’, this defaults to the current buffer. 2039 2040 -- Function: take n list 2041 This function returns the N first elements of LIST. Essentially, 2042 it returns the part of LIST that ‘nthcdr’ skips. 2043 2044 ‘take’ returns LIST if shorter than N elements; it returns ‘nil’ if 2045 N is zero or negative. 2046 2047 (take 3 '(a b c d)) 2048 ⇒ (a b c) 2049 (take 10 '(a b c d)) 2050 ⇒ (a b c d) 2051 (take 0 '(a b c d)) 2052 ⇒ nil 2053 2054 -- Function: ntake n list 2055 This is a version of ‘take’ that works by destructively modifying 2056 the list structure of the argument. That makes it faster, but the 2057 original value of LIST may be lost. 2058 2059 ‘ntake’ returns LIST unmodified if shorter than N elements; it 2060 returns ‘nil’ if N is zero or negative. Otherwise, it returns LIST 2061 truncated to its first N elements. 2062 2063 This means that it is usually a good idea to use the return value 2064 and not just rely on the truncation effect unless N is known to be 2065 positive. 2066 2067 -- Function: compiled-function-p object 2068 This function returns ‘t’ if OBJECT is a function object that is 2069 not in the form of ELisp source code but something like machine 2070 code or byte code instead. More specifically it returns ‘t’ if the 2071 function is built-in, or byte-compiled, or natively-compiled, or a 2072 function loaded from a dynamic module. 2073 2074 -- Function: function-alias-p object &optional noerror 2075 Checks whether OBJECT is a function alias. If it is, it returns a 2076 list of symbols representing the function alias chain, else ‘nil’. 2077 For instance, if ‘a’ is an alias for ‘b’, and ‘b’ is an alias for 2078 ‘c’: 2079 2080 (function-alias-p 'a) 2081 ⇒ (b c) 2082 2083 If there’s a loop in the definitions, an error will be signalled. 2084 If NOERROR is non-‘nil’, the non-looping parts of the chain is 2085 returned instead. 2086 2087 -- Function: string-equal-ignore-case string1 string2 2088 ‘string-equal-ignore-case’ compares strings ignoring case 2089 differences, like ‘char-equal’ when ‘case-fold-search’ is ‘t’. 2090 2091 *Note (elisp)Text Comparison::. 2092 2093 -- Function: string-split string &optional separators omit-nulls trim 2094 ‘string-split’ is an alias for the function ‘split-string’. The 2095 name follows the convention of other string functions. 2096 2097 *Note (elisp)Creating Strings::. 2098 2099 -- Function: buffer-match-p condition buffer-or-name &optional arg 2100 This function checks if a buffer designated by ‘buffer-or-name’ 2101 satisfies a ‘condition’. Optional third argument ARG is passed to 2102 the predicate function in CONDITION. A condition can be one of the 2103 following: 2104 • A string, interpreted as a regular expression. The buffer 2105 satisfies the condition if the regular expression matches the 2106 buffer name. 2107 • A predicate function, which should return non-‘nil’ if the 2108 buffer matches. If the function expects one argument, it is 2109 called with BUFFER-OR-NAME as the argument; if it expects 2 2110 arguments, the first argument is BUFFER-OR-NAME and the second 2111 is ARG (or ‘nil’ if ARG is omitted). 2112 • A cons-cell ‘(OPER . EXPR)’ where OPER is one of 2113 ‘not’ 2114 Satisfied if EXPR doesn’t satisfy ‘buffer-match-p’ with 2115 the same buffer and ‘arg’. 2116 ‘or’ 2117 Satisfied if EXPR is a list and _any_ condition in EXPR 2118 satisfies ‘buffer-match-p’, with the same buffer and 2119 ‘arg’. 2120 ‘and’ 2121 Satisfied if EXPR is a list and _all_ conditions in EXPR 2122 satisfy ‘buffer-match-p’, with the same buffer and ‘arg’. 2123 ‘derived-mode’ 2124 Satisfied if the buffer’s major mode derives from EXPR. 2125 ‘major-mode’ 2126 Satisfied if the buffer’s major mode is equal to EXPR. 2127 Prefer using ‘derived-mode’ instead when both can work. 2128 • t Satisfied by any buffer. A convenient alternative to ‘""’ 2129 (empty string), ‘(and)’ (empty conjunction) or ‘always’. 2130 2131 *Note (elisp)Buffer List::. 2132 2133 -- Function: match-buffers condition &optional buffers arg 2134 This function returns a list of all buffers that satisfy a 2135 ‘condition’, as defined for ‘buffer-match-p’. By default all 2136 buffers are considered, but this can be restricted via the second 2137 optional ‘buffer-list’ argument. Optional third argument ARG will 2138 be used by CONDITION in the same way as ‘buffer-match-p’ does. 2139 2140 *Note (elisp)Buffer List::. 2141 2142 -- Function: string-glyph-split string 2143 When character compositions are in effect, sequence of characters 2144 can be composed for display to form _grapheme clusters_, for 2145 example to display accented characters, or ligatures, or Emoji, or 2146 when complex text shaping requires that for some scripts. When 2147 that happens, characters no longer map in a simple way to display 2148 columns, and display layout decisions with such strings, such as 2149 truncating too wide strings, can be a complex job. This function 2150 helps in performing such jobs: it splits up its argument STRING 2151 into a list of substrings, where each substring produces a single 2152 grapheme cluster that should be displayed as a unit. Lisp programs 2153 can then use this list to construct visually-valid substrings of 2154 STRING which will look correctly on display, or compute the width 2155 of any substring of STRING by adding the width of its constituents 2156 in the returned list, etc. 2157 2158 For instance, if you want to display a string without the first 2159 glyph, you can say: 2160 2161 (apply #'insert (cdr (string-glyph-split string)))) 2162 2163 *Note (elisp)Size of Displayed Text::. 2164 2165 -- Macro: with-buffer-unmodified-if-unchanged &rest body... 2166 Evaluate BODY like ‘progn’, but change buffer-modified status only 2167 if buffer text changes. If the buffer was unmodified before 2168 execution of BODY, and buffer text after execution of BODY is 2169 identical to what it was before, ensure that buffer is still marked 2170 unmodified afterwards. 2171 2172 Note that only changes in the raw byte sequence of the buffer text, 2173 as stored in the internal representation, are monitored for the 2174 purpose of detecting the lack of changes in buffer text. Any other 2175 changes that are normally perceived as "buffer modifications", such 2176 as changes in text properties, ‘buffer-file-coding-system’, buffer 2177 multibyteness, etc. – will not be noticed, and the buffer will 2178 still be marked unmodified, effectively ignoring those changes. 2179 2180 -- Function: file-attribute-file-identifier 2181 Return the fields ‘(inodenum device)’ as a list from attributes 2182 generated by ‘file-attributes’. 2183 2184 *Note (elisp)File Attributes::. 2185 2186 -- Function: file-name-split filename 2187 This function splits a file name into its components, and can be 2188 thought of as the inverse of ‘string-join’ with the appropriate 2189 directory separator. For example, 2190 2191 (file-name-split "/tmp/foo.txt") 2192 ⇒ ("" "tmp" "foo.txt") 2193 (string-join (file-name-split "/tmp/foo.txt") "/") 2194 ⇒ "/tmp/foo.txt" 2195 2196 -- Function: file-name-parent-directory filename 2197 This function returns the directory name of the parent directory of 2198 FILENAME. If FILENAME is at the root directory of the filesystem, 2199 it returns ‘nil’. A relative FILENAME is assumed to be relative to 2200 ‘default-directory’, and the return value will also be relative in 2201 that case. If the return value is non-‘nil’, it ends in a slash. 2202 2203 *Note (elisp)Directory Names::. 2204 2205 -- Function: file-has-changed-p file &optional tag 2206 This function returns non-‘nil’ if the time stamp of FILENAME has 2207 changed since the last call. When called for the first time for 2208 some FILENAME, it records the last modification time and size of 2209 the file, and returns non-‘nil’ when FILENAME exists. Thereafter, 2210 when called for the same FILENAME, it compares the current time 2211 stamp and size with the recorded ones, and returns non-‘nil’ only 2212 if either the time stamp or the size (or both) are different. This 2213 is useful when a Lisp program wants to re-read a file whenever it 2214 changes. With an optional argument TAG, which must be a symbol, 2215 the size and modification time comparisons are limited to calls 2216 with the same tag. 2217 2218 *Note (elisp)File Attributes::. 2219 2220 -- Function: directory-abbrev-make-regexp directory 2221 Create a regexp to match DIRECTORY for ‘directory-abbrev-alist’. 2222 2223 -- Function: directory-abbrev-apply filename 2224 Apply the abbreviations in ‘directory-abbrev-alist’ to FILENAME. 2225 Note that when calling this, you should set ‘case-fold-search’ as 2226 appropriate for the filesystem used for FILENAME. 2227 2228 -- Function: key-valid-p keys 2229 Say whether KEYS is a valid key. A key is a string consisting of 2230 one or more key strokes. The key strokes are separated by single 2231 space characters. 2232 2233 Each key stroke is either a single character, or the name of an 2234 event, surrounded by angle brackets. In addition, any key stroke 2235 may be preceded by one or more modifier keys. Finally, a limited 2236 number of characters have a special shorthand syntax. 2237 2238 Here’s some example key sequences. 2239 2240 ‘f’ 2241 The key ‘f’. 2242 ‘S o m’ 2243 A three key sequence of the keys ‘S’, ‘o’ and ‘m’. 2244 ‘C-c o’ 2245 A two key sequence of the keys ‘c’ with the control modifier 2246 and then the key ‘o’. 2247 ‘H-<left>’ 2248 The key named "left" with the hyper modifier. 2249 ‘M-RET’ 2250 The "return" key with a meta modifier. 2251 ‘C-M-<space>’ 2252 The "space" key with both the control and meta modifiers. 2253 2254 These are the characters that have shorthand syntax: ‘NUL’, ‘RET’, 2255 ‘TAB’, ‘LFD’, ‘ESC’, ‘SPC’, ‘DEL’. 2256 2257 Modifiers have to be specified in this order 2258 Alt (A)-Control (C)-Hyper (H)-Meta (M)-Shift (s)-Super (s) 2259 2260 -- Function: key-parse keys 2261 Convert KEYS to the internal Emacs key representation. See 2262 ‘key-valid-p’ for a description of valid key sequences. Examples 2263 include ‘f’, ‘C-c C-c’, ‘H-<left>’, ‘M-RET’ or ‘C-M-<return>’. 2264 2265 -- Function: keymap-set keymap key definition 2266 This function sets the binding for KEY in KEYMAP. (If KEY is more 2267 than one event long, the change is actually made in another keymap 2268 reached from KEYMAP.) The argument BINDING can be any Lisp object, 2269 but only certain types are meaningful. (For a list of meaningful 2270 types, see *note (elisp)Key Lookup::.) The value returned by 2271 ‘keymap-set’ is BINDING. 2272 2273 If KEY is ‘<t>’, this sets the default binding in KEYMAP. When an 2274 event has no binding of its own, the Emacs command loop uses the 2275 keymap’s default binding, if there is one. 2276 2277 Every prefix of KEY must be a prefix key (i.e., bound to a keymap) 2278 or undefined; otherwise an error is signaled. If some prefix of 2279 KEY is undefined, then ‘keymap-set’ defines it as a prefix key so 2280 that the rest of KEY can be defined as specified. 2281 2282 If there was previously no binding for KEY in KEYMAP, the new 2283 binding is added at the beginning of KEYMAP. The order of bindings 2284 in a keymap makes no difference for keyboard input, but it does 2285 matter for menu keymaps (*note (elisp)Menu Keymaps::). 2286 2287 *Note (elisp)Changing Key Bindings::. 2288 2289 -- Function: keymap-global-set key command 2290 This function sets the binding of KEY in the current global map to 2291 BINDING. 2292 2293 (keymap-global-set KEY BINDING) 2294 ≡ 2295 (keymap-set (current-global-map) KEY BINDING) 2296 2297 *Note (elisp)Key Binding Commands::. 2298 2299 -- Function: keymap-local-set key command 2300 This function sets the binding of KEY in the current local keymap 2301 to BINDING. 2302 2303 (keymap-local-set KEY BINDING) 2304 ≡ 2305 (keymap-set (current-local-map) KEY BINDING) 2306 2307 *Note (elisp)Key Binding Commands::. 2308 2309 -- Function: keymap-global-unset key &optional remove 2310 This function removes the binding of KEY from the current global 2311 map. 2312 2313 One use of this function is in preparation for defining a longer 2314 key that uses KEY as a prefix—which would not be allowed if KEY has 2315 a non-prefix binding. For example: 2316 2317 (keymap-global-unset "C-l") 2318 ⇒ nil 2319 (keymap-global-set "C-l C-l" 'redraw-display) 2320 ⇒ nil 2321 2322 *Note (elisp)Key Binding Commands::. 2323 2324 -- Function: keymap-local-unset key &optional remove 2325 This function removes the binding of KEY from the current local 2326 map. 2327 2328 *Note (elisp)Key Binding Commands::. 2329 2330 -- Function: keymap-substitute keymap olddef newdef &optional oldmap 2331 prefix 2332 Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as 2333 OLDDEF. In other words, OLDDEF is replaced with NEWDEF wherever it 2334 appears. Alternatively, if optional fourth argument OLDMAP is 2335 specified, we redefine in KEYMAP as NEWDEF those keys that are 2336 defined as OLDDEF in OLDMAP. 2337 2338 -- Function: keymap-lookup keymap key &optional accept-default no-remap 2339 position 2340 This function returns the definition of KEY in KEYMAP. All the 2341 other functions described in this chapter that look up keys use 2342 ‘keymap-lookup’. Here are examples: 2343 2344 (keymap-lookup (current-global-map) "C-x C-f") 2345 ⇒ find-file 2346 (keymap-lookup (current-global-map) "C-x C-f 1 2 3 4 5") 2347 ⇒ 2 2348 2349 *Note (elisp)Functions for Key Lookup::. 2350 2351 -- Function: keymap-local-lookup keys &optional accept-default 2352 Like ‘keymap-lookup’, but restricting the search for commands bound 2353 to KEYS to the current local keymap. 2354 2355 -- Function: keymap-global-lookup keys &optional accept-default 2356 Like ‘keymap-lookup’, but restricting the search for commands bound 2357 to KEYS to the current global keymap. 2358 2359 -- Function: define-keymap &rest definitions 2360 You can create a keymap with the functions described above, and 2361 then use ‘keymap-set’ (*note (elisp)Changing Key Bindings::) to 2362 specify key bindings in that map. When writing modes, however, you 2363 frequently have to bind a large number of keys at once, and using 2364 ‘keymap-set’ on them all can be tedious and error-prone. Instead 2365 you can use ‘define-keymap’, which creates a keymap and binds a 2366 number of keys. Here’s a very basic example: 2367 2368 (define-keymap 2369 "n" #'forward-line 2370 "f" #'previous-line 2371 "C-c C-c" #'quit-window) 2372 2373 This function creates a new sparse keymap, defines the keystrokes 2374 in PAIRS, and returns the new keymap. 2375 2376 PAIRS is a list of alternating key bindings and key definitions, as 2377 accepted by ‘keymap-set’. In addition, the key can be the special 2378 symbol ‘:menu’, in which case the definition should be a menu 2379 definition as accepted by ‘easy-menu-define’ (*note (elisp)Easy 2380 Menu::). Here’s a brief example of this usage: 2381 2382 (define-keymap :full t 2383 "g" #'eww-reload 2384 :menu '("Eww" 2385 ["Exit" quit-window t] 2386 ["Reload" eww-reload t])) 2387 2388 A number of keywords can be used before the key/definition pairs to 2389 change features of the new keymap. If any of the feature keywords 2390 is missing from the ‘define-keymap’ call, the default value for 2391 that feature is ‘nil’. Here’s a list of the available feature 2392 keywords: 2393 2394 ‘:full’ 2395 If non-‘nil’, create a char-table keymap (as from 2396 ‘make-keymap’) instead of a sparse keymap (as from 2397 ‘make-sparse-keymap’ (*note (elisp)Creating Keymaps::). A 2398 sparse keymap is the default. 2399 2400 ‘:parent’ 2401 If non-‘nil’, the value should be a keymap to use as the 2402 parent (*note (elisp)Inheritance and Keymaps::). 2403 2404 ‘:keymap’ 2405 If non-‘nil’, the value should be a keymap. Instead of 2406 creating a new keymap, the specified keymap is modified 2407 instead. 2408 2409 ‘:suppress’ 2410 If non-‘nil’, the keymap will be suppressed with 2411 ‘suppress-keymap’ (*note (elisp)Changing Key Bindings::). By 2412 default, digits and the minus sign are exempt from 2413 suppressing, but if the value is ‘nodigits’, this suppresses 2414 digits and minus-sign like it does with other characters. 2415 2416 ‘:name’ 2417 If non-‘nil’, the value should be a string to use as the menu 2418 for the keymap if you use it as a menu with ‘x-popup-menu’ 2419 (*note (elisp)Pop-Up Menus::). 2420 2421 ‘:prefix’ 2422 If non-‘nil’, the value should be a symbol to be used as a 2423 prefix command (*note (elisp)Prefix Keys::). If this is the 2424 case, this symbol is returned by ‘define-keymap’ instead of 2425 the map itself. 2426 2427 -- Function: defvar-keymap (variable-name &rest defs) 2428 By far, the most common thing to do with a keymap is to bind it to 2429 a variable. This is what virtually all modes do—a mode called 2430 ‘foo’ almost always has a variable called ‘foo-mode-map’. 2431 2432 This macro defines NAME as a variable, passes OPTIONS and PAIRS to 2433 ‘define-keymap’, and uses the result as the default value for the 2434 variable. 2435 2436 OPTIONS is like the keywords in ‘define-keymap’, but there’s an 2437 additional ‘:doc’ keyword that provides the doc string for the 2438 defined variable. 2439 2440 Here’s an example: 2441 2442 (defvar-keymap eww-textarea-map 2443 :parent text-mode-map 2444 "RET" #'forward-line 2445 "TAB" #'shr-next-link) 2446 2447 -- Macro: while-let spec then-forms... 2448 Like ‘when-let’, but repeat until a binding in SPEC is ‘nil’. The 2449 return value is always ‘nil’. 2450 2451 This is comparable to ‘and-let*’. 2452 2453 -- Function: window-configuration-equal-p config1 config2 2454 This function says whether two window configurations have the same 2455 window layout, but ignores the values of point and the saved 2456 scrolling positions—it can return ‘t’ even if those aspects differ. 2457 2458 -- Macro: ert-with-temp-file name &rest body 2459 Bind NAME to the name of a new temporary file and evaluate BODY. 2460 Delete the temporary file after BODY exits normally or non-locally. 2461 NAME will be bound to the file name of the temporary file. See the 2462 docstring for supported keyword arguments. 2463 2464 -- Macro: ert-with-temp-directory name &rest body 2465 Bind NAME to the name of a new temporary directory and evaluate 2466 BODY. Delete the temporary directory after BODY exits normally or 2467 non-locally. 2468 2469 NAME is bound to the directory name, not the directory file name. 2470 (In other words, it will end with the directory delimiter; on 2471 Unix-like systems, it will end with "/".) 2472 2473 The same keyword arguments are supported as in ‘ert-with-temp-file’ 2474 (which see), except for ‘:text’. 2475 2476 -- Function: cl-constantly value 2477 Return a function that takes any number of arguments, but returns 2478 VALUE. 2479 2480 -- Macro: cl-with-gensyms names... body 2481 This macro expands to code that executes BODY with each of the 2482 variables in NAMES bound to a fresh uninterned symbol, or “gensym”, 2483 in Common Lisp parlance. For macros requiring more than one 2484 gensym, use of ‘cl-with-gensyms’ shortens the code and renders 2485 one’s intentions clearer. Compare: 2486 2487 (defmacro my-macro (foo) 2488 (let ((bar (gensym "bar")) 2489 (baz (gensym "baz")) 2490 (quux (gensym "quux"))) 2491 `(let ((,bar (+ ...))) 2492 ...))) 2493 2494 (defmacro my-macro (foo) 2495 (cl-with-gensyms (bar baz quux) 2496 `(let ((,bar (+ ...))) 2497 ...))) 2498 2499 -- Macro: cl-once-only ((variable form)...) body 2500 This macro is primarily to help the macro programmer ensure that 2501 forms supplied by the user of the macro are evaluated just once by 2502 its expansion even though the result of evaluating the form is to 2503 occur more than once. Less often, this macro is used to ensure 2504 that forms supplied by the macro programmer are evaluated just 2505 once. 2506 2507 Each VARIABLE may be used to refer to the result of evaluating FORM 2508 in BODY. ‘cl-once-only’ binds each VARIABLE to a fresh uninterned 2509 symbol during the evaluation of BODY. Then, ‘cl-once-only’ wraps 2510 the final expansion in code to evaluate each FORM and bind the 2511 result to the corresponding uninterned symbol. Thus, when the 2512 macro writer substitutes the value for VARIABLE into the expansion 2513 they are effectively referring to the result of evaluating FORM, 2514 rather than FORM itself. Another way to put this is that each 2515 VARIABLE is bound to an expression for the (singular) result of 2516 evaluating FORM. 2517 2518 The most common case is where VARIABLE is one of the arguments to 2519 the macro being written, so ‘(variable variable)’ may be 2520 abbreviated to just ‘variable’. 2521 2522 For example, consider this macro: 2523 2524 (defmacro my-list (x y &rest forms) 2525 (let ((x-result (gensym)) 2526 (y-result (gensym))) 2527 `(let ((,x-result ,x) 2528 (,y-result ,y)) 2529 (list ,x-result ,y-result ,x-result ,y-result 2530 (progn ,@forms)))) 2531 2532 In a call like ‘(my-list (pop foo) ...)’ the intermediate binding 2533 to ‘x-result’ ensures that the ‘pop’ is not done twice. But as a 2534 result the code is rather complex: the reader must keep track of 2535 how ‘x-result’ really just means the first parameter of the call to 2536 the macro, and the required use of multiple gensyms to avoid 2537 variable capture by ‘(progn ,@forms)’ obscures things further. 2538 ‘cl-once-only’ takes care of these details: 2539 2540 (defmacro my-list (x y &rest forms) 2541 (cl-once-only (x y) 2542 `(list ,x ,y ,x ,y 2543 (progn ,@forms)))) 2544 2545 2.5.2 Extended Definitions 2546 -------------------------- 2547 2548 These functions must be called explicitly via ‘compat-call’, since their 2549 calling convention or behavior was extended in Emacs 29.1: 2550 2551 -- Function: compat-call set-transient-map keymap &optional keep-pred 2552 on-exit message timeout 2553 This function adds KEYMAP as a “transient” keymap, which takes 2554 precedence over other keymaps for one (or more) subsequent keys. 2555 2556 Normally, KEYMAP is used just once, to look up the very next key. 2557 If the optional argument KEEP-PRED is ‘t’, the map stays active as 2558 long as the user types keys defined in KEYMAP; when the user types 2559 a key that is not in KEYMAP, the transient keymap is deactivated 2560 and normal key lookup continues for that key. 2561 2562 The KEEP-PRED argument can also be a function. In that case, the 2563 function is called with no arguments, prior to running each 2564 command, while KEYMAP is active; it should return non-‘nil’ if 2565 KEYMAP should stay active. 2566 2567 The optional argument ON-EXIT, if non-‘nil’, specifies a function 2568 that is called, with no arguments, after KEYMAP is deactivated. 2569 2570 The optional argument MESSAGE specifies the message to display 2571 after activating the transient map. If MESSAGE is a string, it is 2572 the format string for the message, and any ‘%k’ specifier in that 2573 string is replaced with the list of keys from the transient map. 2574 Any other non-‘nil’ value of MESSAGE stands for the default message 2575 format ‘Repeat with %k’. 2576 2577 If the optional argument TIMEOUT is non-‘nil’, it should be a 2578 number that specifies how many seconds of idle time to wait before 2579 deactivating KEYMAP. The value of the variable 2580 ‘set-transient-map-timeout’, if non-‘nil’, overrides the value of 2581 this argument. 2582 2583 This function works by adding and removing KEYMAP from the variable 2584 ‘overriding-terminal-local-map’, which takes precedence over all 2585 other active keymaps (*note (Searching Keymaps)elisp::). 2586 2587 -- Function: compat-call string-lines string &optional omit-nulls 2588 keep-newlines 2589 Split STRING into a list of strings on newline boundaries. If the 2590 optional argument OMIT-NULLS is non-‘nil’, remove empty lines from 2591 the results. If the optional argument KEEP-NEWLINES is non-‘nil’, 2592 don’t remove the trailing newlines from the result strings. 2593 2594 *Note (elisp)Creating Strings::. 2595 2596 -- Function: compat-call define-key 2597 This function is like ‘keymap-set’ (*note (elisp)Changing Key 2598 Bindings::, but understands only the legacy key syntaxes. 2599 2600 In addition, this function also has a REMOVE argument. If it is 2601 non-‘nil’, the definition will be removed. This is almost the same 2602 as setting the definition to ‘nil’, but makes a difference if the 2603 KEYMAP has a parent, and KEY is shadowing the same binding in the 2604 parent. With REMOVE, subsequent lookups will return the binding in 2605 the parent, whereas with a ‘nil’ definition the lookups will return 2606 ‘nil’. 2607 2608 *Note (elisp)Low-Level Key Binding::. 2609 2610 This compatibility version handles the optional argument REMOVE. 2611 2612 -- Function: compat-call plist-get plist prop &optional predicate 2613 This returns the value of the PROPERTY property stored in the 2614 property list PLIST. Comparisons are done with PREDICATE, and 2615 defaults to ‘eq’. It accepts a malformed PLIST argument. If 2616 PROPERTY is not found in the PLIST, it returns ‘nil’. 2617 2618 *Note (elisp)Plist Access::. 2619 2620 This compatibility version handles the optional argument PREDICATE. 2621 This is a generalized variable (*note (elisp)Generalized 2622 Variables::) that can be used to change a value with ‘setf’. 2623 2624 -- Function: compat-call plist-put plist prop val &optional predicate 2625 This stores VALUE as the value of the PROPERTY property in the 2626 property list PLIST. Comparisons are done with PREDICATE, and 2627 defaults to ‘eq’. It may modify PLIST destructively, or it may 2628 construct a new list structure without altering the old. The 2629 function returns the modified property list, so you can store that 2630 back in the place where you got PLIST. 2631 2632 *Note (elisp)Plist Access::. 2633 2634 This compatibility version handles the optional argument PREDICATE. 2635 2636 -- Function: compat-call plist-member plist prop &optional predicate 2637 This returns non-‘nil’ if PLIST contains the given PROPERTY. 2638 Comparisons are done with PREDICATE, and defaults to ‘eq’. Unlike 2639 ‘plist-get’, this allows you to distinguish between a missing 2640 property and a property with the value ‘nil’. The value is 2641 actually the tail of PLIST whose ‘car’ is PROPERTY. 2642 2643 *Note (elisp)Plist Access::. 2644 2645 This compatibility version handles the optional argument PREDICATE. 2646 2647 2.5.3 Missing Definitions 2648 ------------------------- 2649 2650 Compat does not provide support for the following Lisp features 2651 implemented in 29.1: 2652 2653 • The function ‘imagep’. 2654 • The function ‘image-at-point-p’. 2655 • The function ‘function-documentation’. 2656 • The macro ‘with-undo-amalgamate’. 2657 • The function ‘string-glyph-split’. 2658 • The function ‘string-limit’. 2659 • The function ‘string-pixel-width’ and ‘buffer-text-pixel-size’. 2660 • The function ‘minibuffer-lazy-highlight-setup’. 2661 • The function ‘pp-emacs-lisp-code’. 2662 • The function ‘bidi-string-strip-control-characters’. 2663 • The native function ‘current-cpu-time’. 2664 • The functions ‘xdg-state-home’, ‘xdg-current-desktop’ and 2665 ‘xdg-session-type’. 2666 • The macro ‘setopt’. 2667 • The ‘oclosure’ library. 2668 • The ‘textsec’ library. 2669 • The ‘range’ library. 2670 • The ‘string-edit’ library. 2671 • The ‘vtable’ library. 2672 • The ‘pixel-fill’ library. 2673 • Support for symbols with position information. 2674 2675 2676 File: doc23GpG6.info, Node: Emacs 30.1, Prev: Emacs 29.1, Up: Support 2677 2678 2.6 Emacs 30.1 2679 ============== 2680 2681 2.6.1 Added Definitions 2682 ----------------------- 2683 2684 The following functions and macros are implemented in Emacs 30.1. These 2685 functions are made available by Compat on Emacs versions older than 2686 30.1. Note that due to upstream changes, it might happen that there 2687 will be the need for changes, so use these functions with care. 2688 2689 -- Function: char-to-name char 2690 This function returns the Unicode name of CHAR. It returns ‘nil’ 2691 if CHAR is not a character or has no Unicode name. 2692 2693 -- Function: obarray-clear obarray 2694 This function removes all symbols from OBARRAY. 2695 2696 -- Function: closurep object 2697 This function returns ‘t’ if OBJECT is a closure, which is a 2698 particular kind of function object. Currently closures are used 2699 for all byte-code functions and all interpreted functions. 2700 2701 -- Function: interpreted-function-p object 2702 This function returns ‘t’ if OBJECT is an interpreted function. 2703 2704 -- Function: primitive-function-p object 2705 Return ‘t’ if OBJECT is a built-in primitive function. This 2706 excludes special forms, since they are not functions. 2707 2708 -- Function: value< a b 2709 This function returns non-‘nil’ if A comes before B in the standard 2710 sorting order; this means that it returns ‘nil’ when B comes before 2711 A, or if they are equal or unordered. 2712 2713 The arguments A and B must have the same type. Specifically: 2714 2715 • Numbers are compared using ‘<’. 2716 • Strings are compared using ‘string<’ and symbols are compared 2717 by comparing their names as strings. 2718 • Conses, lists, vectors and records are compared 2719 lexicographically. This means that the two sequences are 2720 compared element-wise from left to right until they differ, 2721 and the result is then that of ‘value<’ on the first pair of 2722 differing elements. If one sequence runs out of elements 2723 before the other, the shorter sequence comes before the 2724 longer. 2725 • Markers are compared first by buffer, then by position. 2726 • Buffers and processes are compared by comparing their names as 2727 strings. Dead buffers (whose name is ‘nil’) will compare 2728 before any live buffer. 2729 • Other types are considered unordered and the return value will 2730 be ‘nil’. 2731 2732 Examples: 2733 (value< -4 3.5) ⇒ t 2734 (value< "dog" "cat") ⇒ nil 2735 (value< 'yip 'yip) ⇒ nil 2736 (value< '(3 2) '(3 2 0)) ⇒ t 2737 (value< [3 2 "a"] [3 2 "b"]) ⇒ t 2738 2739 Note that ‘nil’ is treated as either a symbol or an empty list, 2740 depending on what it is compared against: 2741 2742 (value< nil '(0)) ⇒ t 2743 (value< 'nib nil) ⇒ t 2744 2745 There is no limit to the length of sequences (lists, vectors and so 2746 on) that can be compared, but ‘value<’ may fail with an error if 2747 used to compare circular or deeply nested data structures. 2748 2749 -- Function: drop n list 2750 This function is an alias for ‘nthcdr’. It returns the Nth CDR of 2751 LIST. In other words, it skips past the first N links of LIST and 2752 returns what follows. 2753 2754 -- Function: get-truename-buffer filename 2755 Return the buffer with ‘file-truename’ equal to FILENAME (a 2756 string). If there is no such live buffer, return nil. See also 2757 ‘find-buffer-visiting’. 2758 2759 -- Function: find-buffer variable value 2760 Return the buffer with buffer-local VARIABLE equal to VALUE. If 2761 there is no such live buffer, return nil. 2762 2763 -- Function: require-with-check feature &optional filename noerror 2764 This function works like ‘require’, except if FEATURE is already 2765 loaded (i.e. is already a member of the list in ‘features’, see 2766 below). If FEATURE is already loaded, this function checks if 2767 FEATURE was provided by a file different from FILENAME, and if so, 2768 it by default signals an error. If the value of the optional 2769 argument NOERROR is ‘reload’, the function doesn’t signal an error, 2770 but instead forcibly reloads FILENAME; if NOERROR is some other 2771 non-‘nil’ value, the function emits a warning about FEATURE being 2772 already provided by another file. 2773 2774 -- Function: merge-ordered-lists lists &optional error-function 2775 Merge LISTS in a consistent order. LISTS is a list of lists of 2776 elements. Merge them into a single list containing the same 2777 elements (removing duplicates), obeying their relative positions in 2778 each list. The order of the (sub)lists determines the final order 2779 in those cases where the order within the sublists does not impose 2780 a unique choice. Equality of elements is tested with ‘eql’. 2781 2782 If a consistent order does not exist, call ERROR-FUNCTION with a 2783 remaining list of lists that we do not know how to merge. It 2784 should return the candidate to use to continue the merge, which has 2785 to be the head of one of the lists. By default we choose the head 2786 of the first list. 2787 2788 -- Variable: completion-lazy-hilit 2789 If non-nil, request lazy highlighting of completion candidates. 2790 2791 Lisp programs (a.k.a. "front ends") that present completion 2792 candidates may opt to bind this variable to a non-nil value when 2793 calling functions (such as ‘completion-all-completions’) which 2794 produce completion candidates. This tells the underlying 2795 completion styles that they do not need to fontify (i.e., 2796 propertize with the ‘face’ property) completion candidates in a way 2797 that highlights the matching parts. Then it is the front end which 2798 presents the candidates that becomes responsible for this 2799 fontification. The front end does that by calling the function 2800 ‘completion-lazy-hilit’ on each completion candidate that is to be 2801 displayed to the user. 2802 2803 Note that only some completion styles take advantage of this 2804 variable for optimization purposes. Other styles will ignore the 2805 hint and fontify eagerly as usual. It is still safe for a front 2806 end to call ‘completion-lazy-hilit’ in these situations. 2807 2808 To author a completion style that takes advantage of this variable, 2809 see ‘completion-lazy-hilit-fn’ and 2810 ‘completion-pcm--hilit-commonality’. 2811 2812 -- Variable: completion-lazy-hilit-fn 2813 Fontification function set by lazy-highlighting completions styles. 2814 When a given style wants to enable support for 2815 ‘completion-lazy-hilit’ (which see), that style should set this 2816 variable to a function of one argument. It will be called with 2817 each completion candidate, a string, to be displayed to the user, 2818 and should destructively propertize these strings with the ‘face’ 2819 property. 2820 2821 -- Function: completion-lazy-hilit str 2822 Return a copy of completion candidate STR that is face-propertized. 2823 See documentation of the variable ‘completion-lazy-hilit’ for more 2824 details. 2825 2826 -- Macro: static-if condition then-form else-forms... 2827 Test CONDITION at macro-expansion time. If its value is non-‘nil’, 2828 expand the macro to THEN-FORM, otherwise expand it to ELSE-FORMS 2829 enclosed in a ‘progn’. ELSE-FORMS may be empty. 2830 2831 Here is an example of its use from CC Mode, which prevents a 2832 ‘defadvice’ form being compiled in newer versions of Emacs: 2833 (static-if (boundp 'comment-line-break-function) 2834 (progn) 2835 (defvar c-inside-line-break-advice nil) 2836 (defadvice indent-new-comment-line (around c-line-break-advice 2837 activate preactivate) 2838 "Call `c-indent-new-comment-line' if in CC Mode." 2839 (if (or c-inside-line-break-advice 2840 (not c-buffer-is-cc-mode)) 2841 ad-do-it 2842 (let ((c-inside-line-break-advice t)) 2843 (c-indent-new-comment-line (ad-get-arg 0)))))) 2844 2845 2.6.2 Extended Definitions 2846 -------------------------- 2847 2848 These functions must be called explicitly via ‘compat-call’, since their 2849 calling convention or behavior was extended in Emacs 30.1: 2850 2851 -- Function: compat-call sort sequence &rest keyword-args 2852 This function sorts SEQUENCE, which must be a list or vector, and 2853 returns a sorted sequence of the same type. The sort is stable, 2854 which means that elements with equal sort keys maintain their 2855 relative order. It takes the following optional keyword arguments: 2856 2857 ‘:key KEYFUNC’ 2858 Use KEYFUNC, a function that takes a single element from 2859 SEQUENCE and returns its key value, to generate the keys used 2860 in comparison. If this argument is absent or if KEYFUNC is 2861 ‘nil’ then ‘identity’ is assumed; that is, the elements 2862 themselves are used as sorting keys. 2863 2864 ‘:lessp PREDICATE’ 2865 Use PREDICATE to order the keys. PREDICATE is a function that 2866 takes two sort keys as arguments and returns non-‘nil’ if the 2867 first should come before the second. If this argument is 2868 absent or PREDICATE is ‘nil’, then ‘value<’ is used, which is 2869 applicable to many different Lisp types and generally sorts in 2870 ascending order. 2871 2872 For consistency, any predicate must obey the following rules: 2873 • It must be “antisymmetric”: it cannot both order A before 2874 B and B before A. 2875 • It must be “transitive”: if it orders A before B and B 2876 before C, then it must also order A before C. 2877 2878 ‘:reverse FLAG’ 2879 If FLAG is non-‘nil’, the sorting order is reversed. With the 2880 default ‘:lessp’ predicate this means sorting in descending 2881 order. 2882 2883 ‘:in-place FLAG’ 2884 If FLAG is non-‘nil’, then SEQUENCE is sorted in-place 2885 (destructively) and returned. If ‘nil’, or if this argument 2886 is not given, a sorted copy of the input is returned and 2887 SEQUENCE itself remains unmodified. In-place sorting is 2888 slightly faster, but the original sequence is lost. 2889 2890 If the default behaviour is not suitable for your needs, it is 2891 usually easier and faster to supply a new ‘:key’ function than a 2892 different ‘:lessp’ predicate. For example, consider sorting these 2893 strings: 2894 2895 (setq numbers '("one" "two" "three" "four" "five" "six")) 2896 (sort numbers) 2897 ⇒ ("five" "four" "one" "six" "three" "two") 2898 2899 You can sort the strings by length instead by supplying a different 2900 key function: 2901 2902 (sort numbers :key #'length) 2903 ⇒ ("one" "two" "six" "four" "five" "three") 2904 2905 Note how strings of the same length keep their original order, 2906 thanks to the sorting stability. Now suppose you want to sort by 2907 length, but use the string contents to break ties. The easiest way 2908 is to specify a key function that transforms an element to a value 2909 that is sorted this way. Since ‘value<’ orders compound objects 2910 (conses, lists, vectors and records) lexicographically, you could 2911 do: 2912 2913 (sort numbers :key (lambda (x) (cons (length x) x))) 2914 ⇒ ("one" "six" "two" "five" "four" "three") 2915 2916 because ‘(3 . "six")’ is ordered before ‘(3 . "two")’ and so on. 2917 2918 For compatibility with previous versions of Emacs, the ‘sort’ 2919 function can also be called using the fixed two-argument form: 2920 2921 (sort SEQUENCE PREDICATE) 2922 2923 where PREDICATE is the ‘:lessp’ argument. When using this form, 2924 sorting is always done in-place. 2925 2926 -- Function: compat-call completion-metadata-get metadata prop 2927 Get property PROP from completion METADATA. If the metadata 2928 specifies a completion category, the variables 2929 ‘completion-category-overrides’ and ‘completion-category-defaults’ 2930 take precedence for category-specific overrides. If the completion 2931 metadata does not specify the property, the 2932 ‘completion-extra-properties’ plist is consulted. Note that the 2933 keys of the ‘completion-extra-properties’ plist are keyword 2934 symbols, not plain symbols. 2935 2936 -- Function: compat-call copy-tree tree &optional vectors-and-records 2937 This function returns a copy of the tree TREE. If TREE is a cons 2938 cell, this makes a new cons cell with the same CAR and CDR, then 2939 recursively copies the CAR and CDR in the same way. 2940 2941 Normally, when TREE is anything other than a cons cell, ‘copy-tree’ 2942 simply returns TREE. However, if VECTORS-AND-RECORDS is non-‘nil’, 2943 it copies vectors and records too (and operates recursively on 2944 their elements). The TREE argument must not contain cycles. 2945 2946 2.6.3 Missing Definitions 2947 ------------------------- 2948 2949 Compat does not provide support for the following Lisp features 2950 implemented in 30.1: 2951 2952 2953 File: doc23GpG6.info, Node: Development, Next: Function Index, Prev: Support, Up: Top 2954 2955 3 Development 2956 ************* 2957 2958 Compat is developed on GitHub. 2959 2960 Bug reports, patches and comments are best sent to the issue tracker 2961 (https://github.com/emacs-compat/compat/issues). These may include 2962 issues in the compatibility code, missing definitions or performance 2963 issues. We also provide a development mailing list 2964 (https://lists.sr.ht/~pkal/compat-devel) (~pkal/compat-devel@lists.sr.ht 2965 <~pkal/compat-devel@lists.sr.ht>). 2966 2967 Please note that as a GNU ELPA package, Compat requires contributors 2968 to have signed the FSF copyright assignment 2969 (https://www.gnu.org/software/emacs/manual/html_node/emacs/Copyright-Assignment.html), 2970 before any non-trivial contribution (roughly 15 lines of code) can be 2971 applied. 2972 2973 It is important that you provide tests when you contribute new 2974 functionality. Compat has 100% test coverage by the test suite. We use 2975 continuous integration to check if patches preserve existing 2976 functionality. 2977 2978 Development for the currently stable Emacs version happens in the 2979 main branch of the Compat Git repository. ELPA-devel nightly builds are 2980 created from this branch. New features, which are not yet ready to be 2981 merged directly into the main branch, are developed in feature branches. 2982 Furthermore the Git repository has a branch emacs-<version> where the 2983 development for the upcoming Emacs release takes place. This branch is 2984 separate from the main branch since the new functionality should not be 2985 made available (neither via ELPA nor ELPA-devel) before the new Emacs 2986 version has been reasonably stabilized, e.g., around the time when the 2987 Emacs version branch is created in the Emacs repository on Savannah. 2988 2989 2990 File: doc23GpG6.info, Node: Function Index, Next: Variable Index, Prev: Development, Up: Top 2991 2992 Appendix A Function Index 2993 ************************* 2994 2995 2996 * Menu: 2997 2998 * add-display-text-property: Emacs 29.1. (line 190) 2999 * alist-get: Emacs 25.1. (line 82) 3000 * always: Emacs 28.1. (line 83) 3001 * and-let*: Emacs 26.1. (line 158) 3002 * assoc-delete-all: Emacs 26.1. (line 13) 3003 * bignump: Emacs 27.1. (line 55) 3004 * bool-vector: Emacs 25.1. (line 177) 3005 * bounds-of-thing-at-mouse: Emacs 28.1. (line 292) 3006 * buffer-hash: Emacs 26.1. (line 80) 3007 * buffer-local-boundp: Emacs 28.1. (line 125) 3008 * buffer-local-restore-state: Emacs 29.1. (line 50) 3009 * buffer-local-set-state: Emacs 29.1. (line 50) 3010 * buffer-match-p: Emacs 29.1. (line 258) 3011 * buttonize: Emacs 29.1. (line 156) 3012 * buttonize-region: Emacs 29.1. (line 165) 3013 * char-to-name: Emacs 30.1. (line 14) 3014 * char-uppercase-p: Emacs 29.1. (line 127) 3015 * cl-constantly: Emacs 29.1. (line 635) 3016 * cl-once-only: Emacs 29.1. (line 658) 3017 * cl-with-gensyms: Emacs 29.1. (line 639) 3018 * closurep: Emacs 30.1. (line 21) 3019 * color-dark-p: Emacs 28.1. (line 322) 3020 * color-values-from-color-spec: Emacs 28.1. (line 328) 3021 * compat-call: Usage. (line 50) 3022 * compat-call alist-get: Emacs 26.1. (line 344) 3023 * compat-call assoc: Emacs 26.1. (line 316) 3024 * compat-call assoc-delete-all: Emacs 27.1. (line 417) 3025 * compat-call completion-metadata-get: Emacs 30.1. (line 251) 3026 * compat-call copy-tree: Emacs 30.1. (line 261) 3027 * compat-call count-windows: Emacs 28.1. (line 407) 3028 * compat-call define-key: Emacs 29.1. (line 755) 3029 * compat-call executable-find: Emacs 27.1. (line 429) 3030 * compat-call file-size-human-readable: Emacs 27.1. (line 397) 3031 * compat-call line-number-at-pos: Emacs 26.1. (line 330) 3032 * compat-call lookup-key: Emacs 27.1. (line 356) 3033 * compat-call make-temp-file: Emacs 26.1. (line 278) 3034 * compat-call plist-get: Emacs 29.1. (line 771) 3035 * compat-call plist-member: Emacs 29.1. (line 795) 3036 * compat-call plist-put: Emacs 29.1. (line 783) 3037 * compat-call recenter: Emacs 27.1. (line 346) 3038 * compat-call regexp-opt: Emacs 27.1. (line 385) 3039 * compat-call set-transient-map: Emacs 29.1. (line 710) 3040 * compat-call setq-local: Emacs 27.1. (line 370) 3041 * compat-call sort: Emacs 30.1. (line 176) 3042 * compat-call string-lines: Emacs 29.1. (line 746) 3043 * compat-call string-trim: Emacs 26.1. (line 375) 3044 * compat-call string-trim-left: Emacs 26.1. (line 359) 3045 * compat-call string-trim-right: Emacs 26.1. (line 367) 3046 * compat-call string-width: Emacs 28.1. (line 390) 3047 * compat-function: Usage. (line 58) 3048 * compiled-function-p: Emacs 29.1. (line 226) 3049 * completion-lazy-hilit: Emacs 30.1. (line 146) 3050 * count-sentences: Emacs 29.1. (line 25) 3051 * cXXXr: Emacs 26.1. (line 66) 3052 * cXXXXr: Emacs 26.1. (line 67) 3053 * date-days-in-month: Emacs 27.1. (line 213) 3054 * date-ordinal-to-time: Emacs 27.1. (line 220) 3055 * decoded-time-day: Emacs 27.1. (line 175) 3056 * decoded-time-dst: Emacs 27.1. (line 195) 3057 * decoded-time-hour: Emacs 27.1. (line 170) 3058 * decoded-time-minute: Emacs 27.1. (line 165) 3059 * decoded-time-month: Emacs 27.1. (line 180) 3060 * decoded-time-period: Emacs 28.1. (line 359) 3061 * decoded-time-second: Emacs 27.1. (line 160) 3062 * decoded-time-weekday: Emacs 27.1. (line 190) 3063 * decoded-time-year: Emacs 27.1. (line 185) 3064 * decoded-time-zone: Emacs 27.1. (line 200) 3065 * define-keymap: Emacs 29.1. (line 518) 3066 * defvar-keymap: Emacs 29.1. (line 586) 3067 * delete-line: Emacs 29.1. (line 59) 3068 * directory-abbrev-apply: Emacs 29.1. (line 382) 3069 * directory-abbrev-make-regexp: Emacs 29.1. (line 379) 3070 * directory-empty-p: Emacs 28.1. (line 243) 3071 * directory-name-p: Emacs 25.1. (line 56) 3072 * dlet: Emacs 28.1. (line 143) 3073 * dolist-with-progress-reporter: Emacs 27.1. (line 119) 3074 * drop: Emacs 30.1. (line 74) 3075 * ensure-list: Emacs 28.1. (line 158) 3076 * ert-with-temp-directory: Emacs 29.1. (line 623) 3077 * ert-with-temp-file: Emacs 29.1. (line 617) 3078 * file-attribute-access-time: Emacs 26.1. (line 223) 3079 * file-attribute-collect: Emacs 26.1. (line 260) 3080 * file-attribute-device-number: Emacs 26.1. (line 255) 3081 * file-attribute-file-identifier: Emacs 29.1. (line 339) 3082 * file-attribute-group-id: Emacs 26.1. (line 218) 3083 * file-attribute-inode-number: Emacs 26.1. (line 250) 3084 * file-attribute-link-number: Emacs 26.1. (line 208) 3085 * file-attribute-modes: Emacs 26.1. (line 245) 3086 * file-attribute-modification-time: Emacs 26.1. (line 228) 3087 * file-attribute-size: Emacs 26.1. (line 240) 3088 * file-attribute-status-change-time: Emacs 26.1. (line 234) 3089 * file-attribute-type: Emacs 26.1. (line 203) 3090 * file-attribute-user-id: Emacs 26.1. (line 213) 3091 * file-backup-file-names: Emacs 28.1. (line 347) 3092 * file-has-changed-p: Emacs 29.1. (line 364) 3093 * file-local-name: Emacs 26.1. (line 167) 3094 * file-modes-number-to-symbolic: Emacs 28.1. (line 341) 3095 * file-name-concat: Emacs 28.1. (line 53) 3096 * file-name-parent-directory: Emacs 29.1. (line 355) 3097 * file-name-quote: Emacs 26.1. (line 102) 3098 * file-name-quoted-p: Emacs 26.1. (line 95) 3099 * file-name-split: Emacs 29.1. (line 345) 3100 * file-name-unquote: Emacs 26.1. (line 90) 3101 * file-name-with-extension: Emacs 28.1. (line 225) 3102 * file-size-human-readable-iec: Emacs 27.1. (line 251) 3103 * find-buffer: Emacs 30.1. (line 84) 3104 * fixnump: Emacs 27.1. (line 60) 3105 * flatten-tree: Emacs 27.1. (line 132) 3106 * format-message: Emacs 25.1. (line 44) 3107 * format-prompt: Emacs 28.1. (line 254) 3108 * funcall-with-delayed-message: Emacs 29.1. (line 148) 3109 * function-alias-p: Emacs 29.1. (line 233) 3110 * garbage-collect-maybe: Emacs 28.1. (line 68) 3111 * gensym: Emacs 26.1. (line 70) 3112 * get-display-property: Emacs 29.1. (line 173) 3113 * get-scratch-buffer-create: Emacs 29.1. (line 38) 3114 * get-truename-buffer: Emacs 30.1. (line 79) 3115 * hash-table-empty: Emacs 25.1. (line 119) 3116 * if-let: Emacs 25.1. (line 96) 3117 * if-let*: Emacs 26.1. (line 149) 3118 * ignore-errors: Emacs 27.1. (line 106) 3119 * image-property: Emacs 26.1. (line 198) 3120 * insert-into-buffer: Emacs 28.1. (line 92) 3121 * interpreted-function-p: Emacs 30.1. (line 26) 3122 * key-parse: Emacs 29.1. (line 419) 3123 * key-valid-p: Emacs 29.1. (line 387) 3124 * keymap-global-lookup: Emacs 29.1. (line 514) 3125 * keymap-global-set: Emacs 29.1. (line 448) 3126 * keymap-global-unset: Emacs 29.1. (line 468) 3127 * keymap-local-lookup: Emacs 29.1. (line 510) 3128 * keymap-local-set: Emacs 29.1. (line 458) 3129 * keymap-local-unset: Emacs 29.1. (line 483) 3130 * keymap-lookup: Emacs 29.1. (line 497) 3131 * keymap-set: Emacs 29.1. (line 424) 3132 * keymap-substitute: Emacs 29.1. (line 489) 3133 * length<: Emacs 28.1. (line 45) 3134 * length=: Emacs 28.1. (line 42) 3135 * length>: Emacs 28.1. (line 50) 3136 * list-of-strings-p: Emacs 29.1. (line 62) 3137 * macroexp-file-name: Emacs 28.1. (line 301) 3138 * macroexp-parse: Emacs 25.1. (line 174) 3139 * macroexp-quote: Emacs 25.1. (line 171) 3140 * macroexp-warn-and-return: Emacs 28.1. (line 305) 3141 * macroexpand-1: Emacs 25.1. (line 164) 3142 * major-mode-restore: Emacs 27.1. (line 22) 3143 * major-mode-suspend: Emacs 27.1. (line 13) 3144 * make-empty-file: Emacs 27.1. (line 254) 3145 * make-lock-file-name: Emacs 28.1. (line 355) 3146 * make-nearby-temp-file: Emacs 26.1. (line 120) 3147 * make-separator-line: Emacs 28.1. (line 88) 3148 * mapcan: Emacs 26.1. (line 53) 3149 * mark-thing-at-mouse: Emacs 28.1. (line 298) 3150 * match-buffers: Emacs 29.1. (line 292) 3151 * merge-ordered-lists: Emacs 30.1. (line 99) 3152 * minibuffer-history-value: Emacs 27.1. (line 32) 3153 * named-let: Emacs 28.1. (line 207) 3154 * native-comp-available-p: Emacs 28.1. (line 371) 3155 * ntake: Emacs 29.1. (line 213) 3156 * obarray-clear: Emacs 30.1. (line 18) 3157 * package-get-version: Emacs 27.1. (line 205) 3158 * plistp: Emacs 29.1. (line 65) 3159 * pos-bol: Emacs 29.1. (line 119) 3160 * pos-eol: Emacs 29.1. (line 123) 3161 * primitive-function-p: Emacs 30.1. (line 29) 3162 * process-lines-handling-status: Emacs 28.1. (line 20) 3163 * process-lines-ignore-status: Emacs 28.1. (line 16) 3164 * proper-list-p: Emacs 27.1. (line 76) 3165 * provided-mode-derived-p: Emacs 27.1. (line 247) 3166 * read-answer: Emacs 26.1. (line 17) 3167 * read-char-from-minibuffer: Emacs 27.1. (line 44) 3168 * read-multiple-choice: Emacs 26.1. (line 185) 3169 * readablep: Emacs 29.1. (line 28) 3170 * region-bounds: Emacs 25.1. (line 28) 3171 * region-noncontiguous-p: Emacs 25.1. (line 34) 3172 * replace-regexp-in-string: Emacs 28.1. (line 117) 3173 * replace-string-in-region: Emacs 28.1. (line 102) 3174 * require-with-check: Emacs 30.1. (line 88) 3175 * ring-resize: Emacs 27.1. (line 28) 3176 * save-mark-and-excursion: Emacs 25.1. (line 39) 3177 * static-if: Emacs 30.1. (line 151) 3178 * string-chop-newline: Emacs 28.1. (line 202) 3179 * string-clean-whitespace: Emacs 28.1. (line 171) 3180 * string-distance: Emacs 27.1. (line 86) 3181 * string-equal-ignore-case: Emacs 29.1. (line 246) 3182 * string-fill: Emacs 28.1. (line 178) 3183 * string-glyph-split: Emacs 29.1. (line 301) 3184 * string-greaterp: Emacs 25.1. (line 64) 3185 * string-lines: Emacs 28.1. (line 186) 3186 * string-pad: Emacs 28.1. (line 193) 3187 * string-replace: Emacs 28.1. (line 77) 3188 * string-search: Emacs 28.1. (line 34) 3189 * string-split: Emacs 29.1. (line 252) 3190 * subr-primitive-p: Emacs 28.1. (line 364) 3191 * substitute-quotes: Emacs 29.1. (line 34) 3192 * take: Emacs 29.1. (line 199) 3193 * temporary-file-directory: Emacs 26.1. (line 137) 3194 * text-property-search-backward: Emacs 27.1. (line 332) 3195 * text-property-search-forward: Emacs 27.1. (line 260) 3196 * text-quoting-style: Emacs 28.1. (line 28) 3197 * thing-at-mouse: Emacs 28.1. (line 285) 3198 * thread-first: Emacs 25.1. (line 122) 3199 * thread-last: Emacs 25.1. (line 143) 3200 * time-equal-p: Emacs 27.1. (line 208) 3201 * use-region-beginning: Emacs 29.1. (line 47) 3202 * use-region-end: Emacs 29.1. (line 44) 3203 * use-region-noncontiguous-p: Emacs 29.1. (line 41) 3204 * value<: Emacs 30.1. (line 33) 3205 * when-let: Emacs 25.1. (line 114) 3206 * when-let*: Emacs 26.1. (line 153) 3207 * while-let: Emacs 29.1. (line 606) 3208 * window-configuration-equal-p: Emacs 29.1. (line 612) 3209 * with-buffer-unmodified-if-unchanged: Emacs 29.1. (line 324) 3210 * with-delayed-message: Emacs 29.1. (line 131) 3211 * with-environment-variables: Emacs 28.1. (line 309) 3212 * with-existing-directory: Emacs 28.1. (line 132) 3213 * with-file-modes: Emacs 25.1. (line 71) 3214 * with-memoization: Emacs 29.1. (line 68) 3215 * with-minibuffer-selected-window: Emacs 27.1. (line 38) 3216 * with-restriction: Emacs 29.1. (line 73) 3217 * with-suppressed-warnings: Emacs 27.1. (line 65) 3218 * with-window-non-dedicated: Emacs 28.1. (line 379) 3219 * without-restriction: Emacs 29.1. (line 107) 3220 * xor: Emacs 27.1. (line 142) 3221 3222 3223 File: doc23GpG6.info, Node: Variable Index, Prev: Function Index, Up: Top 3224 3225 Appendix B Variable Index 3226 ************************* 3227 3228 3229 * Menu: 3230 3231 * completion-lazy-hilit: Emacs 30.1. (line 113) 3232 * completion-lazy-hilit-fn: Emacs 30.1. (line 137) 3233 * exec-path: Emacs 27.1. (line 228) 3234 * gensym-counter: Emacs 26.1. (line 77) 3235 * lisp-directory: Emacs 29.1. (line 17) 3236 * mounted-file-systems: Emacs 26.1. (line 133) 3237 * regexp-unmatchable: Emacs 27.1. (line 152) 3238 * set-transient-map-timeout: Emacs 29.1. (line 736) 3239 * text-quoting-style: Emacs 25.1. (line 13) 3240 3241 3242 3243 Tag Table: 3244 Node: Top829 3245 Node: Introduction2258 3246 Node: Overview2421 3247 Node: Usage2947 3248 Node: Limitations7326 3249 Node: Support12192 3250 Node: Emacs 25.112777 3251 Node: Emacs 26.121265 3252 Node: Emacs 27.138559 3253 Node: Emacs 28.158956 3254 Node: Emacs 29.178835 3255 Node: Emacs 30.1116233 3256 Node: Development129248 3257 Node: Function Index130982 3258 Node: Variable Index147436 3259 3260 End Tag Table 3261 3262 3263 Local Variables: 3264 coding: utf-8 3265 End: