aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorKaroly Lorentey2005-09-10 23:51:08 +0000
committerKaroly Lorentey2005-09-10 23:51:08 +0000
commit92071250fabab9d4daa7c6cf0bd7d7c36f73ea41 (patch)
tree1fdb99d17b67629236ce13a68c0d2eb45121c4c1 /lisp
parent79cf212310d3b1dc039f2f752fd91d54cd03670c (diff)
downloademacs-92071250fabab9d4daa7c6cf0bd7d7c36f73ea41.tar.gz
emacs-92071250fabab9d4daa7c6cf0bd7d7c36f73ea41.zip
Fix `emacsclient -ne '(+ 2 2)'' (reported by Han Boetes), and clean up some corner cases in Emacs server.
* lib-src/emacsclient.c (decode_options): Make --no-wait imply --current-frame, except when it is the only option given. Make sure no frame is opened when --current-frame is set. (main): Pass --current-frame to server.el. * lisp/server.el (server-process-filter): Handle -current-frame command. Don't create frames when it is given. Don't bind X frames to the client when we are in -no-wait mode. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-407
Diffstat (limited to 'lisp')
-rw-r--r--lisp/server.el89
1 files changed, 52 insertions, 37 deletions
diff --git a/lisp/server.el b/lisp/server.el
index 0104e2787fe..27596c317df 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -481,6 +481,9 @@ The following commands are accepted by the server:
481`-env NAME VALUE' 481`-env NAME VALUE'
482 An environment variable on the client side. 482 An environment variable on the client side.
483 483
484`-current-frame'
485 Forbid the creation of new frames.
486
484`-nowait' 487`-nowait'
485 Request that the next frame created should not be 488 Request that the next frame created should not be
486 associated with this client. 489 associated with this client.
@@ -560,6 +563,7 @@ The following commands are accepted by the client:
560 (or file-name-coding-system 563 (or file-name-coding-system
561 default-file-name-coding-system))) 564 default-file-name-coding-system)))
562 (client (server-client proc)) 565 (client (server-client proc))
566 current-frame
563 nowait ; t if emacsclient does not want to wait for us. 567 nowait ; t if emacsclient does not want to wait for us.
564 frame ; The frame that was opened for the client (if any). 568 frame ; The frame that was opened for the client (if any).
565 display ; Open the frame on this display. 569 display ; Open the frame on this display.
@@ -592,6 +596,9 @@ The following commands are accepted by the client:
592 ;; -nowait: Emacsclient won't wait for a result. 596 ;; -nowait: Emacsclient won't wait for a result.
593 ((equal "-nowait" arg) (setq nowait t)) 597 ((equal "-nowait" arg) (setq nowait t))
594 598
599 ;; -current-frame: Don't create frames.
600 ((equal "-current-frame" arg) (setq current-frame t))
601
595 ;; -display DISPLAY: 602 ;; -display DISPLAY:
596 ;; Open X frames on the given instead of the default. 603 ;; Open X frames on the given instead of the default.
597 ((and (equal "-display" arg) (string-match "\\([^ ]*\\) " request)) 604 ((and (equal "-display" arg) (string-match "\\([^ ]*\\) " request))
@@ -602,26 +609,31 @@ The following commands are accepted by the client:
602 ((equal "-window-system" arg) 609 ((equal "-window-system" arg)
603 (unless (server-client-get client 'version) 610 (unless (server-client-get client 'version)
604 (error "Protocol error; make sure to use the correct version of emacsclient")) 611 (error "Protocol error; make sure to use the correct version of emacsclient"))
605 (if (fboundp 'x-create-frame) 612 (unless current-frame
606 (progn 613 (if (fboundp 'x-create-frame)
607 (setq frame (make-frame-on-display 614 (let ((params (if nowait
608 (or display 615 nil
609 (frame-parameter nil 'device) 616 (list (cons 'client proc)))))
610 (getenv "DISPLAY") 617 (setq frame (make-frame-on-display
611 (error "Please specify display")) 618 (or display
612 (list (cons 'client proc)))) 619 (frame-parameter nil 'device)
613 ;; XXX We need to ensure the client parameter is 620 (getenv "DISPLAY")
614 ;; really set because Emacs forgets initialization 621 (error "Please specify display"))
615 ;; parameters for X frames at the moment. 622 params))
616 (modify-frame-parameters frame (list (cons 'client proc))) 623 (server-log (format "%s created" frame) proc)
617 (select-frame frame) 624 ;; XXX We need to ensure the parameters are
618 (server-client-set client 'frame frame) 625 ;; really set because Emacs forgets unhandled
619 (server-client-set client 'device (frame-display frame)) 626 ;; initialization parameters for X frames at
620 (setq dontkill t)) 627 ;; the moment.
621 ;; This emacs does not support X. 628 (modify-frame-parameters frame params)
622 (server-log "Window system unsupported" proc) 629 (select-frame frame)
623 (server-send-string proc "-window-system-unsupported \n") 630 (server-client-set client 'frame frame)
624 (setq dontkill t))) 631 (server-client-set client 'device (frame-display frame))
632 (setq dontkill t))
633 ;; This emacs does not support X.
634 (server-log "Window system unsupported" proc)
635 (server-send-string proc "-window-system-unsupported \n")
636 (setq dontkill t))))
625 637
626 ;; -resume: Resume a suspended tty frame. 638 ;; -resume: Resume a suspended tty frame.
627 ((equal "-resume" arg) 639 ((equal "-resume" arg)
@@ -652,23 +664,26 @@ The following commands are accepted by the client:
652 (setq request (substring request (match-end 0))) 664 (setq request (substring request (match-end 0)))
653 (unless (server-client-get client 'version) 665 (unless (server-client-get client 'version)
654 (error "Protocol error; make sure you use the correct version of emacsclient")) 666 (error "Protocol error; make sure you use the correct version of emacsclient"))
655 (server-with-client-environment proc 667 (unless current-frame
656 ("LANG" "LC_CTYPE" "LC_ALL" 668 (server-with-client-environment proc
657 ;; For tgetent(3); list according to ncurses(3). 669 ("LANG" "LC_CTYPE" "LC_ALL"
658 "BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES" 670 ;; For tgetent(3); list according to ncurses(3).
659 "NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING" 671 "BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES"
660 "NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO" 672 "NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING"
661 "TERMINFO_DIRS" "TERMPATH") 673 "NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO"
662 (setq frame (make-frame-on-tty tty type 674 "TERMINFO_DIRS" "TERMPATH")
663 `((client . ,proc))))) 675 (setq frame (make-frame-on-tty tty type
664 (select-frame frame) 676 ;; Ignore nowait here; we always need to clean
665 (server-client-set client 'frame frame) 677 ;; up opened ttys when the client dies.
666 (server-client-set client 'tty (display-name frame)) 678 `((client . ,proc)))))
667 (server-client-set client 'device (frame-display frame)) 679 (select-frame frame)
668 680 (server-client-set client 'frame frame)
669 ;; Reply with our pid. 681 (server-client-set client 'tty (display-name frame))
670 (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n")) 682 (server-client-set client 'device (frame-display frame))
671 (setq dontkill t))) 683
684 ;; Reply with our pid.
685 (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n"))
686 (setq dontkill t))))
672 687
673 ;; -position LINE: Go to the given line in the next file. 688 ;; -position LINE: Go to the given line in the next file.
674 ((and (equal "-position" arg) (string-match "\\(\\+[0-9]+\\) " request)) 689 ((and (equal "-position" arg) (string-match "\\(\\+[0-9]+\\) " request))