emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-28 8807a4f532: Enable 256 colors in fbterm.


From: Gregory Heytings
Subject: emacs-28 8807a4f532: Enable 256 colors in fbterm.
Date: Tue, 30 Aug 2022 17:09:03 -0400 (EDT)

branch: emacs-28
commit 8807a4f53204674a796cb2db73716e09736b548e
Author: Gregory Heytings <gregory@heytings.org>
Commit: Gregory Heytings <gregory@heytings.org>

    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(-)

diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi
index 2da37a1d21..32fdcb8058 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 0000000000..ad7150c1a1
--- /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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]