]> code.delx.au - gnu-emacs/blobdiff - lisp/term/xterm.el
Merge from emacs-24; up to 2012-04-22T13:58:00Z!cyd@gnu.org
[gnu-emacs] / lisp / term / xterm.el
index b0fe443ca59d29730456d5716b9bb87ac9bbf4d8..51e5aa5796d04ef8bc194d774aa34d13fa17e076 100644 (file)
@@ -1,6 +1,6 @@
 ;;; xterm.el --- define function key sequences and standard colors for xterm
 
-;; Copyright (C) 1995, 2001-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2012 Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals
 (defgroup xterm nil
   "XTerm support."
   :version "24.1"
-  :group 'emacs)
+  :group 'environment)
 
 (defcustom xterm-extra-capabilities 'check
-  "Set to a list if the XTerm supports modifyOtherKeys or
-reporting the background color.  Set to 'check to check for those
-features.  Set to nil to skip the checks."
+  "Whether Xterm supports some additional, more modern, features.
+If nil, just assume that it does not.
+If `check', try to check if it does.
+If a list, assume that the listed features are supported, without checking.
+
+The relevant features are:
+  modifyOtherKeys  -- if supported, more key bindings work (e.g, \"\\C-,\")
+  reportBackground -- if supported, Xterm reports its background color
+"
+  :version "24.1"
   :group 'xterm
   :type '(choice (const :tag "No" nil)
                  (const :tag "Check" check)
@@ -460,7 +467,7 @@ features.  Set to nil to skip the checks."
   "Terminal initialization function for xterm."
   ;; rxvt terminals sometimes set the TERM variable to "xterm", but
   ;; rxvt's keybindings are incompatible with xterm's. It is
-  ;; better in that case to use rxvt's initializion function.
+  ;; better in that case to use rxvt's initialization function.
   (if (and (getenv "COLORTERM" (selected-frame))
           (string-match "\\`rxvt" (getenv "COLORTERM" (selected-frame))))
       (tty-run-terminal-initialization (selected-frame) "rxvt")
@@ -488,9 +495,7 @@ features.  Set to nil to skip the checks."
   (when xterm-extra-capabilities
     (let ((coding-system-for-read 'binary)
           (chr nil)
-          (str nil)
-          (background-regex
-           "11;rgb:\\([a-f0-9]+\\)/\\([a-f0-9]+\\)/\\([a-f0-9]+\\)")
+          (str "")
           (recompute-faces nil)
           ;; If `xterm-extra-capabilities' is 'check, we don't know
           ;; the capabilities.  We need to check for those defined
@@ -525,10 +530,7 @@ features.  Set to nil to skip the checks."
         (while (not (equal (setq chr (read-event nil nil 2)) ?c))
           (setq str (concat str (string chr))))
         (if (string-match ">0;\\([0-9]+\\);0" str)
-            (setq version
-                  (string-to-number
-                   (substring str (match-beginning 1) (match-end 1))))))
-
+            (setq version (string-to-number (match-string 1 str)))))
       ;; 2. If reportBackground is known to be supported, or the
       ;; version is 242 or higher, assume the xterm supports
       ;; reporting the background color (TODO: maybe earlier
@@ -543,7 +545,8 @@ features.  Set to nil to skip the checks."
           (setq str "")
           (while (not (equal (setq chr (read-event nil nil 2)) ?\\))
             (setq str (concat str (string chr))))
-          (if (string-match background-regex str)
+          (if (string-match
+               "11;rgb:\\([a-f0-9]+\\)/\\([a-f0-9]+\\)/\\([a-f0-9]+\\)" str)
               (setq recompute-faces
                     (xterm-maybe-set-dark-background-mode
                      (string-to-number (match-string 1 str) 16)
@@ -552,8 +555,7 @@ features.  Set to nil to skip the checks."
 
       ;; 3. If modifyOtherKeys is known to be supported or the
       ;; version is 216 (the version when modifyOtherKeys was
-      ;; introduced) or higher, initialize the modifyOtherKeys
-      ;; support.
+      ;; introduced) or higher, initialize the modifyOtherKeys support.
       (if (or (memq 'modifyOtherKeys given-capabilities)
               (and (memq 'modifyOtherKeys tocheck-capabilities)
                    version
@@ -642,7 +644,7 @@ versions of xterm."
        ;; 216 non-gray colors first
        (let ((r 0) (g 0) (b 0))
          (while (> ncolors 24)
-           ;; This and other formulae taken from 256colres.pl and
+           ;; This and other formulas taken from 256colres.pl and
            ;; 88colres.pl in the xterm distribution.
            (tty-color-define (format "color-%d" (- 256 ncolors))
                              (- 256 ncolors)