Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:43:57+00:00 2026-06-14T20:43:57+00:00

I’m using a local emacs instance (aquamacs) to run R processes on a remote

  • 0

I’m using a local emacs instance (aquamacs) to run R processes on a remote server, and I’d like to automate the process of connecting to my server. The process is as follows:

[in emacs]

M-x shell

[in the resulting console]

TERM=xterm
ssh -Y -C <my remote server>
screen -rd [and/or] R

[in emacs]

M-x ess-remote
r

I discovered this general approach here: http://blog.nguyenvq.com/2010/07/11/using-r-ess-remote-with-screen-in-emacs/. The -Y -C options allow you use xterm to view plots. I don’t know lisp and tho I’ve googled around a bit, I can’t seem to piece together how to actually define a function to automate this (e.g., in .emacs.el). Has anyone implemented anything like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:43:59+00:00Added an answer on June 14, 2026 at 8:43 pm

    Let’s assume you just want to call shell in code. In Lisp, everything is prefix notation surrounded by parentheses. So we enter this into a buffer (say, the scratch buffer):

    (shell)
    

    Move your pointer to the end of the line after the close-paren, and type <C-x C-e> to execute the Lisp code. You should see that the shell function is called.

    Now, let’s make it a function, so we can add other things to it. The command to create a function is defun, and it takes the name of the function, the argument list (in parentheses), and then the body of the function:

    (defun automate-connection ()
      (shell))
    

    Move your cursor to the end of the code, hit <C-x C-e>, and the function will be defined. You can call it from Lisp by executing

    (automate-connection)
    

    Ok, now we just need to put some text into the shell buffer.

    (defun automate-connection ()
      (shell)
      (insert "TERM=xterm"))
    

    Now, when we run that, we get “TERM=xterm” put into the shell buffer. But it doesn’t actually send the command. Let’s try putting a newline.

    (defun automate-connection ()
      (shell)
      (insert "TERM=xterm\n"))
    

    That puts in a newline, but doesn’t actually make the command run. Why not? Let’s see what the enter key does. Go to your *shell* buffer, and type <C-h c>, then hit the return key. (<C-h c> runs describe-key-briefly, which prints the name of the function invoked by hitting the given key). That says that when you hit RET, it’s not putting a newline, but actually calling comint-send-input. So let’s do that:

    (defun automate-connection ()
      (shell)
      (insert "TERM=xterm")
      (comint-send-input))
    

    Now, when you run `(automate-connection) from any Lisp code, you should get the given thing sent. I leave it as an exercise to the reader to add your other commands.

    But wait! We’re not really done, are we? I assume you don’t want to have to move to a Lisp scratch buffer, type in (automate-connection), then evaluate that code. You probably just want to type , and call it a day. You can’t do that by default with the function we just created. Luckily, it’s simple to allow that: just add a call to (interactive) in your function:

    (defun automate-connection ()
      (interactive)
      (shell)
      (insert "TERM=xterm")
      (comint-send-input))
    

    Now you can call it as you want, and it’ll open the *shell* buffer, put in the text, and tell Emacs to tell the shell to run that text.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I have thousands of HTML files to process using Groovy/Java and I need to
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.