[ESS] XEmacs, UNIX, ESS
rdiaz02 at gmail.com
Fri Nov 21 10:56:25 CET 2008
Sorry to jump into the conversation, being a complete emacs lisp ignorant.
push-line-other-window is really neat (and I just added it to my
.emacs). However, if I have more than two windows, I find the behavior
disconcerting. A while ago, I found the following solution, which I
added to my .emacs. It sends the marked line (which can be in any
window) to a shell process, and shows the output (if there is anything
to be shown). What I do not like is that it will not use the shell
process window if I have one open already.
;; Take entire current line and execute it as a shell command:
;; from http://linux.hostweb.com/TopicMessages/comp.os.linux.misc/1859693/25/Default.aspx
(defun my-execute-line ()
"Execute the line the cursor is on in a subshell"
(if (eobp) (error "End of buffer"))
(let ((beg (point)))
(sh-execute-region beg (point))))
;;; I'd like this to work as in ESS, but I can't simply
;;; do a global-set-key because that would break ESS, the python-ess like, etc.
;;; But I don't want them local now, because I sometimes execute pieces
;;; of shell code that are in arbitrary files (R, C, python, etc).
(global-set-key "\C-cy" 'my-execute-line)
(global-set-key "\C-cr" 'sh-execute-region)
On Fri, Nov 21, 2008 at 6:36 AM, Tim Hesterberg <timhesterberg at gmail.com> wrote:
> I'll claim authorship of push-line-other-window. I'm glad to hear
> you find it useful.
> Here are
> * a couple of refinements
> * how I created this in the first place - you may find this useful for
> other applications
> * another useful macro
> Instead of C-x p, I now have it bound to M-o and C-t,
> either of which is easier to type repeatedly.
> (define-key esc-map "o" 'push-line-other-window)
> (global-set-key "\C-t" 'push-line-other-window)
> I now have a slightly more efficient version of the fset command in my
> .emacs. I can't send that in an email message, because it includes
> some control characters, but I'll attach a small zip file that
> contains the definition.
> I created a macro that did what I want, then saved the macro into .emacs.
> Steps are:
> C-x ( start-kbd-macro
> give the sequences of commands that does what you want
> C-x ) end-kbd-macro
> M-x name-last-kbd-macro (give a name)
> ; In your .emacs:
> M-x insert-kbd-macro
> ; Optionally, in your .emacs, bind it to a key sequence.
> I've created a bunch of such macros, though you don't want most of them :-)
> Here's one that's generally useful:
> (fset 'double-line
> [escape ?k ?\C-e ? ?z ?z ?z ? ?\C-y ?\C-n ?\C-a])
> ; insert zzz between copies, can replace that with something needed, or
> With C-u, you can use that to do the same thing for many lines.
> E.g. do
> C-u 3 M-x double-line
> to convert:
> foo zzz foo
> bar zzz bar
> zed zzz zed
> which you can then use other editing commands to convert to:
> mv foo.txt foo.dat
> mv bar.txt bar.dat
> mv zed.txt zed.dat
> Naturally, you will want to use push-line-other-window to send
> those commands to a shell window :-)
> Tim Hesterberg
> On Wed, Nov 19, 2008 at 8:58 AM, Charles C. Berry <cberry at tajo.ucsd.edu>wrote:
>> On Wed, 19 Nov 2008, Luis F wrote:
>> Dear Douglas, Richard, Mailing List:
>>> Thanks for such a quick reply. Douglas is absolutely right. I was
>>> precisely trying to write an email clarifying my unprecise mail. Sorry
>>> about that.
>>> Douglas Bates wrote:
>>>> On Wed, Nov 19, 2008 at 8:12 AM, Richard M. Heiberger <rmh at temple.edu>
>>>> > Use ESS. The behavior is identical on Windows and Unix.
>>>> I believe Luis is asking a different question, Richard. He wants to
>>>> have separate shell and shell-script windows in which he can send
>>>> lines from the shell script window to be executed in the shell window.
>>>> That is, he wants to emulate some of the features provided by ESS for
>>>> R, S-PLUS (which apparently now has become S+) and SAS source files in
>>>> shell scripts.
>> You can use shell-script-mode to edit the script and add his macro:
>> (fset 'push-line-other-window
>> (global-set-key "\C-xp" 'push-line-other-window )
>> to your .emacs (or wherever).
>> With the shell-script-mode window open and the shell-mode window open, you
>> can use C-X p to send a line from the former to the latter.
>> My thanks to the orignator of this macro and apologies for forgetting
>> his/her name. I think it was posted on S-news. I've used it for years when I
>> want to move a line from one buffer to another.
>>>> > -----Original Message-----
>>>> > From: ess-help-bounces at stat.math.ethz.ch
>>>> > [mailto:ess-help-bounces at stat.math.ethz.ch] On Behalf Of Luis F
>>>> > Sent: Wednesday, November 19, 2008 09:02
>>>> > To: ess-help at stat.math.ethz.ch
>>>> > Subject: [ESS] XEmacs, UNIX, ESS
>>>> > > Dear Mailing List,
>>>> > > I am a biologist, very used to program in R using XEmacs and ESS. I
>>>> > to do some little things in UNIX now. I would love to have something
>>>> > similar to what I'm used to with ESS.
>>>> > > Mainly:
>>>> > 1) a shell script on my top window
>>>> > 2) a shell on my bottom window
>>>> > 3) send commands from the script (one line at the time, similar to C-c
>>>> > C-n; a region - C-C C-r; the whole file C-c C-l)
>>>> > > I could already do 1) and 2) (alt-x shell) (major achievements!) and
>>>> > can copy-paste, go from one window do the next (C-x o) and that is
>>>> > already a great improvment.
>>>> > > But I can't do 3). Any suggestions?
>>>> > > I realize this might be a question outside of the strict scope of
>>>> > list (and I appologize if anyone feels this is spam); I decided to
>>>> > it here, because after searching for a while in the web, i felt this
>>>> > specific request would be more understood by people in here.
>>>> > > Thank you all for your work,
>>>> > Tiago
> [[alternative HTML version deleted]]
> ESS-help at stat.math.ethz.ch mailing list
Statistical Computing Team
Structural Biology and Biocomputing Programme
Spanish National Cancer Centre (CNIO)
Phone: +34-91-732-8000 ext. 3019
More information about the ESS-help