Subject: bug#51116: 28.0.60; tty-run-terminal-initialization unnecessarily decompresses .el.gz file

From: "Sebastian Arlund Nørgaard" <[email-masked]>
Date: Sun, 10 Oct 2021 09:37:35 +0000

When compressed elisp files are installed, tty-run-terminal-initialization will decompress and interpret an el.gz file rather than use the available compiled .elc file.

The problem is this bit of code (line 2288-2293 in lisp/faces.el):

	(tty-find-type #'(lambda (type)
			   (let ((file (locate-library (concat term-file-prefix type))))
			     (and file
				  (or (assoc file load-history)
				      (load (file-name-sans-extension file)
                                            t t)))))

In my case, the locate-library call will resolve to (locate-library "term/xterm"), which will return

/path/to/install/lisp/term/xterm.el.gz

A bit further down, the call to file-name-sans-extension will strip the extension to xterm.el. But there is only xterm.el.gz and xterm.elc in the path, so load will resolve to the xterm.el.gz, rather than the .elc file. I can reproduce this as follows:

- emacs -nw -Q
- switch to *Messages* buffer
- Buffer contains "uncompressing xterm.el.gz...done"

Ideally the output of load-library should be stripped completely of extensions, so load will resolve to xterm.elc.

(xterm is the tty type for my system, but this would apply just as well for other tty types.)

----------------------

In GNU Emacs 28.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.25, cairo version 1.16.0)
 of 2021-10-07 built on sebastian-Home-Linux
Repository revision: 160e62a23cd722744c74cec9e8d37cb678be0fb1
Repository branch: emacs-28
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Ubuntu 21.04

Configured using:
 'configure --prefix=/home/sebastian/emacs-master-install
 --with-native-compilation --with-cairo --with-dumping=pdumper
 --with-mailutils --with-json --with-x --enable-link-time-optimization
 'CFLAGS=-g3 -O3 -mtune=native -march=native -fomit-frame-pointer''

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBOTF LIBSELINUX LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix