LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-21-2008, 06:00 PM   #1
cmetelko
Member
 
Registered: Jan 2006
Posts: 37

Rep: Reputation: 15
Smile Controlling emacs -nw from another terminal or somehow remotely? or vi/pico


Hi,
I would like to control emacs/editors externally ie send a
Ctrl-X Ctrl-F filename to switch files.

I've tried to 'echo -e Ctrl sequence Ctrl X Ctrl F > /dev/pts/X
without success.

I'm interested in making a minimal develop enviroment (just the features I need) after getting annoyed by the bloat of eclipse and esp. NetBeans (which I do really like).
I need to be able to control emacs/vi/pico remotely.

Using redirection is a (slow) win all situation, but if you know how
to do this alternatively for (preferably) emacs please let me know.

Thanks.

NB Netbeans/Eclipse general Java stuff would be great after DSL got hold
of them!
 
Old 02-21-2008, 06:34 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
What exactly are you trying to do, it's not clear?
 
Old 02-22-2008, 04:31 AM   #3
cmetelko
Member
 
Registered: Jan 2006
Posts: 37

Original Poster
Rep: Reputation: 15
An example would be to get a terminal to

echo -e some escape/control string

which sends Ctrl-X Ctrl F filename

to emacs -nw running in a different terminal.

Hence I could get an external program like a file manager to switch
which file I am editing in emacs.


My original idea was to get the /dev/pts/X of the terminal running
emacs -nw from tty, and then
execute
echo -e some escape/control string > /dev/pts/X

on a different terminal.

This does work in some form-> I can send plain text strings which
then appear in emacs, but I can do special keys, and don't know why/how.

-

Hope that is clearer.
 
Old 02-22-2008, 11:43 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
You could use emacsclient: with the --no-wait (or -n) option will cause emacs to open the file given on the command line. With the --eval option you can run arbitrary elisp code which is more flexible than sending keystrokes.
 
Old 02-24-2008, 03:11 PM   #5
cmetelko
Member
 
Registered: Jan 2006
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks for the reply,
took me a while to understand lisp syntax but got it to work.

Using this I can do what I want using xemacs, so I can get started.

Also if I have more than 2 xemacs windows open, can I use gnuclient
with both?

I'm using gnuclient -batch -f function

control lines.


Also very tempted to try using lisp to program, is this a good idea?
I will be linking a filename, interface to svn,cvs, and other progs. I
going to use python.

Is the /dev/pts/ redirection impossible? If I can do it then any
editor would be able to be used. Will use the emacs client though, as
it exists.
 
Old 02-25-2008, 09:39 AM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by cmetelko View Post
Thanks for the reply,
took me a while to understand lisp syntax but got it to work.

Using this I can do what I want using xemacs, so I can get started.

Also if I have more than 2 xemacs windows open, can I use gnuclient
with both?

I'm using gnuclient -batch -f function

control lines.
Hmm, I don't use XEmacs, so I'm not sure. For Emacs you can set the server-window variable to decide which frame or window to choose.

Quote:
Also very tempted to try using lisp to program, is this a good idea?
I will be linking a filename, interface to svn,cvs, and other progs.
Certainly, that is the Emacs Way There is an interface for cvs built-in to emacs already, and psvn is a pretty good interface for svn.

Quote:
Is the /dev/pts/ redirection impossible? If I can do it then any
editor would be able to be used. Will use the emacs client though, as
it exists.
Maybe the trick is to send a literal C-x C-f, looking that up on the ascii table :
Code:
Oct 	Dec 	Hex 	Abbr 	PR[a] 	CS[b] 	CEC[c] 	Description
006 	6 	06 	ACK 	␆ 	^F 		Acknowledgment
030 	24 	18 	CAN 	␘ 	^X 		Cancel
So maybe
Code:
echo -en '\030\006' > /dev/pts/X

Last edited by ntubski; 02-25-2008 at 09:40 AM.
 
Old 03-03-2008, 05:42 PM   #7
cmetelko
Member
 
Registered: Jan 2006
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks for the info
I'll look up and have a play with

server-window variable

and look up emacs cvs and psvn..

still can't get C-x C-f working, could this be my choice of terminal?
I can send text via > dev/pts/X but not Ctrl-sequences.
 
Old 03-04-2008, 06:48 PM   #8
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
still can't get C-x C-f working, could this be my choice of terminal?
I can send text via > dev/pts/X but not Ctrl-sequences.
Well, I didn't actually test my idea, just thought I would throw it out. It doesn't work for me either However, I noticed that echoing text doesn't exactly work, the text shows up on screen, but Emacs treats it as if it wasn't there (running on /dev/tty2 have the same behaviour). I guess echoing to the pts doesn't do exactly the same thing as the user typing.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Alt no longer META key when using in-terminal option of Emacs (emacs -nw) frznchckn Linux - Software 1 06-02-2007 02:41 AM
controlling terminal colors datasink Linux - Desktop 2 01-17-2007 09:08 AM
Remotely monitoring and controlling Dell PowerEdge 1800 without using DRAC Card Probl microbruce Linux - General 1 07-06-2005 09:06 PM
Controlling linux remotely via an IM moux Slackware 3 06-28-2004 11:59 AM
Remotely controlling my computer Totoro Linux - Newbie 2 03-18-2004 04:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration