aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaroly Lorentey2005-09-10 23:51:08 +0000
committerKaroly Lorentey2005-09-10 23:51:08 +0000
commit92071250fabab9d4daa7c6cf0bd7d7c36f73ea41 (patch)
tree1fdb99d17b67629236ce13a68c0d2eb45121c4c1
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
-rw-r--r--README.multi-tty5
-rw-r--r--lib-src/emacsclient.c37
-rw-r--r--lisp/server.el89
3 files changed, 77 insertions, 54 deletions
diff --git a/README.multi-tty b/README.multi-tty
index 93fb58b4119..e6dde3bfd98 100644
--- a/README.multi-tty
+++ b/README.multi-tty
@@ -386,11 +386,6 @@ is probably not very interesting for anyone else.)
386THINGS TO DO 386THINGS TO DO
387------------ 387------------
388 388
389** cus-start.el has some suspicious uses of window-system, introduced
390 in patch-404.
391
392** emacsclient --no-wait and --eval is currently broken.
393
394** xt-mouse.el needs to be adapted for multi-tty. It currently 389** xt-mouse.el needs to be adapted for multi-tty. It currently
395 signals an error on kill-emacs under X, which prevents the user 390 signals an error on kill-emacs under X, which prevents the user
396 from exiting Emacs. (Reported by Mnemonikk on freenode.) 391 from exiting Emacs. (Reported by Mnemonikk on freenode.)
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 4908d49441b..ecd0d18ce85 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -67,6 +67,9 @@ int nowait = 0;
67/* Nonzero means args are expressions to be evaluated. --eval. */ 67/* Nonzero means args are expressions to be evaluated. --eval. */
68int eval = 0; 68int eval = 0;
69 69
70/* Nonzero means don't open a new frame. --current-frame. */
71int current_frame = 0;
72
70/* Nonzero means open a new graphical frame. */ 73/* Nonzero means open a new graphical frame. */
71int window_system = 0; 74int window_system = 0;
72 75
@@ -112,11 +115,6 @@ decode_options (argc, argv)
112 if (display && strlen (display) == 0) 115 if (display && strlen (display) == 0)
113 display = NULL; 116 display = NULL;
114 117
115 if (display)
116 window_system = 1;
117 else
118 tty = 1;
119
120 while (1) 118 while (1)
121 { 119 {
122 int opt = getopt_long (argc, argv, 120 int opt = getopt_long (argc, argv,
@@ -159,12 +157,10 @@ decode_options (argc, argv)
159 157
160 case 't': 158 case 't':
161 tty = 1; 159 tty = 1;
162 window_system = 0;
163 break; 160 break;
164 161
165 case 'c': 162 case 'c':
166 window_system = 0; 163 current_frame = 1;
167 tty = 0;
168 break; 164 break;
169 165
170 case 'H': 166 case 'H':
@@ -178,10 +174,24 @@ decode_options (argc, argv)
178 } 174 }
179 } 175 }
180 176
181 if (tty) { 177 if (!tty && display)
182 nowait = 0; 178 window_system = 1;
183 display = 0; 179 else
184 } 180 tty = 1;
181
182 /* `emacsclient --no-wait' should open a new permanent frame, then exit.
183 Otherwise, --no-wait always implies --current-frame. */
184 if (nowait && argc - optind > 0)
185 current_frame = 1;
186
187 if (current_frame)
188 {
189 tty = 0;
190 window_system = 0;
191 }
192
193 if (tty)
194 window_system = 0;
185} 195}
186 196
187void 197void
@@ -710,6 +720,9 @@ To start the server in Emacs, type \"M-x server-start\".\n",
710 if (nowait) 720 if (nowait)
711 fprintf (out, "-nowait "); 721 fprintf (out, "-nowait ");
712 722
723 if (current_frame)
724 fprintf (out, "-current-frame ");
725
713 if (display) 726 if (display)
714 { 727 {
715 fprintf (out, "-display "); 728 fprintf (out, "-display ");
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))