Lisp Changes in Emacs 27.1

8 Lisp Changes in Emacs 27.1

8.1 Emacs Lisp integers can now be of arbitrary size.

Emacs uses the GNU Multiple Precision (GMP) library to support integers whose size is too large to support natively. The integers supported natively are known as "fixnums", while the larger ones are "bignums". The new predicates bignump and fixnump can be used to distinguish between these two types of integers.

All the arithmetic, comparison, and logical (a.k.a. "bitwise") operations where bignums make sense now support both fixnums and bignums. However, note that unlike fixnums, bignums will not compare equal with eq, you must use eql instead. (Numerical comparison with '=' works on both, of course.)

Since large bignums consume a lot of memory, Emacs limits the size of the largest bignum a Lisp program is allowed to create. The nonnegative value of the new variable integer-width specifies the maximum number of bits allowed in a bignum. Emacs signals an integer overflow error if this limit is exceeded.

Several primitive functions formerly returned floats or lists of integers to represent integers that did not fit into fixnums. These functions now simply return integers instead. Affected functions include functions like encode-char that compute code-points, functions like file-attributes that compute file sizes and other attributes, functions like process-id that compute process IDs, and functions like user-uid and group-gid that compute user and group IDs.

8.2 overflow-error is now documented as a subcategory of range-error.

Formerly it was undocumented, and was (incorrectly) a subcategory of domain-error.

8.3 Time values

8.3.1 New function time-convert converts Lisp time values to Lisp

timestamps of various forms, including a new timestamp form '(TICKS . HZ)' where TICKS is an integer and HZ a positive integer denoting a clock frequency.

8.3.2 Although the default timestamp format is still '(HI LO US PS)',

it is planned to change in a future Emacs version, to exploit bignums. The documentation has been updated to mention that the timestamp format may change and that programs should use functions like format-time-string, decode-time, and time-convert rather than probing the innards of a timestamp directly, or creating a timestamp by hand.

8.3.3 Decoded (calendrical) timestamps now have subsecond resolution.

This affects decode-time, which generates these timestamps, as well as functions like encode-time that accept them. The subsecond info is present as a '(TICKS . HZ)' value in the seconds element of a decoded timestamp, and decode-time has a new optional FORM argument specifying the form of the seconds member. For example, if X is the timestamp '(1566009571321878186 . 1000000000)', which represents "2019-08-17 02:39:31.321878186 UTC", '(decode-time X t t)' returns '((31321878186 . 1000000000) 39 2 17 8 2019 6 nil 0)' instead of the traditional '(31 39 2 17 8 2019 6 nil 0)' returned by plain '(decode-time X t)'. Although the default FORM is currently integer, which truncates the seconds to an integer and is the traditional behavior, this default may change in future Emacs versions, so callers requiring an integer should specify FORM explicitly.

8.3.4 encode-time supports a new API '(encode-time TIME)'.

The old encode-time API is still supported.

8.3.5 A new package to parse ISO 8601 time, date, durations and

intervals has been added. The main function to use is iso8601-parse, but there's also iso8601-parse-date, iso8601-parse-time, iso8601-parse-duration and iso8601-parse-interval. All these functions return decoded time structures, except the final one, which returns three of them (start, end and duration).

8.3.6 time-add, time-subtract, and time-less-p now accept

infinities and NaNs too, and propagate them or return nil like floating-point operators do. If both arguments are finite, these functions now return exact results instead of rounding in some cases, and they also avoid excess precision when that is easy.

8.3.7 New function time-equal-p compares time values for equality.

8.3.8 format-time-string supports a new conversion specifier flag '+'

that acts like the 0 flag but also puts a '+' before nonnegative years containing more than four digits. This is for compatibility with POSIX.1-2017.

8.3.9 To access (or alter) the elements of a decoded time value, the

decoded-time-second, decoded-time-minute, decoded-time-hour, decoded-time-day, decoded-time-month, decoded-time-year, decoded-time-weekday, decoded-time-dst and decoded-time-zone accessors can be used.

8.3.10 The new functions date-days-in-month (which will say how many

days there are in a month in a specific year), date-ordinal-to-time (that computes the date of an ordinal day), decoded-time-add (for doing computations on a decoded time structure), make-decoded-time (for making a decoded time structure with only the given keywords filled out), and encoded-time-set-defaults (which fills in nil elements as if it's midnight January 1st, 1970) have been added.

8.3.11 In the DST slot, encode-time and parse-time-string now return -1

if it is not known whether daylight saving time is in effect. Formerly they were inconsistent: encode-time returned t in this situation, whereas parse-time-string returned nil. Now they consistently use nil to mean that DST is not in effect, and use -1 to mean that it is not known whether DST is in effect.

8.4 New macro benchmark-progn.

This macro works like progn, but messages how long it takes to evaluate the body forms. The value of the last form is the return value.

8.5 New function read-char-from-minibuffer.

This function works like read-char, but uses read-from-minibuffer to read a character, so it maintains a history that can be navigated via usual minibuffer keystrokes M-p/M-n.

8.6 New variables set-message-function and clear-message-function

can be used to specify functions to show and clear messages that normally are displayed in the echo area.

8.7 setq-local can now set an arbitrary number of variables, which

makes the syntax more like setq.

8.8 reveal-mode can now also be used for more than to toggle between

invisible and visible: It can also toggle display properties in overlays. This is only done on display properties that have the reveal-toggle-invisible property set.

8.9 process-contact now takes an optional NO-BLOCK argument to allow

not waiting for a process to be set up.

8.10 New variable read-process-output-max controls sub-process throughput.

This variable determines how many bytes can be read from a sub-process in one read operation. The default, 4096 bytes, was previously a hard-coded constant. Setting it to a larger value might enhance throughput of reading from sub-processes that produces vast (megabytes) amounts of data in one go.

8.11 The new user option quit-window-hook is now run first when

executing the quit-window command.

8.12 The user options help-enable-completion-auto-load,

help-enable-auto-load and vhdl-project-auto-load, as well as the function vhdl-auto-load-project have been renamed to have "autoload" without the hyphen in their names. Obsolete aliases from the old names have been added.

8.13 Buttons (created with make-button and related functions) can

now use the button-data property. If present, the data in this property will be passed on to the action function instead of the button itself in button-activate.

8.14 defcustom now takes a ':local' keyword that can be either t or

permanent, which mean that the variable should be automatically buffer-local. permanent also sets the variable's permanent-local property.

8.15 The new macro with-suppressed-warnings can be used to suppress

specific byte-compile warnings.

8.16 The new macro ignore-error is like ignore-errors, but takes a

specific error condition, and will only ignore that condition. (This can also be a list of conditions.)

8.17 The new function byte-compile-info-message can be used to output

informational messages that look pleasing during the Emacs build.

8.18 New help-fns-describe-variable-functions hook.

It makes it possible to add metadata information to describe-variable.

8.19 i18n (internationalization)

8.19.1 ngettext can be used now to return the right plural form

according to the given numeric value.

8.20 inhibit-null-byte-detection is renamed to inhibit-nul-byte-detection.

8.21 self-insert-command takes the char to insert as (optional) argument.

8.22 lookup-key can take a list of keymaps as argument.

8.23 condition-case now accepts t to match any error symbol.

8.24 New function proper-list-p.

Given a proper list as argument, this predicate returns its length; otherwise, it returns nil. format-proper-list-p is now an obsolete alias for the new function.

8.25 define-minor-mode automatically documents the meaning of ARG.

8.26 The function recenter now accepts an additional optional argument.

By default, calling recenter will not redraw the frame even if recenter-redisplay is non-nil. Call recenter with the new second argument non-nil to force redisplay per recenter-redisplays value.

8.27 New functions major-mode-suspend and major-mode-restore.

Use them when switching temporarily to another major mode, e.g. for hexl-mode, or to switch between c-mode and image-mode in XPM.

8.28 New macro dolist-with-progress-reporter.

This works like dolist, but reports progress similar to dotimes-with-progress-reporter.

8.29 New hook after-delete-frame-functions.

This works like delete-frame-functions, but runs after the frame to be deleted has been made dead and removed from the frame list.

8.30 The function provided-mode-derived-p was extended to support aliases.

The function now returns non-nil when the argument MODE is derived from any alias of any of MODES.

8.31 New frame focus state inspection interface.

The hooks focus-in-hook and focus-out-hook are now obsolete. Instead, attach to after-focus-change-function using add-function and inspect the focus state of each frame using frame-focus-state.

8.32 Emacs now requests and recognizes focus-change notifications from TTYs.

On terminal emulators that support the feature, Emacs can now support focus-in-hook and focus-out-hook for TTY frames.

8.33 Window-specific face remapping.

Face specifications (of the kind used in face-remapping-alist) now support filters, allowing faces to vary between different windows displaying the same buffer. See the node "(elisp) Face Remapping" of the Emacs Lisp Reference manual for more detail.

8.34 Window change functions have been redesigned.

Hooks reacting to window changes run now only when redisplay detects that a change has actually occurred. Six hooks are now provided: window-buffer-change-functions (run after window buffers have changed), window-size-change-functions (run after a window was assigned a new buffer or size), window-configuration-change-hook (like the former but run also when a window was deleted), window-selection-change-functions (run when the selected window changed) and window-state-change-functions and window-state-change-hook (run when any of the preceding ones is run). Applications can enforce running the latter two using the new function set-frame-window-state-change. window-scroll-functions are unaffected by these changes.

In addition, a number of functions now allow the caller to detect what has changed since last redisplay: window-old-buffer returns for any window the buffer it showed at that time. old-selected-window and old-selected-frame return the window and frame that were selected during last redisplay. window-old-pixel-width (renamed from window-pixel-width-before-size-change), window-old-pixel-height (renamed from window-pixel-height-before-size-change), window-old-body-pixel-width and window-old-body-pixel-height return the total and body sizes of any window during last redisplay.

Also run-window-configuration-change-hook is declared obsolete.

See the section "(elisp) Window Hooks" in the Elisp manual for a detailed explanation of the new behavior.

8.35 Scroll bar and fringe settings can now be made persistent for windows.

The functions set-window-scroll-bars and set-window-fringes now have a new optional argument that makes the settings they produce reliably survive subsequent invocations of set-window-buffer.

8.36 New user option resize-mini-frames.

This option allows automatically resizing minibuffer-only frames similarly to how minibuffer windows are resized on "normal" frames.

8.37 New buffer display action function display-buffer-in-direction.

This function allows specifying the location of the window chosen by display-buffer in various ways.

8.38 New buffer display action alist entry dedicated.

Such an entry allows specifying the dedicated status of a window created by display-buffer.

8.39 New buffer display action alist entry window-min-height.

Such an entry allows specifying a minimum height of the window used for displaying a buffer. display-buffer-below-selected is the only action function to respect it at the moment.

8.40 New buffer display action alist entry direction.

This entry is used to specify the location of the window chosen by display-buffer-in-direction.

8.41 Additional meaning of display action alist entry window.

A window entry can now also specify a reference window for display-buffer-in-direction.

8.42 The function assoc-delete-all now takes an optional predicate argument.

8.43 New function string-distance to calculate the Levenshtein distance

between two strings.

8.44 print-quoted now defaults to t, so if you want to see

'(quote x)' instead of 'x you will have to bind it to nil where applicable.

8.45 Numbers formatted via '%o' or '%x' are now formatted as signed integers.

This avoids problems in calls like '(read (format "#x%x" -1))', and is more compatible with bignums. To get the traditional machine-dependent behavior, set the experimental variable binary-as-unsigned to t, and if the new behavior breaks your code please email <32252@debbugs.gnu.org>. Because '%o' and '%x' can now format signed integers, they now support the '+' and space flags.

8.46 In Emacs Lisp mode, symbols with confusable quotes are highlighted.

For example, the first character in '‘foo' would be highlighted in font-lock-warning-face.

8.47 Omitting variables after '&optional' and '&rest' is now allowed.

For example '(defun foo (&optional))' is no longer an error. This is sometimes convenient when writing macros. See the ChangeLog entry titled "Allow '&rest' or '&optional' without following variable (Bug#29165)" for a full listing of which arglists are accepted across versions.

8.48 Internal parsing commands now use syntax-ppss and disregard

open-paren-in-column-0-is-defun-start. This affects mostly things like forward-comment, scan-sexps, and forward-sexp when parsing backward. The new variable comment-use-syntax-ppss can be set to nil to recover the old behavior if needed. This also means that there is no longer any need to precede opening brackets at the start of a line inside documentation strings with a backslash, although there is no harm in doing so to make the code easier to edit with an older Emacs version.

8.49 New symbolic accessor functions for a parse state list.

The new accessor functions ppss-depth, ppss-list-start, ppss-last-sexp-start, ppss-string-terminator, comment-depth, quoted-p, comment-style, comment-or-string-start, open-parens, and two-character-syntax can be used on the list value returned by parse-partial-sexp and syntax-ppss.

8.50 The server-name and server-socket-dir variables are set when a

socket has been passed to Emacs.

8.51 The file-system-info function is now available on all platforms.

instead of just Microsoft platforms. This fixes a get-free-disk-space bug on OS X 10.8 and later.

8.52 The function get-free-disk-space returns now a non-nil value for

remote systems, which support this check.

8.53 memory-limit now returns a better estimate of memory consumption.

8.54 When interpreting gc-cons-percentage, Emacs now estimates the

heap size more often and (we hope) more accurately. E.g., formerly '(progn (let ((gc-cons-percentage 0.8)) BODY1) BODY2)' continued to use the 0.8 value during BODY2 until the next garbage collection, but that is no longer true. Applications may need to re-tune their GC tricks.

8.55 New macro combine-change-calls arranges to call the change hooks

(before-change-functions and after-change-functions) just once each around a sequence of lisp forms, given a region. This is useful when a function makes a possibly large number of repetitive changes and the change hooks are time consuming.

8.56 eql, make-hash-table, etc. now treat NaNs consistently.

Formerly, some of these functions ignored signs and significands of NaNs. Now, all these functions treat NaN signs and significands as significant. For example, '(eql 0.0e+NaN -0.0e+NaN)' now returns nil because the two NaNs have different signs; formerly it returned t. Also, Emacs now reads and prints NaN significands; e.g., if X is a NaN, '(format "%s" X)' now returns "0.0e+NaN", "1.0e+NaN", etc., depending on X's significand.

8.57 The function make-string accepts an additional optional argument.

If the optional third argument is non-nil, make-string will produce a multibyte string even if its second argument is an ASCII character.

8.58 '(format "%d" X)' no longer mishandles a floating-point number X that

does not fit in a machine integer.

8.59 New coding-system ibm038.

This is the International EBCDIC encoding, also available as aliases ebcdic-int and cp038.

8.60 New JSON parsing and serialization functions json-serialize,

json-insert, json-parse-string, and json-parse-buffer. These are implemented in C using the Jansson library.

8.61 New function ring-resize.

ring-resize can be used to grow or shrink a ring.

8.62 New function flatten-tree.

flatten-list is provided as an alias. These functions take a tree and flatten it such that the result is a list of all the terminal nodes.

8.63 zlib-decompress-region can partially decompress corrupted data.

If the new optional ALLOW-PARTIAL argument is passed, then the data that was decompressed successfully before failing will be inserted into the buffer.

8.64 Image mode

8.64.1 New library Exif.

An Exif library has been added that can parse JPEG files and output data about creation times and orientation and the like. exif-parse-file and exif-parse-buffer are the main interface functions.

8.64.2 image-mode now uses this library to automatically rotate images

according to the orientation in the Exif data, if any.

8.64.3 The command image-rotate now accepts a prefix argument.

With a prefix argument, image-rotate now rotates the image at point 90 degrees counter-clockwise, instead of the default clockwise.

8.64.4 In image-mode the image is resized automatically to fit in window.

By default, the image will resize upon first display and whenever the window's dimensions change. Two user options image-auto-resize and image-auto-resize-on-window-resize control the resizing behavior (including the possibility to disable auto-resizing). A new prefix key s contains the commands that can be used to fit the image to the window manually.

8.64.5 Some image-mode variables are now buffer-local.

The image parameters image-transform-rotation, image-transform-scale and image-transform-resize are now declared buffer-local, so each buffer could have its own values for these parameters.

8.64.6 Three new image-mode commands have been added: m, which marks

the file in the dired buffer(s) for the directory the file is in; u, which unmarks the file; and w, which pushes the current buffer's file name to the kill ring.

8.64.7 New library image-converter.

If you need to view exotic image formats for which Emacs doesn't have native support, customize the new user option image-use-external-converter to t. If your system has GraphicsMagick, ImageMagick or ffmpeg installed, they will then be used to convert images automatically before displaying them.

8.64.8 auto-mode-alist now includes many of the types typically

supported by the external image converters, like WEPB, BMP and ICO. These now default to using image-mode.

8.64.9 imagemagick-types-inhibit disables using ImageMagick by default.

image-mode started using ImageMagick by default for all images some years back. It now respects imagemagick-types-inhibit as a way to disable that.

8.65 Modules

8.65.1 The function load now behaves correctly when loading modules.

Specifically, it puts the module name into load-history, prints loading messages if requested, and protects against recursive loads.

8.65.2 New module environment function process_input to process user

input while module code is running.

8.65.3 New module environment functions make_time and extract_time to

convert between timespec structures and Emacs Lisp time values.

8.65.4 New module environment functions make_big_integer and

extract_big_integer to create and extract arbitrary-size integer values.

8.65.5 emacs-module.h now defines a macro EMACS_MAJOR_VERSION that expands

to the major version of the latest Emacs supported by the header.

8.66 The function read-variable now uses its own history list.

The history of variable names read by read-variable is recorded in the new variable custom-variable-history.

8.67 The functions string-to-unibyte and string-to-multibyte are no

longer declared obsolete. We have found that there are legitimate use cases for these functions, where there's no better alternative. We believe that the incorrect uses of these functions all but disappeared by now, so we are un-obsoleting them.

8.68 New function group-name returns a group name corresponding to GID.

8.69 make-process now takes a keyword argument ':file-handler'; if

that is non-nil, it will look for a file name handler for the current buffer's default-directory and invoke that file name handler to make the process. That way make-process can start remote processes.

8.70 '(locale-info 'paper)' now returns the paper size on systems that support it.

This is currently supported on GNUish hosts and on modern versions of MS-Windows.

8.71 The function regexp-opt, when given an empty list of strings, now

returns a regexp that never matches anything, which is an identity for this operation. Previously, the empty string was returned in this case.

8.72 New constant regexp-unmatchable contains a never-matching regexp.

It is a convenient and readable way to specify a regexp that should not match anything, and is as fast as any such regexp can be.

8.73 New functions to handle the URL variant of base-64 encoding.

New functions base64url-encode-string and base64url-encode-region implement the url-variant of base-64 encoding as defined in RFC4648.

The functions base64-decode-string and base64-decode-region now accept an optional argument to decode the URL variant of base-64 encoding.

8.74 The function file-size-human-readable accepts more optional arguments.

The new third argument is a string put between the number and unit; it defaults to the empty string. The new fourth argument is a string representing the unit to use; it defaults to "B" when the second argument is iec and the empty string otherwise. We recommend a space or non-breaking space as third argument, and "B" as fourth argument, circumstances allowing.

8.75 format-spec has been expanded with several modifiers to allow

greater flexibility when customizing variables. The modifiers include zero-padding, upper- and lower-casing, and limiting the length of the interpolated strings. The function has now also been documented in the Emacs Lisp manual.

8.76 directory-files-recursively can now take an optional PREDICATE

parameter to control descending into subdirectories, and a FOLLOW-SYMLINK parameter to say that symbolic links that point to other directories should be followed.

8.77 New function xor returns the boolean exclusive-or of its args.

The function was previously defined in array.el, but has been moved to subr.el so that it is available by default. It now always returns the non-nil argument when the other is nil. Several duplicates of xor in other packages are now obsolete aliases of xor.

8.78 define-globalized-minor-mode now takes BODY forms.

8.79 New text property help-echo-inhibit-substitution.

Setting this on the first character of a help string disables conversions via substitute-command-keys.

8.80 New text property minibuffer-message.

Setting this on a character of the minibuffer text will display the temporary echo messages before that character, when messages need to be displayed while minibuffer is active.

8.81 undo can be made to ignore the active region for a command

by setting undo-inhibit-region symbol property of that command to non-nil. This is used by mouse-drag-region to make the effect easier to undo immediately afterwards.

8.82 When called interactively, next-buffer and previous-buffer now

signal user-error if there is no buffer to switch to.