Mercurial > emacs
changeset 83367:2b5fb28780be
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
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sat, 10 Sep 2005 23:51:08 +0000 |
parents | 5a8e49e5b281 |
children | 0d0962d43546 |
files | README.multi-tty lib-src/emacsclient.c lisp/server.el |
diffstat | 3 files changed, 76 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/README.multi-tty Sat Sep 10 23:00:15 2005 +0000 +++ b/README.multi-tty Sat Sep 10 23:51:08 2005 +0000 @@ -386,11 +386,6 @@ THINGS TO DO ------------ -** cus-start.el has some suspicious uses of window-system, introduced - in patch-404. - -** emacsclient --no-wait and --eval is currently broken. - ** xt-mouse.el needs to be adapted for multi-tty. It currently signals an error on kill-emacs under X, which prevents the user from exiting Emacs. (Reported by Mnemonikk on freenode.)
--- a/lib-src/emacsclient.c Sat Sep 10 23:00:15 2005 +0000 +++ b/lib-src/emacsclient.c Sat Sep 10 23:51:08 2005 +0000 @@ -67,6 +67,9 @@ /* Nonzero means args are expressions to be evaluated. --eval. */ int eval = 0; +/* Nonzero means don't open a new frame. --current-frame. */ +int current_frame = 0; + /* Nonzero means open a new graphical frame. */ int window_system = 0; @@ -112,11 +115,6 @@ if (display && strlen (display) == 0) display = NULL; - if (display) - window_system = 1; - else - tty = 1; - while (1) { int opt = getopt_long (argc, argv, @@ -159,12 +157,10 @@ case 't': tty = 1; - window_system = 0; break; case 'c': - window_system = 0; - tty = 0; + current_frame = 1; break; case 'H': @@ -178,10 +174,24 @@ } } - if (tty) { - nowait = 0; - display = 0; - } + if (!tty && display) + window_system = 1; + else + tty = 1; + + /* `emacsclient --no-wait' should open a new permanent frame, then exit. + Otherwise, --no-wait always implies --current-frame. */ + if (nowait && argc - optind > 0) + current_frame = 1; + + if (current_frame) + { + tty = 0; + window_system = 0; + } + + if (tty) + window_system = 0; } void @@ -710,6 +720,9 @@ if (nowait) fprintf (out, "-nowait "); + if (current_frame) + fprintf (out, "-current-frame "); + if (display) { fprintf (out, "-display ");
--- a/lisp/server.el Sat Sep 10 23:00:15 2005 +0000 +++ b/lisp/server.el Sat Sep 10 23:51:08 2005 +0000 @@ -481,6 +481,9 @@ `-env NAME VALUE' An environment variable on the client side. +`-current-frame' + Forbid the creation of new frames. + `-nowait' Request that the next frame created should not be associated with this client. @@ -560,6 +563,7 @@ (or file-name-coding-system default-file-name-coding-system))) (client (server-client proc)) + current-frame nowait ; t if emacsclient does not want to wait for us. frame ; The frame that was opened for the client (if any). display ; Open the frame on this display. @@ -592,6 +596,9 @@ ;; -nowait: Emacsclient won't wait for a result. ((equal "-nowait" arg) (setq nowait t)) + ;; -current-frame: Don't create frames. + ((equal "-current-frame" arg) (setq current-frame t)) + ;; -display DISPLAY: ;; Open X frames on the given instead of the default. ((and (equal "-display" arg) (string-match "\\([^ ]*\\) " request)) @@ -602,26 +609,31 @@ ((equal "-window-system" arg) (unless (server-client-get client 'version) (error "Protocol error; make sure to use the correct version of emacsclient")) - (if (fboundp 'x-create-frame) - (progn - (setq frame (make-frame-on-display - (or display - (frame-parameter nil 'device) - (getenv "DISPLAY") - (error "Please specify display")) - (list (cons 'client proc)))) - ;; XXX We need to ensure the client parameter is - ;; really set because Emacs forgets initialization - ;; parameters for X frames at the moment. - (modify-frame-parameters frame (list (cons 'client proc))) - (select-frame frame) - (server-client-set client 'frame frame) - (server-client-set client 'device (frame-display frame)) - (setq dontkill t)) - ;; This emacs does not support X. - (server-log "Window system unsupported" proc) - (server-send-string proc "-window-system-unsupported \n") - (setq dontkill t))) + (unless current-frame + (if (fboundp 'x-create-frame) + (let ((params (if nowait + nil + (list (cons 'client proc))))) + (setq frame (make-frame-on-display + (or display + (frame-parameter nil 'device) + (getenv "DISPLAY") + (error "Please specify display")) + params)) + (server-log (format "%s created" frame) proc) + ;; XXX We need to ensure the parameters are + ;; really set because Emacs forgets unhandled + ;; initialization parameters for X frames at + ;; the moment. + (modify-frame-parameters frame params) + (select-frame frame) + (server-client-set client 'frame frame) + (server-client-set client 'device (frame-display frame)) + (setq dontkill t)) + ;; This emacs does not support X. + (server-log "Window system unsupported" proc) + (server-send-string proc "-window-system-unsupported \n") + (setq dontkill t)))) ;; -resume: Resume a suspended tty frame. ((equal "-resume" arg) @@ -652,23 +664,26 @@ (setq request (substring request (match-end 0))) (unless (server-client-get client 'version) (error "Protocol error; make sure you use the correct version of emacsclient")) - (server-with-client-environment proc - ("LANG" "LC_CTYPE" "LC_ALL" - ;; For tgetent(3); list according to ncurses(3). - "BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES" - "NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING" - "NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO" - "TERMINFO_DIRS" "TERMPATH") - (setq frame (make-frame-on-tty tty type - `((client . ,proc))))) - (select-frame frame) - (server-client-set client 'frame frame) - (server-client-set client 'tty (display-name frame)) - (server-client-set client 'device (frame-display frame)) + (unless current-frame + (server-with-client-environment proc + ("LANG" "LC_CTYPE" "LC_ALL" + ;; For tgetent(3); list according to ncurses(3). + "BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES" + "NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING" + "NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO" + "TERMINFO_DIRS" "TERMPATH") + (setq frame (make-frame-on-tty tty type + ;; Ignore nowait here; we always need to clean + ;; up opened ttys when the client dies. + `((client . ,proc))))) + (select-frame frame) + (server-client-set client 'frame frame) + (server-client-set client 'tty (display-name frame)) + (server-client-set client 'device (frame-display frame)) - ;; Reply with our pid. - (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n")) - (setq dontkill t))) + ;; Reply with our pid. + (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n")) + (setq dontkill t)))) ;; -position LINE: Go to the given line in the next file. ((and (equal "-position" arg) (string-match "\\(\\+[0-9]+\\) " request))