From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: How to `start-process' in different terminal? Date: Sun, 22 Jun 2014 17:03:44 +0200 Organization: Informatimago Message-ID: <87egyhnfzj.fsf@kuiper.lan.informatimago.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1403449824 6482 80.91.229.3 (22 Jun 2014 15:10:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 22 Jun 2014 15:10:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 22 17:10:18 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WyjPO-0008Cw-0M for geh-help-gnu-emacs@m.gmane.org; Sun, 22 Jun 2014 17:10:18 +0200 Original-Received: from localhost ([::1]:49356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WyjPN-0002BU-Al for geh-help-gnu-emacs@m.gmane.org; Sun, 22 Jun 2014 11:10:17 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 106 Original-X-Trace: individual.net EtZx9b2ohklMtNqLDbauRwAAU17zenxRyJdaknAOvatXBWQX3t Cancel-Lock: sha1:Yzk5MTU3NGY4N2FmYzljMDA1M2U3OGU2M2Y3Y2E3N2JhZTY3ZWNhMQ== sha1:Ypx/zkqui2g/7N0Bwa1tfXdUdDU= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:206087 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:98358 Archived-At: Thorsten Jolitz writes: > Hi List, > > when running Emacs on the console (without X) I use 'fbgs' to display > pdf files (converted to .tiff actally). This does not work with a > terminal multiplexer like tmux (running on e.g. tty), I have to switch > manually to e.g. tty1 to make it work. > > Quite a lot of Emacs libs use start-process to display generated pdfs > with an OS dependent executable, for example "evince", always assuming > > ,----[ C-h f display-graphic-p RET ] > | display-graphic-p is a compiled Lisp function in `frame.el'. > | > | (display-graphic-p &optional DISPLAY) > | > | Return non-nil if DISPLAY is a graphic display. > `---- > > is non-nil. I would like to fallback to "fbgs" if it is nil on > GNU/Linux, normally from an Emacs running inside a tmux session e.g. on > tty. It depends on the frame, nowadays emacs can work BOTH on a terminal and a X window at the same time: (frame-list) --> (# #) So calling display-graphic-p is meaningless. > How can I `start-process' in a different terminal (e.g. tty1) and switch > to that terminal in an Emacs Lisp program? > > When I call `(terminal-list)' from Emacs instances on two different tty's I get > the same result: > > ,---- > | (#) > `---- I don't observe that: (terminal-list) --> (# # #) (frame-list) --> (# # #) > and I don't find a function for switching terminal or calling cmd on > another terminal. You can use: (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))5) to make a frame on a new terminal. But to run a function in the context of another terminal, you need to select a frame running on that terminal. To find a frame running on a given terminal device: (first (remove* "/dev/pts/3" (frame-list) :test (function string/=) :key (lambda (frame) (terminal-name (frame-terminal frame))))) --> (#) then you can use with-selected-frame to run your code on that frame. To switch automatically to that terminal will depend on the multiplexer you use. You can use chvt(1) to switch to the linux console you want. When you run a multiplexer in the terminal, you need to use whatever is provided by the multiplexer to switch to another view. For example, with screen, you could print ESC ]83;select 1 BEL to select the view 1. I don't know tmux. But the difficulty here would be to have emacs send the escape sequence unchanged. With message or insert, screen doesn't seem to catch it, I guess we'd have to do that at a lower level. Finally if you're on X window, you would have to use window manager commands to move the X window containing the terminal emulator you want on the front. With ratpoison it's done with: (shell-command "ratpoison -c 'select 1'") but it depends on the window manager. Perhaps there's some common (ICCCM) command, and it should be possible to send it, since emacs itself can be used as a X window manager (cf. xwem). -- __Pascal Bourguignon__ http://www.informatimago.com/ "Le mercure monte ? C'est le moment d'acheter !"