Annotation of 43BSD/contrib/emacs/lisp/term/xterm.el, revision 1.1.1.1

1.1       root        1: ;; Parse switches controlling how Emacs interfaces with X window system.
                      2: ;; Copyright (C) 1985 Richard M. Stallman.
                      3: 
                      4: ;; This file is part of GNU Emacs.
                      5: 
                      6: ;; GNU Emacs is distributed in the hope that it will be useful,
                      7: ;; but WITHOUT ANY WARRANTY.  No author or distributor
                      8: ;; accepts responsibility to anyone for the consequences of using it
                      9: ;; or for whether it serves any particular purpose or works at all,
                     10: ;; unless he says so in writing.  Refer to the GNU Emacs General Public
                     11: ;; License for full details.
                     12: 
                     13: ;; Everyone is granted permission to copy, modify and redistribute
                     14: ;; GNU Emacs, but only under the conditions described in the
                     15: ;; GNU Emacs General Public License.   A copy of this license is
                     16: ;; supposed to have been given to you along with GNU Emacs so you
                     17: ;; can know your rights and responsibilities.  It should be in a
                     18: ;; file named COPYING.  Among other things, the copyright notice
                     19: ;; and this notice must be preserved on all copies.
                     20: 
                     21: 
                     22: (defvar x-switches nil
                     23:   "Alist of command switches and values for X window system interface.
                     24: You can set this in your init file, if you want some defaults
                     25: for these switches.  Example:
                     26:   (setq x-switches '((\"-r\" . t) (\"-font\" . \"foo\") (\"-b\" . \"8\")))")
                     27: 
                     28: (setq command-switch-alist
                     29:       (append '(("-r" . x-handle-switch)
                     30:                ("-i" . x-handle-switch)
                     31:                ("-font" . x-handle-switch)
                     32:                ("-w" . x-handle-switch)
                     33:                ("-d" . x-handle-switch)
                     34:                ("-b" . x-handle-switch)
                     35:                ("-fg" . x-handle-switch)
                     36:                ("-bg" . x-handle-switch)
                     37:                ("-bd" . x-handle-switch)
                     38:                ("-cr" . x-handle-switch)
                     39:                ("-ms" . x-handle-switch))
                     40:              command-switch-alist))
                     41: 
                     42: ;; This is run after the command args are parsed.
                     43: (defun x-handle-switch (switch)
                     44:   (if (x-handle-switch-1 switch (car command-line-args))
                     45:       (setq command-line-args (cdr command-line-args))))
                     46: 
                     47: (defun x-handle-switch-1 (switch arg)
                     48:   (cond ((string= switch "-r")
                     49:         (x-flip-color)
                     50:         nil)
                     51:        ((string= switch "-i")
                     52:         (x-set-icon t)
                     53:         nil)
                     54:        ((string= switch "-font")
                     55:         (x-set-font arg)
                     56:         t)
                     57:        ((string= switch "-b")
                     58:         (x-set-border-width (string-to-int arg))
                     59:         t)
                     60:        ((string= switch "-d")
                     61:         (x-new-display arg)
                     62:         t)
                     63:        ((string= switch "-w")
                     64:         (x-create-x-window arg)
                     65:         t)
                     66:        ((string= switch "-fg")
                     67:         (x-set-foreground-color arg)
                     68:         t)
                     69:        ((string= switch "-bg")
                     70:         (x-set-background-color arg)
                     71:         t)
                     72:        ((string= switch "-bd")
                     73:         (x-set-border-color arg)
                     74:         t)
                     75:        ((string= switch "-cr")
                     76:         (x-set-cursor-color arg)
                     77:         t)
                     78:        ((string= switch "-ms")
                     79:         (x-set-mouse-color arg)
                     80:         t)))
                     81: 
                     82: ;; Convert a string of the form "WWxHH+XO+YO",
                     83: ;; where WW, HH, XO and YO are numerals,
                     84: ;; into a list (WW HH XO YO).
                     85: ;; "xHH" may be omitted; then 0 is used for HH.
                     86: ;; XO and YO may be preceded by - instead of + to make them negative.
                     87: ;; Either YO or both XO and YO may be omitted; zero is used.
                     88: (defun x-parse-edge-spec (arg)
                     89:   (let ((cols-by-font 0)
                     90:        (rows-by-font 0)
                     91:        (xoffset 0)
                     92:        (yoffset 0))
                     93:     (if (string-match "^=" arg)
                     94:        (setq cols-by-font (x-extract-number))
                     95:       (error "Invalid X window size/position spec"))
                     96:     (if (string-match "^x" arg)                ;get rows-by-font
                     97:        (setq rows-by-font (x-extract-number)))
                     98:     (if (string-match "^[-+]" arg)
                     99:        (setq xoffset (x-extract-number)))
                    100:     (if (string-match "^[-+]" arg)
                    101:        (setq yoffset (x-extract-number)))
                    102:     (or (equal arg "")
                    103:        (error "Invalid X window size/position spec"))
                    104:     (list cols-by-font rows-by-font xoffset yoffset)))
                    105: 
                    106: ;; Subroutine to extract the next numeral from the front of arg,
                    107: ;; returning it and shortening arg to remove its text.
                    108: ;; If arg is negative, subtract 1 before returning it.
                    109: (defun x-extract-number ()
                    110:   (if (string-match "^[x=]" arg)
                    111:       (setq arg (substring arg 1)))
                    112:   (or (string-match "[-+]?[0-9]+" arg)
                    113:       (error "Invalid X window size/position spec"))
                    114:   (prog1
                    115:       (+ (string-to-int arg)
                    116:         (if (string-match "^-" arg) -1 0))
                    117:     (setq arg
                    118:          (substring arg
                    119:                     (or (string-match "[^0-9]" arg 1)
                    120:                         (length arg))))))
                    121: 
                    122: (defun x-get-default-args ()
                    123:   (let (value)
                    124:     (if (not (string= (setq value (x-get-default "bodyfont")) ""))
                    125:        (x-handle-switch-1 "-font"  value))
                    126:     (if (string-match "On" (x-get-default "reversevideo"))
                    127:        (x-handle-switch-1 "-r" t))
                    128:     (if (string-match "On" (x-get-default "bitmapicon"))
                    129:        (x-handle-switch-1 "-i" t))
                    130:     (if (not (string= (setq value (x-get-default "borderwidth")) ""))
                    131:        (x-handle-switch-1 "-b" value))
                    132:     (if (not (string= (setq value (x-get-default "foreground")) ""))
                    133:        (x-handle-switch-1 "-fg" value))
                    134:     (if (not (string= (setq value (x-get-default "background")) ""))
                    135:        (x-handle-switch-1 "-bg" value))
                    136:     (if (not (string= (setq value (x-get-default "border")) ""))
                    137:        (x-handle-switch-1 "-bd" value))
                    138:     (if (not (string= (setq value (x-get-default "cursor")) ""))
                    139:        (x-handle-switch-1 "-cr" value))
                    140:     (if (not (string= (setq value (x-get-default "mouse")) ""))
                    141:        (x-handle-switch-1 "-ms" value))))
                    142: 
                    143: (defun x-new-display (display)
                    144:   "This function takes one argument, the display where you wish to
                    145: continue your editing session.  Your current window will be unmapped and
                    146: the current display will be closed.  The new X display will be opened and
                    147: the rubber-band outline of the new window will appear on the new X display."
                    148:   (interactive "sDisplay to switch emacs to:  ")
                    149:   (x-change-display display)
                    150:   (x-get-default-args))
                    151: 
                    152: ;; So far we have only defined some functions.
                    153: ;; Now we start processing X-related switches
                    154: ;; and redefining commands and variables,
                    155: ;; only if Emacs has been compiled to support direct interface to X.
                    156: 
                    157: (if (fboundp 'x-change-display)
                    158:     (progn
                    159:       ;; xterm.c depends on using interrupt-driven input.
                    160:       (set-input-mode t nil)
                    161: 
                    162:       ;; Not defvar!  This is not DEFINING this variable, just specifying
                    163:       ;; a value for it.
                    164:       (setq term-setup-hook 'x-pop-up-window)
                    165: 
                    166:       (load "x-mouse" t t)
                    167:       (put 'suspend-emacs 'disabled t)
                    168:       (global-set-key "\C-z" 'undefined)
                    169:       (global-set-key "\C-x\C-z" 'undefined)
                    170: 
                    171:       (x-get-default-args)
                    172: 
                    173:       ;; If used has .Xdefaults file, process switch settings for Emacs
                    174:       ;; recorded there.
                    175:       ;;(if user
                    176:       ;;    (let ((Xdefs-file (concat "~" user "/.Xdefaults")))
                    177:       ;;      (if (file-exists-p Xdefs-file)
                    178:       ;;         (x-get-default-args Xdefs-file))))
                    179: 
                    180:       ;; Process switch settings made by .emacs file.
                    181:       (while x-switches
                    182:        (x-handle-switch-1 (car (car x-switches)) (cdr (car x-switches)))
                    183:        (setq x-switches (cdr x-switches)))
                    184:       ))

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.