From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Schmitt Newsgroups: gmane.emacs.help Subject: Re: send selection or current line to Terminal/iTerm Date: Sat, 14 Jun 2014 17:31:34 +0200 Message-ID: References: <1402261104327-324145.post@n5.nabble.com> <1402586029056-324374.post@n5.nabble.com> <87r42tvpkr.fsf@debian.uxu> <87k38lvp9r.fsf@debian.uxu> <87d2edvnog.fsf@debian.uxu> <1402609430389-324400.post@n5.nabble.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1402759940 31609 80.91.229.3 (14 Jun 2014 15:32:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 14 Jun 2014 15:32:20 +0000 (UTC) Cc: help-gnu-emacs , klebsiella To: Jai Dayal Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 14 17:32:14 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 1WvpwE-00086K-4W for geh-help-gnu-emacs@m.gmane.org; Sat, 14 Jun 2014 17:32:14 +0200 Original-Received: from localhost ([::1]:35737 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvpwD-0007fc-Ep for geh-help-gnu-emacs@m.gmane.org; Sat, 14 Jun 2014 11:32:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wvpvv-0007fH-K0 for Help-gnu-emacs@gnu.org; Sat, 14 Jun 2014 11:32:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wvpvn-0001A5-R3 for Help-gnu-emacs@gnu.org; Sat, 14 Jun 2014 11:31:55 -0400 Original-Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:22684) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wvpvn-000180-KO for Help-gnu-emacs@gnu.org; Sat, 14 Jun 2014 11:31:47 -0400 X-IronPort-AV: E=Sophos;i="5.01,477,1400018400"; d="scan'208";a="80065361" Original-Received: from cbg35-2-78-242-14-140.fbx.proxad.net (HELO top.local) ([78.242.14.140]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA; 14 Jun 2014 17:31:44 +0200 In-Reply-To: (Jai Dayal's message of "Thu, 12 Jun 2014 17:59:20 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.134.164.83 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:98254 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On 2014-06-13 01:59, Jai Dayal writes: > Okay, good, so it calls applescript. > > Is there a way to have emacs call applescript programs? > > It seems "yes", but I can't tell for sure. > > *http://www.emacswiki.org/emacs/EmacsForMacOS#toc21 > * This file (in org mode contrib) http://orgmode.org/cgit.cgi/org-mode.git/tree/contrib/lisp/org-mac-link.el shows how to do it. I think this is the relevant code. #+begin_src emacs-lisp ;; In mac.c, removed in Emacs 23. (declare-function do-applescript "org-mac-message" (script)) (unless (fboundp 'do-applescript) ;; Need to fake this using shell-command-to-string (defun do-applescript (script) (let (start cmd return) (while (string-match "\n" script) (setq script (replace-match "\r" t t script))) (while (string-match "'" script start) (setq start (+ 2 (match-beginning 0)) script (replace-match "\\'" t t script))) (setq cmd (concat "osascript -e '" script "'")) (setq return (shell-command-to-string cmd)) (concat "\"" (org-trim return) "\"")))) #+end_src Alan =2D-=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBAgAGBQJTnGrfAAoJEAQNCjtO0uXHp1oH/1JMUFV2bgrsZJgxakw3qAmn Mz4FCuFJq2obW2wiopZ8PPjbtVETJFFbNnV4GzAYNfDuVh5Mq0mhVaZjCPdX/uDo sCaTpNSp40pfojlm0ujdSfwswwvnMKFewcoHSymHvPE7fwCPmRAt7+LAxfbakEFl mhr0IaO0qXvDQVQxAO73ZkFokCGKyIf1zqhg67A4As0VEOjjH3odx26rdmYIyET/ PD27FIwCiT8cMl/XXae5MFsFmu9C0hIo8MctseOaZsM4XwHxQhD17fBkUDvOYex7 XUlWQBPz1w2nCzhV3bPNLa2t6uXTdL74d7uQvPsSyMSPKjSCwd4opxrb0jA3fGU= =/5dY -----END PGP SIGNATURE----- --=-=-=--