Annotation of 43BSDReno/contrib/emacs-18.55/lisp/term/x-win.el, revision 1.1

1.1     ! root        1: ;; Parse switches controlling how Emacs interfaces with X window system.
        !             2: ;; Copyright (C) 1986, 1988 Free Software Foundation, Inc.
        !             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: (defconst window-system-version window-system-version
        !            22:   "*Window system version number now in use.")
        !            23: 
        !            24: (defvar x-sigio-bug nil
        !            25:   "Non-NIL means don't use interrupts for input when using X.")
        !            26: 
        !            27: (defvar x-processed-defaults nil
        !            28:   "Non-NIL means that user's X defaults have already been processed.")
        !            29: 
        !            30: (defvar x-switches nil
        !            31:   "Alist of command switches and values for X window system interface.
        !            32: You can set this in your init file, if you want some defaults
        !            33: for these switches.  Example:
        !            34:   (setq x-switches '((\"-r\" . t) (\"-font\" . \"foo\") (\"-b\" . \"8\")))
        !            35: This feature is currently broken for X11.")
        !            36: 
        !            37: (if (= window-system-version 10)
        !            38:     (setq command-switch-alist
        !            39:          (append '(("-r" . x-handle-switch)
        !            40:                    ("-i" . x-handle-switch)
        !            41:                    ("-font" . x-handle-switch)
        !            42:                    ("-w" . x-handle-switch)
        !            43:                    ("-b" . x-handle-switch)
        !            44:                    ("-ib" . x-handle-switch)
        !            45:                    ("-fg" . x-handle-switch)
        !            46:                    ("-bg" . x-handle-switch)
        !            47:                    ("-bd" . x-handle-switch)
        !            48:                    ("-cr" . x-handle-switch)
        !            49:                    ("-ms" . x-handle-switch))
        !            50:                  command-switch-alist))
        !            51:   (setq command-switch-alist
        !            52:        (append '(("-rn" . x-ignore-arg)
        !            53:                  ("-r" . ignore)
        !            54:                  ("-i" . ignore)
        !            55:                  ("-rn" . x-ignore-arg)
        !            56:                  ("-font" . x-ignore-arg)
        !            57:                  ("-fn" . x-ignore-arg)
        !            58:                  ("-wn" . x-ignore-arg)
        !            59:                  ("-in" . x-ignore-arg)
        !            60:                  ("-w" . x-ignore-arg)
        !            61:                  ("-geometry" . x-ignore-arg)
        !            62:                  ("-b" . x-ignore-arg)
        !            63:                  ("-ib" . x-ignore-arg)
        !            64:                  ("-fg" . x-ignore-arg)
        !            65:                  ("-bg" . x-ignore-arg)
        !            66:                  ("-bd" . x-ignore-arg)
        !            67:                  ("-cr" . x-ignore-arg)
        !            68:                  ("-ms" . x-ignore-arg))
        !            69:                command-switch-alist)))
        !            70: 
        !            71: (defun x-ignore-arg (&rest ignore)
        !            72:   (setq command-line-args-left (cdr command-line-args-left)))
        !            73: 
        !            74: ;; This is run after the command args are parsed.
        !            75: (defun x-handle-switch (switch)
        !            76:   (if (x-handle-switch-1 switch (car command-line-args-left))
        !            77:       (setq command-line-args-left (cdr command-line-args-left))))
        !            78: 
        !            79: (defun x-handle-switch-1 (switch arg)
        !            80:   (cond ((string= switch "-r")
        !            81:         (x-flip-color)
        !            82:         nil)
        !            83:        ((string= switch "-i")
        !            84:         (x-set-icon t)
        !            85:         nil)
        !            86:        ((string= switch "-font")
        !            87:         (x-set-font arg)
        !            88:         t)
        !            89:        ((string= switch "-b")
        !            90:         (x-set-border-width (string-to-int arg))
        !            91:         t)
        !            92:        ((string= switch "-ib")
        !            93:         (x-set-internal-border-width (string-to-int arg))
        !            94:         t)
        !            95:        ((string= switch "-w")
        !            96:         (x-create-x-window arg)
        !            97:         t)
        !            98:        ((string= switch "-fg")
        !            99:         (x-set-foreground-color arg)
        !           100:         t)
        !           101:        ((string= switch "-bg")
        !           102:         (x-set-background-color arg)
        !           103:         t)
        !           104:        ((string= switch "-bd")
        !           105:         (x-set-border-color arg)
        !           106:         t)
        !           107:        ((string= switch "-cr")
        !           108:         (x-set-cursor-color arg)
        !           109:         t)
        !           110:        ((string= switch "-ms")
        !           111:         (x-set-mouse-color arg)
        !           112:         t)))
        !           113: 
        !           114: ;; Convert a string of the form "WWxHH+XO+YO",
        !           115: ;; where WW, HH, XO and YO are numerals,
        !           116: ;; into a list (WW HH XO YO).
        !           117: ;; "xHH" may be omitted; then 0 is used for HH.
        !           118: ;; XO and YO may be preceded by - instead of + to make them negative.
        !           119: ;; Either YO or both XO and YO may be omitted; zero is used.
        !           120: (defun x-parse-edge-spec (arg)
        !           121:   (let ((cols-by-font 0)
        !           122:        (rows-by-font 0)
        !           123:        (xoffset 0)
        !           124:        (yoffset 0))
        !           125:     (if (string-match "^=" arg)
        !           126:        (setq cols-by-font (x-extract-number))
        !           127:       (error "Invalid X window size/position spec"))
        !           128:     (if (string-match "^x" arg)                ;get rows-by-font
        !           129:        (setq rows-by-font (x-extract-number)))
        !           130:     (if (string-match "^[-+]" arg)
        !           131:        (setq xoffset (x-extract-number)))
        !           132:     (if (string-match "^[-+]" arg)
        !           133:        (setq yoffset (x-extract-number)))
        !           134:     (or (equal arg "")
        !           135:        (error "Invalid X window size/position spec"))
        !           136:     (list cols-by-font rows-by-font xoffset yoffset)))
        !           137: 
        !           138: ;; Subroutine to extract the next numeral from the front of arg,
        !           139: ;; returning it and shortening arg to remove its text.
        !           140: ;; If arg is negative, subtract 1 before returning it.
        !           141: (defun x-extract-number ()
        !           142:   (if (string-match "^[x=]" arg)
        !           143:       (setq arg (substring arg 1)))
        !           144:   (or (string-match "[-+]?[0-9]+" arg)
        !           145:       (error "Invalid X window size/position spec"))
        !           146:   (prog1
        !           147:       (+ (string-to-int arg)
        !           148:         (if (string-match "^-" arg) -1 0))
        !           149:     (setq arg
        !           150:          (substring arg
        !           151:                     (or (string-match "[^0-9]" arg 1)
        !           152:                         (length arg))))))
        !           153: 
        !           154: (defun x-get-default-args ()
        !           155:   (setq x-processed-defaults t)
        !           156:   (let (value)
        !           157:     (if (not (string= (setq value (x-get-default "bodyfont")) ""))
        !           158:        (x-handle-switch-1 "-font"  value))
        !           159:     (if (string-match "on" (x-get-default "bitmapicon"))
        !           160:        (x-handle-switch-1 "-i" t))
        !           161:     (if (not (string= (setq value (x-get-default "borderwidth")) ""))
        !           162:        (x-handle-switch-1 "-b" value))
        !           163:     (if (not (string= (setq value (x-get-default "internalborder")) ""))
        !           164:        (x-handle-switch-1 "-ib" value))
        !           165:     (if (not (string= (setq value (x-get-default "foreground")) ""))
        !           166:        (x-handle-switch-1 "-fg" value))
        !           167:     (if (not (string= (setq value (x-get-default "background")) ""))
        !           168:        (x-handle-switch-1 "-bg" value))
        !           169:     (if (not (string= (setq value (x-get-default "border")) ""))
        !           170:        (x-handle-switch-1 "-bd" value))
        !           171:     (if (not (string= (setq value (x-get-default "cursor")) ""))
        !           172:        (x-handle-switch-1 "-cr" value))
        !           173:     (if (not (string= (setq value (x-get-default "mouse")) ""))
        !           174:        (x-handle-switch-1 "-ms" value))
        !           175:     (if (string-match "on" (x-get-default "reversevideo"))
        !           176:        (x-handle-switch-1 "-r" t))))
        !           177: 
        !           178: (defun x-new-display (display)
        !           179:   "This function takes one argument, the display where you wish to
        !           180: continue your editing session.  Your current window will be unmapped and
        !           181: the current display will be closed.  The new X display will be opened and
        !           182: the rubber-band outline of the new window will appear on the new X display."
        !           183:   (interactive "sDisplay to switch emacs to:  ")
        !           184:   (x-change-display display)
        !           185:   (x-get-default-args))
        !           186: 
        !           187: ;; So far we have only defined some functions.
        !           188: ;; Now we start processing X-related switches
        !           189: ;; and redefining commands and variables,
        !           190: ;; only if Emacs has been compiled to support direct interface to X.
        !           191: 
        !           192: (if (eq window-system 'x)
        !           193:     (progn
        !           194:       (require 'x-mouse)
        !           195:       (if (= window-system-version 10)
        !           196:          (progn
        !           197:            ;; xterm.c depends on using interrupt-driven input.
        !           198:            (set-input-mode t nil)
        !           199: 
        !           200:            ;; Not defvar!  This is not DEFINING this variable, just specifying
        !           201:            ;; a value for it.
        !           202:            (setq window-setup-hook 'x-pop-up-window)
        !           203: 
        !           204:            ;; Process switch settings made by .emacs file.
        !           205:            (while x-switches
        !           206:              (x-handle-switch-1 (car (car x-switches)) (cdr (car x-switches)))
        !           207:              (setq x-switches (cdr x-switches)))))
        !           208: 
        !           209:       ;; On certain systems, turn off use of sigio, because it's broken.
        !           210:       (if x-sigio-bug
        !           211:          (set-input-mode nil nil))
        !           212: 
        !           213:       (put 'suspend-emacs 'disabled
        !           214:           "Suspending a program running in an X window is silly
        !           215: and you would not be able to start it again.  Just switch windows instead.\n")
        !           216:       (setq suspend-hook '(lambda () (error "Suspending an emacs running under X makes no sense")))
        !           217:       (substitute-key-definition 'suspend-emacs nil global-map)
        !           218:       (substitute-key-definition 'suspend-emacs nil esc-map)
        !           219:       (substitute-key-definition 'suspend-emacs nil ctl-x-map)
        !           220:       ;; Not needed any more -- done in C.
        !           221:       ;; (if (not x-processed-defaults) (x-get-default-args))
        !           222: ))

unix.superglobalmegacorp.com

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