comparison lisp/server.el @ 83499:0fe580113f72

Set `default-directory' in *scratch* to the current directory of emacsclient. * lib-src/emacsclient.c (get_current_dir_name): New function, copied here from sysdep.c. (main): Use it to send over the current directory. * lisp/server.el (server-process-filter): Accept `-dir' command. Set `default-directory' of the *scratch* buffer on connect, if applicable. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-539
author Karoly Lorentey <lorentey@elte.hu>
date Sun, 26 Mar 2006 16:34:35 +0000
parents 3a9507e5aa39
children 1321f6cfb389
comparison
equal deleted inserted replaced
83498:f0987e2f27e2 83499:0fe580113f72
491 `-good-version' to confirm the match. 491 `-good-version' to confirm the match.
492 492
493 `-env NAME=VALUE' 493 `-env NAME=VALUE'
494 An environment variable on the client side. 494 An environment variable on the client side.
495 495
496 `-dir DIRNAME'
497 The current working directory of the client process.
498
496 `-current-frame' 499 `-current-frame'
497 Forbid the creation of new frames. 500 Forbid the creation of new frames.
498 501
499 `-nowait' 502 `-nowait'
500 Request that the next frame created should not be 503 Request that the next frame created should not be
517 `-window-system' 520 `-window-system'
518 Open a new X frame. 521 Open a new X frame.
519 522
520 `-tty DEVICENAME TYPE' 523 `-tty DEVICENAME TYPE'
521 Open a new tty frame at the client. 524 Open a new tty frame at the client.
525
526 `-suspend'
527 Suspend this tty frame. The client sends this string in
528 response to SIGTSTP and SIGTTOU. The server must cease all I/O
529 on this tty until it gets a -resume command.
522 530
523 `-resume' 531 `-resume'
524 Resume this tty frame. The client sends this string when it 532 Resume this tty frame. The client sends this string when it
525 gets the SIGCONT signal and it is the foreground process on its 533 gets the SIGCONT signal and it is the foreground process on its
526 controlling tty. 534 controlling tty.
527
528 `-suspend'
529 Suspend this tty frame. The client sends this string in
530 response to SIGTSTP and SIGTTOU. The server must cease all I/O
531 on this tty until it gets a -resume command.
532 535
533 `-ignore COMMENT' 536 `-ignore COMMENT'
534 Do nothing, but put the comment in the server 537 Do nothing, but put the comment in the server
535 log. Useful for debugging. 538 log. Useful for debugging.
536 539
579 nowait ; t if emacsclient does not want to wait for us. 582 nowait ; t if emacsclient does not want to wait for us.
580 frame ; The frame that was opened for the client (if any). 583 frame ; The frame that was opened for the client (if any).
581 display ; Open the frame on this display. 584 display ; Open the frame on this display.
582 dontkill ; t if the client should not be killed. 585 dontkill ; t if the client should not be killed.
583 env 586 env
587 dir
584 (files nil) 588 (files nil)
585 (lineno 1) 589 (lineno 1)
586 (columnno 0)) 590 (columnno 0))
587 ;; Remove this line from STRING. 591 ;; Remove this line from STRING.
588 (setq string (substring string (match-end 0))) 592 (setq string (substring string (match-end 0)))
648 (server-client-set client 'frame frame) 652 (server-client-set client 'frame frame)
649 (server-client-set client 'terminal (frame-terminal frame)) 653 (server-client-set client 'terminal (frame-terminal frame))
650 654
651 ;; Display *scratch* by default. 655 ;; Display *scratch* by default.
652 (switch-to-buffer (get-buffer-create "*scratch*") 'norecord) 656 (switch-to-buffer (get-buffer-create "*scratch*") 'norecord)
657 (if dir (setq default-directory dir))
653 658
654 (setq dontkill t)) 659 (setq dontkill t))
655 ;; This emacs does not support X. 660 ;; This emacs does not support X.
656 (server-log "Window system unsupported" proc) 661 (server-log "Window system unsupported" proc)
657 (server-send-string proc "-window-system-unsupported \n") 662 (server-send-string proc "-window-system-unsupported \n")
704 (server-client-set client 'tty (terminal-name frame)) 709 (server-client-set client 'tty (terminal-name frame))
705 (server-client-set client 'terminal (frame-terminal frame)) 710 (server-client-set client 'terminal (frame-terminal frame))
706 711
707 ;; Display *scratch* by default. 712 ;; Display *scratch* by default.
708 (switch-to-buffer (get-buffer-create "*scratch*") 'norecord) 713 (switch-to-buffer (get-buffer-create "*scratch*") 'norecord)
714 (if dir (setq default-directory dir))
709 715
710 ;; Reply with our pid. 716 ;; Reply with our pid.
711 (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n")) 717 (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n"))
712 (setq dontkill t)))) 718 (setq dontkill t))))
713 719
757 ((and (equal "-env" arg) (string-match "\\([^ ]+\\) " request)) 763 ((and (equal "-env" arg) (string-match "\\([^ ]+\\) " request))
758 (let ((var (server-unquote-arg (match-string 1 request)))) 764 (let ((var (server-unquote-arg (match-string 1 request))))
759 ;; XXX Variables should be encoded as in getenv/setenv. 765 ;; XXX Variables should be encoded as in getenv/setenv.
760 (setq request (substring request (match-end 0))) 766 (setq request (substring request (match-end 0)))
761 (setq env (cons var env)))) 767 (setq env (cons var env))))
768
769 ;; -dir DIRNAME: The cwd of the emacsclient process.
770 ((and (equal "-dir" arg) (string-match "\\([^ ]+\\) " request))
771 (setq dir (server-unquote-arg (match-string 1 request)))
772 (setq request (substring request (match-end 0)))
773 (if coding-system
774 (setq dir (decode-coding-string dir coding-system)))
775 (setq dir (command-line-normalize-file-name dir)))
762 776
763 ;; Unknown command. 777 ;; Unknown command.
764 (t (error "Unknown command: %s" arg))))) 778 (t (error "Unknown command: %s" arg)))))
765 779
766 (let (buffers) 780 (let (buffers)