From: klebsiella <pierre.khoueiry@embl.de>
To: Help-gnu-emacs@gnu.org
Subject: Re: send selection or current line to Terminal/iTerm
Date: Fri, 13 Jun 2014 06:39:36 -0700 (PDT) [thread overview]
Message-ID: <1402666776993-324448.post@n5.nabble.com> (raw)
In-Reply-To: <CAOj2CQSje7CQeStuy2MY7VAS7O9d+Y5Ta0238Eq7mcP1JxQJew@mail.gmail.com>
So guys,
First thank you all for your time.
Here is the code in my .emacs (see below) that is supposed to do the job
(Thanks go to @JordonBiondo - Stackoverflow and also to you John Mastro)
I am now working on emacs (not Aquamacs) and the code is still not working.
Again, as I do not know Lisp, it was hard for me to debug !!!
The error message given is I guess thrown by osascript, but may be linked to
a syntax problem in lisp:
100:100: syntax error: Expected string but found end of script. (-2741)
Process send-text-iterm2-proc exited abnormally with code 1
Osascript itself is working. For instance the following line runs correctly
on the terminal:
$ osascript -e 'tell application "iTerm" ' -e 'set mysession to current
session of current terminal' -e 'tell mysession to write text "ls"' -e 'end
tell'
It would be great to make it run (For everybody I believe)
.emacs related chunk
(defun sendtext:escape-text(s):
(with-temp-buffer
(insert s)
(replace-string "\\" "\\\\" nil (point-min) (point-max))
(replace-string "\"" "\\\"" nil (point-min) (point-max))
(buffer-substring-no-properties (point-min) (point-max))))
(defun sendtext:send-iterm2(beg end)
(interactive "r")
(let ((text (buffer-substring-no-properties beg end)))
(start-process "send-text-iterm2-proc" "*sendtext:output*"
"osascript"
"-e" "tell app \"iTerm\""
"-e" "set mysession to current session of current
terminal"
"-e" "tell mysession to write text \""
(sendtext:escape-text text)
"\""
"-e" "end tell")))
John Mastro wrote
> Hi klebsiella,
>
> John Mastro <
> john.b.mastro@
> > wrote:
>> This is totally untested (sorry, still not around a Mac), but I think
>> something along these lines should work. Assuming that SublimeText
>> extension works anyway.
>
> By the way, if the code I posted does do approximately want you want,
> I'd be happy to improve it a bit for you (e.g. handling escaping, as the
> SublimeText version seems to).
>
> If you try it, let me know if/how it works for you.
>
> - John
--
View this message in context: http://emacs.1067599.n5.nabble.com/send-selection-or-current-line-to-Terminal-iTerm-tp324145p324448.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
next prev parent reply other threads:[~2014-06-13 13:39 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-08 20:58 send selection or current line to Terminal/iTerm klebsiella
2014-06-12 15:13 ` klebsiella
2014-06-12 15:49 ` Jai Dayal
2014-06-12 16:00 ` klebsiella
2014-06-12 16:02 ` Jai Dayal
[not found] ` <mailman.3500.1402588211.1147.help-gnu-emacs@gnu.org>
2014-06-12 20:29 ` Emanuel Berg
2014-06-12 20:31 ` Jai Dayal
[not found] ` <mailman.3510.1402605133.1147.help-gnu-emacs@gnu.org>
2014-06-12 20:36 ` Emanuel Berg
2014-06-12 20:43 ` Jai Dayal
2014-06-12 21:28 ` John Mastro
[not found] ` <mailman.3511.1402605838.1147.help-gnu-emacs@gnu.org>
2014-06-12 21:10 ` Emanuel Berg
2014-06-12 21:17 ` Jai Dayal
2014-06-12 21:43 ` klebsiella
2014-06-12 23:59 ` Jai Dayal
[not found] ` <CAOj2CQRaRpKuTTgseGjfhk504BLRJ=J+9C76nj+W6Px2iL9X1Q@mail.gmail.com>
2014-06-13 0:55 ` John Mastro
2014-06-13 13:39 ` klebsiella [this message]
2014-06-13 16:51 ` John Mastro
2014-06-14 2:30 ` John Mastro
2014-06-14 6:52 ` klebsiella
2014-06-14 14:22 ` Robert Thorpe
2014-06-14 15:09 ` klebsiella
2014-06-14 18:59 ` Robert Thorpe
[not found] ` <mailman.3652.1402758599.1147.help-gnu-emacs@gnu.org>
2014-06-17 14:11 ` Rusi
2014-06-17 15:58 ` klebsiella
2014-06-17 18:46 ` klebsiella
2014-06-17 19:55 ` John Mastro
2014-06-18 1:11 ` Robert Thorpe
2014-06-18 11:30 ` klebsiella
2014-06-14 16:52 ` John Mastro
2014-06-14 18:09 ` klebsiella
2014-06-14 18:36 ` John Mastro
2014-06-14 19:01 ` klebsiella
2014-06-14 19:24 ` John Mastro
2014-06-14 19:53 ` klebsiella
2014-06-14 15:31 ` Alan Schmitt
[not found] ` <mailman.3513.1402607827.1147.help-gnu-emacs@gnu.org>
2014-06-12 21:35 ` Emanuel Berg
2014-06-12 22:50 ` Robert Thorpe
[not found] ` <mailman.3499.1402586049.1147.help-gnu-emacs@gnu.org>
2014-06-12 15:47 ` Emanuel Berg
2014-06-12 21:26 ` Hans BKK
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1402666776993-324448.post@n5.nabble.com \
--to=pierre.khoueiry@embl.de \
--cc=Help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.