aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2000-10-28 17:18:59 +0000
committerEli Zaretskii2000-10-28 17:18:59 +0000
commitc381f482acd03d13380e91ddf2942d3c2f7aa3e6 (patch)
treec476cc999f4897abb7475c7dc0501a45e4ea3767
parent42002db50d6b1b9e1549b244f919b56191f33759 (diff)
downloademacs-c381f482acd03d13380e91ddf2942d3c2f7aa3e6.tar.gz
emacs-c381f482acd03d13380e91ddf2942d3c2f7aa3e6.zip
(tty-long-option-alist): New variable.
(tty-handle-args): New function. (command-line): Call tty-handle-args.
-rw-r--r--lisp/startup.el78
1 files changed, 78 insertions, 0 deletions
diff --git a/lisp/startup.el b/lisp/startup.el
index 2d3b8a70d4e..51a6778f834 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -504,6 +504,79 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
504 (setq submap (cdr submap)))) 504 (setq submap (cdr submap))))
505 (setq define-key-rebound-commands t)) 505 (setq define-key-rebound-commands t))
506 506
507;; Command-line options supported by tty's:
508(defconst tty-long-option-alist
509 '(("--name" . "-name")
510 ("--title" . "-T")
511 ("--reverse-video" . "-reverse")
512 ("--foreground-color" . "-fg")
513 ("--background-color" . "-bg")))
514
515;; Handle the X-like command line parameters "-fg", "-bg", "-name", etc.
516(defun tty-handle-args (args)
517 (let ((rest nil))
518 (message "%s" args)
519 (while (and args
520 (not (equal (car args) "--")))
521 (let* ((this (car args))
522 (orig-this this)
523 completion argval)
524 (setq args (cdr args))
525 ;; Check for long options with attached arguments
526 ;; and separate out the attached option argument into argval.
527 (if (string-match "^--[^=]*=" this)
528 (setq argval (substring this (match-end 0))
529 this (substring this 0 (1- (match-end 0)))))
530 (when (string-match "^--" this)
531 (setq completion (try-completion this tty-long-option-alist))
532 (if (eq completion t)
533 ;; Exact match for long option.
534 (setq this (cdr (assoc this tty-long-option-alist)))
535 (if (stringp completion)
536 (let ((elt (assoc completion tty-long-option-alist)))
537 ;; Check for abbreviated long option.
538 (or elt
539 (error "Option `%s' is ambiguous" this))
540 (setq this (cdr elt)))
541 ;; Check for a short option.
542 (setq argval nil this orig-this))))
543 (cond ((or (string= this "-fg") (string= this "-foreground"))
544 (or argval (setq argval (car args) args (cdr args)))
545 (setq default-frame-alist
546 (cons (cons 'foreground-color argval)
547 default-frame-alist)))
548 ((or (string= this "-bg") (string= this "-background"))
549 (or argval (setq argval (car args) args (cdr args)))
550 (setq default-frame-alist
551 (cons (cons 'background-color argval)
552 default-frame-alist)))
553 ((or (string= this "-T") (string= this "-name"))
554 (or argval (setq argval (car args) args (cdr args)))
555 (setq default-frame-alist
556 (cons
557 (cons 'title
558 (if (stringp argval)
559 argval
560 (let ((case-fold-search t)
561 i)
562 (setq argval (invocation-name))
563
564 ;; Change any . or * characters in name to
565 ;; hyphens, so as to emulate behavior on X.
566 (while
567 (setq i (string-match "[.*]" argval))
568 (aset argval i ?-))
569 argval)))
570 default-frame-alist)))
571 ((or (string= this "-r")
572 (string= this "-rv")
573 (string= this "-reverse"))
574 (setq default-frame-alist
575 (cons '(reverse . t)
576 default-frame-alist)))
577 (t (setq rest (cons this rest))))))
578 (nreverse rest)))
579
507(defun command-line () 580(defun command-line ()
508 (setq command-line-default-directory default-directory) 581 (setq command-line-default-directory default-directory)
509 582
@@ -580,6 +653,11 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
580 (setq window-system nil) 653 (setq window-system nil)
581 (kill-emacs))) 654 (kill-emacs)))
582 655
656 ;; Windowed displays do this inside their *-win.el.
657 (when (and (not (display-graphic-p))
658 (not noninteractive))
659 (setq command-line-args (tty-handle-args command-line-args)))
660
583 (let ((done nil) 661 (let ((done nil)
584 (args (cdr command-line-args))) 662 (args (cdr command-line-args)))
585 663