comparison lisp/frame.el @ 83403:51eb0aa362f3

Store client's environment in terminal parameters, not server parameters. * lisp/loadup.el: Don't load server. * lisp/ldefs-boot.el: Update. * lib-src/emacsclient.c (main): Send environment only when a new display is created. * lisp/server.el (server-save-buffers-kill-display): Add autoload cookie. Move stuff not specific to server into `save-buffers-kill-display'. * lisp/files.el (save-buffers-kill-display): New function. (ctl-x-map): Bind it to C-x C-c. * lisp/frame.el (terminal-getenv): New function. * lisp/international/mule-cmds.el (set-locale-environment): Use it. * lisp/frame.el (with-terminal-environment): New macro. * lisp/server.el (server-getenv, server-with-client-environment): Remove. (server-getenv-from, server-with-environment): New functions. (server-process-filter): Change syntax of environment variables. Put environment into terminal parameters, not client parameters. * lisp/term/rxvt.el: Don't require server. (rxvt-set-background-mode): Use terminal-getenv, not server-getenv. * lisp/term/x-win.el (x-initialize-window-system): Ditto. * lisp/term/xterm.el (terminal-init-xterm): Ditto. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-443
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 19 Nov 2005 19:17:56 +0000
parents 201f610eb492
children 37d0562504bf
comparison
equal deleted inserted replaced
83402:606eab743857 83403:51eb0aa362f3
1509 (setq terminal-parameter-alist 1509 (setq terminal-parameter-alist
1510 (assq-delete-all (frame-display frame) terminal-parameter-alist)))) 1510 (assq-delete-all (frame-display frame) terminal-parameter-alist))))
1511 1511
1512 (add-hook 'delete-frame-functions 'terminal-handle-delete-frame) 1512 (add-hook 'delete-frame-functions 'terminal-handle-delete-frame)
1513 1513
1514 (defun terminal-getenv (variable &optional terminal)
1515 "Get the value of VARIABLE in the client environment of TERMINAL.
1516 VARIABLE should be a string. Value is nil if VARIABLE is undefined in
1517 the environment. Otherwise, value is a string.
1518
1519 If TERMINAL was created by an emacsclient invocation, then the
1520 variable is looked up in the environment of the emacsclient
1521 process; otherwise the function consults the environment of the
1522 Emacs process.
1523
1524 TERMINAL can be a terminal id, a frame, or nil (meaning the
1525 selected frame's terminal)."
1526 (setq terminal (terminal-id terminal))
1527 (if (not (terminal-parameter-p terminal 'environment))
1528 (getenv variable)
1529 (let ((env (terminal-parameter terminal 'environment))
1530 result entry)
1531 (while (and env (null result))
1532 (setq entry (car env)
1533 env (cdr env))
1534 (if (and (> (length entry) (length variable))
1535 (eq ?= (aref entry (length variable)))
1536 (equal variable (substring entry 0 (length variable))))
1537 (setq result (substring entry (+ (length variable) 1)))))
1538 (if (null result)
1539 (getenv variable)
1540 result))))
1541
1542 (defmacro with-terminal-environment (terminal vars &rest body)
1543 "Evaluate BODY with environment variables VARS set to those of TERMINAL.
1544 The environment variables are then restored to their previous values.
1545
1546 VARS should be a list of strings.
1547
1548 TERMINAL can be a terminal id, a frame, or nil (meaning the
1549 selected frame's terminal).
1550
1551 See also `terminal-getenv'."
1552 (declare (indent 2))
1553 (let ((oldvalues (make-symbol "oldvalues"))
1554 (var (make-symbol "var"))
1555 (value (make-symbol "value"))
1556 (pair (make-symbol "pair")))
1557 `(let (,oldvalues)
1558 (dolist (,var ,vars)
1559 (let ((,value (terminal-getenv ,var ,terminal)))
1560 (setq ,oldvalues (cons (cons ,var (getenv ,var)) ,oldvalues))
1561 (setenv ,var ,value)))
1562 (unwind-protect
1563 (progn ,@body)
1564 (dolist (,pair ,oldvalues)
1565 (setenv (car ,pair) (cdr ,pair)))))))
1566
1567
1514 (provide 'frame) 1568 (provide 'frame)
1515 1569
1516 ;; arch-tag: 82979c70-b8f2-4306-b2ad-ddbd6b328b56 1570 ;; arch-tag: 82979c70-b8f2-4306-b2ad-ddbd6b328b56
1517 ;;; frame.el ends here 1571 ;;; frame.el ends here