Mercurial > emacs
annotate lisp/eshell/em-basic.el @ 83167:69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
* lisp/frame.el (make-frame-on-display): Update doc.
(make-frame): Handle display-id parameter. Update doc.
(frames-on-display-list): Update for display ids.
(framep-on-display): Ditto.
(suspend-frame): Use display-name, not frame-tty-name.
(selected-display): New function.
* lisp/server.el (server-delete-client): Use delete-display, not delete-tty.
(server-tty-live-p, server-handle-delete-tty): Removed.
(server-handle-delete-frame): Delete tty clients, if needed.
(server-process-filter): Set the display parameter, and use it when appropriate.
(server-handle-suspend-tty): Use the display parameter.
(server-start, server-unload-hook): Removed obsolete delete-tty hook.
* lisp/talk.el (talk): Always use talk-add-display.
(talk-add-tty-frame, talk-handle-delete-tty): Removed.
(talk-handle-delete-frame): New function.
(talk-add-display): Open a new frame only if parameter was not a frame.
* src/dispextern.h (get_display, Fdisplay_tty_type): New prototypes.
(Fframe_tty_type): Removed.
* src/dispnew.c (init_display): Use Fdisplay_tty_type, not Fframe_tty_type.
* src/frame.c (Qdisplay_id, Qdisplay_live_p): New symbols.
(make_terminal_frame): Get display as a parameter.
(Fmake_terminal_frame): Get/create display here; pass it to
make_terminal_frame.
(Fframe_display): New function.
(Fdelete_frame): Stop if the hook deleted the frame.
(syms_of_frame): Register new stuff.
* src/frame.h (Qdisplay_id, Qdisplay_live_p, make_terminal_frame):
Updated prototypes.
* src/keyboard.c (interrupt_signal): Updated comment.
* src/term.c (Vdelete_tty_after_functions): Removed variable.
(Qframe_tty_name, Qframe_tty_type): Removed.
(next_display_id): New var.
(tty_ring_bell): Don't do anything on suspended frames.
(Ftty_display_color_p, Ftty_display_color_cells): Doc update.
(get_display): New function.
(get_tty_display): Use it.
(get_named_tty_display): Ignore suspended displays.
(Fframe_tty_name): Renamed to Fdisplay_name. Handle all kinds of
displays.
(Fframe_tty_type): Renamed to Fdisplay_tty_type.
(init_initial_display): Set display name.
(term_init): Allow more displays on the same device. Set display name.
(Fdelete_tty): Removed.
(delete_tty): Don't run hooks.
(create_display): Set display id.
(delete_display): Free display name.
(Fdelete_display, Fdisplay_live_p, Fdisplay_list): New functions.
(Fsuspend_tty): Call hook with display id. Doc update.
(Fresume_tty): Refuse to resume when there is already an active display
on the same device. Call hook with display id. Doc update.
(syms_of_term): Reflect above changes.
* src/termhooks.h (struct display): Added `id' and `name' members.
(DISPLAY_ACTIVE_P): New macro.
* src/xfns.c (check_x_display_info): Handle display ids.
(Fx_create_frame): Try to get display from `display-id' parameter.
* src/xterm.c (x_term_init): Set display name.
(x_delete_display): Handle the case when `font_table' is NULL.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-207
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 04 Jul 2004 04:48:55 +0000 |
parents | 695cf19ef79e |
children | 18a818a2ee7c 375f2633d815 |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32526
diff
changeset
|
1 ;;; em-basic.el --- basic shell builtin commands |
29876 | 2 |
29934
34b1ab9d583d
Change spelling of the Free Software Foundation.
Gerd Moellmann <gerd@gnu.org>
parents:
29876
diff
changeset
|
3 ;; Copyright (C) 1999, 2000 Free Software Foundation |
29876 | 4 |
32526 | 5 ;; Author: John Wiegley <johnw@gnu.org> |
6 | |
29876 | 7 ;; This file is part of GNU Emacs. |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 (provide 'em-basic) | |
25 | |
26 (eval-when-compile (require 'esh-maint)) | |
27 | |
28 (defgroup eshell-basic nil | |
29 "The \"basic\" code provides a set of convenience functions which | |
30 are traditionally considered shell builtins. Since all of the | |
31 functionality provided by them is accessible through Lisp, they are | |
32 not really builtins at all, but offer a command-oriented way to do the | |
33 same thing." | |
34 :tag "Basic shell commands" | |
35 :group 'eshell-module) | |
36 | |
37 ;;; Commentary: | |
38 | |
39 ;; There are very few basic Eshell commands -- so-called builtins. | |
40 ;; They are: echo, umask, and version. | |
41 ;; | |
42 ;;;_* `echo' | |
43 ;; | |
44 ;; The `echo' command repeats its arguments to the screen. It is | |
45 ;; optional whether this is done in a Lisp-friendly fashion (so that | |
46 ;; the value of echo is useful to a Lisp command using the result of | |
47 ;; echo as an argument), or whether it should try to act like a normal | |
48 ;; shell echo, and always result in a flat string being returned. | |
49 | |
50 (defcustom eshell-plain-echo-behavior nil | |
51 "*If non-nil, `echo' tries to behave like an ordinary shell echo. | |
52 This comes at some detriment to Lisp functionality. However, the Lisp | |
53 equivalent of `echo' can always be achieved by using `identity'." | |
54 :type 'boolean | |
55 :group 'eshell-basic) | |
56 | |
57 ;;; | |
58 ;; An example of the difference is the following: | |
59 ;; | |
60 ;; echo Hello world | |
61 ;; | |
62 ;; If `eshell-plain-echo-behavior' is non-nil, this will yield the | |
63 ;; string "Hello world". If Lisp behavior is enabled, however, it | |
64 ;; will yield a list whose two elements are the strings "Hello" and | |
65 ;; "world". The way to write an equivalent expression for both would | |
66 ;; be: | |
67 ;; | |
68 ;; echo "Hello world" | |
69 ;; | |
70 ;; This always returns a single string. | |
71 ;; | |
72 ;;;_* `umask' | |
73 ;; | |
74 ;; The umask command changes the default file permissions for newly | |
75 ;; created files. It uses the same syntax as bash. | |
76 ;; | |
77 ;;;_* `version' | |
78 ;; | |
79 ;; This command reports the version number for Eshell and all its | |
80 ;; dependent module, including the date when those modules were last | |
81 ;; modified. | |
82 | |
83 ;;; Code: | |
84 | |
85 (require 'esh-opt) | |
86 | |
87 ;;; Functions: | |
88 | |
89 (defun eshell-echo (args &optional output-newline) | |
90 "Implementation code for a Lisp version of `echo'. | |
91 It returns a formatted value that should be passed to `eshell-print' | |
92 or `eshell-printn' for display." | |
93 (if eshell-plain-echo-behavior | |
94 (concat (apply 'eshell-flatten-and-stringify args) "\n") | |
95 (let ((value | |
96 (cond | |
97 ((= (length args) 0) "") | |
98 ((= (length args) 1) | |
99 (car args)) | |
100 (t | |
101 (mapcar | |
102 (function | |
103 (lambda (arg) | |
104 (if (stringp arg) | |
105 (set-text-properties 0 (length arg) nil arg)) | |
106 arg)) | |
107 args))))) | |
108 (if output-newline | |
109 (cond | |
110 ((stringp value) | |
111 (concat value "\n")) | |
112 ((listp value) | |
113 (append value (list "\n"))) | |
114 (t | |
115 (concat (eshell-stringify value) "\n"))) | |
116 value)))) | |
117 | |
118 (defun eshell/echo (&rest args) | |
119 "Implementation of `echo'. See `eshell-plain-echo-behavior'." | |
120 (eshell-eval-using-options | |
121 "echo" args | |
122 '((?n nil nil output-newline "terminate with a newline") | |
123 (?h "help" nil nil "output this help screen") | |
124 :preserve-args | |
125 :usage "[-n] [object]") | |
126 (eshell-echo args output-newline))) | |
127 | |
128 (defun eshell/printnl (&rest args) | |
129 "Print out each of the argument, separated by newlines." | |
130 (let ((elems (eshell-flatten-list args))) | |
131 (while elems | |
132 (eshell-printn (eshell-echo (list (car elems)))) | |
133 (setq elems (cdr elems))))) | |
134 | |
135 (defun eshell/listify (&rest args) | |
136 "Return the argument(s) as a single list." | |
137 (if (> (length args) 1) | |
138 args | |
139 (if (listp (car args)) | |
140 (car args) | |
141 (list (car args))))) | |
142 | |
143 (defun eshell/umask (&rest args) | |
144 "Shell-like implementation of `umask'." | |
145 (eshell-eval-using-options | |
146 "umask" args | |
147 '((?S "symbolic" nil symbolic-p "display umask symbolically") | |
148 (?h "help" nil nil "display this usage message") | |
149 :usage "[-S] [mode]") | |
150 (if (or (not args) symbolic-p) | |
151 (let ((modstr | |
152 (concat "000" | |
153 (format "%o" | |
154 (logand (lognot (default-file-modes)) | |
155 511))))) | |
156 (setq modstr (substring modstr (- (length modstr) 3))) | |
157 (when symbolic-p | |
158 (let ((mode (default-file-modes))) | |
159 (setq modstr | |
160 (format | |
161 "u=%s,g=%s,o=%s" | |
162 (concat (and (= (logand mode 64) 64) "r") | |
163 (and (= (logand mode 128) 128) "w") | |
164 (and (= (logand mode 256) 256) "x")) | |
165 (concat (and (= (logand mode 8) 8) "r") | |
166 (and (= (logand mode 16) 16) "w") | |
167 (and (= (logand mode 32) 32) "x")) | |
168 (concat (and (= (logand mode 1) 1) "r") | |
169 (and (= (logand mode 2) 2) "w") | |
170 (and (= (logand mode 4) 4) "x")))))) | |
171 (eshell-printn modstr)) | |
172 (setcar args (eshell-convert (car args))) | |
173 (if (numberp (car args)) | |
174 (set-default-file-modes | |
175 (- 511 (car (read-from-string | |
176 (concat "?\\" (number-to-string (car args))))))) | |
177 (error "setting umask symbolically is not yet implemented")) | |
178 (eshell-print | |
179 "Warning: umask changed for all new files created by Emacs.\n")) | |
180 nil)) | |
181 | |
182 (eval-when-compile | |
183 (defvar print-func)) | |
184 | |
52401 | 185 ;;; arch-tag: 385a31b1-cb95-46f0-9829-9d352ee77db8 |
29876 | 186 ;;; em-basic.el ends here |