From 8807a4f53204674a796cb2db73716e09736b548e Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Tue, 30 Aug 2022 21:03:01 +0000 Subject: [PATCH] Enable 256 colors in fbterm. * lisp/term/fbterm.el: New file. * doc/misc/efaq.texi (Emacs in a Linux console): Document the TERM environment variable with which the new file is used. --- doc/misc/efaq.texi | 20 ++++++++++++++++---- lisp/term/fbterm.el | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 lisp/term/fbterm.el diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index 2da37a1d215..32fdcb80586 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -3047,23 +3047,35 @@ $ fc-list :spacing=mono family | sed 's/ /\\ /g' You can now start Emacs inside @command{fbterm} with the command +@example +$ fbterm -- env TERM=fbterm emacs +@end example + +In some versions of @command{fbterm}, setting @env{TERM} to +@samp{fbterm} can be omitted. To check whether it is needed, start +Emacs inside @command{fbterm} with the command + @example $ fbterm -- emacs @end example +@noindent +and type @kbd{M-x list-colors-display}. If only 8 colors are +displayed, it is necessary; if 256 colors are displayed, it isn't. + You may want to add an alias for that command in your shell configuration file. For example, if you use Bash, you can add the following line to your @file{~/.bashrc} file: @example -alias emacs="fbterm -- emacs" +alias emacs="fbterm -- env TERM=fbterm emacs" @end example @noindent or, if you use Emacs both in the Linux console and under X: @example -[[ "$(tty)" =~ "/dev/tty" ]] && alias emacs="fbterm -- emacs" +[[ "$(tty)" =~ "/dev/tty" ]] && alias emacs="fbterm -- env TERM=fbterm emacs" @end example The @command{fbterm} terminal emulator may define a number of key @@ -3082,7 +3094,7 @@ start Emacs inside @command{fbterm} as root while ensuring that @command{fbterm} does not define any key bindings for its own use: @example -# capsh --drop=cap_sys_tty_config -- -c "fbterm -- emacs" +# capsh --drop=cap_sys_tty_config -- -c "fbterm -- env TERM=fbterm emacs" @end example Again you may want to add a shortcut for that command in the shell @@ -3096,7 +3108,7 @@ you use Bash, you can add the following function in the root user @example function emacs () @{ - CMD="fbterm -- emacs " + CMD="fbterm -- env TERM=fbterm emacs " for ARG in "$@@" do CMD="$CMD '$ARG' " diff --git a/lisp/term/fbterm.el b/lisp/term/fbterm.el new file mode 100644 index 00000000000..ad7150c1a1f --- /dev/null +++ b/lisp/term/fbterm.el @@ -0,0 +1,27 @@ +;;; fbterm.el -*- lexical-binding:t -*- + +;; Copyright (C) 2022 Free Software Foundation, Inc. + +;; Note that, in some versions of fbterm, the TERM environment +;; variable is set to "linux". When that's the case, the code below +;; will not be executed, and only 8 colors will be available. It is +;; therefore necessary, with these versions of fbterm, to set that +;; environment variable to "fbterm" to enable its 256 color mode +;; extension. See also the node "Emacs in a Linux console" of the +;; Emacs FAQ. + +(require 'term/xterm) + +(defun terminal-init-fbterm () + "Terminal initialization function for fbterm." + + ;; fbterm can't display underlines, even though its terminfo data + ;; says it can. + (tty-no-underline) + + ;; fbterm supports xterm's 256 color mode extension. + (xterm-register-default-colors xterm-standard-colors)) + +(provide 'term/fbterm) + +;;; fbterm.el ends here -- 2.39.2