[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: send selection or current line to Terminal/iTerm
From: |
Alan Schmitt |
Subject: |
Re: send selection or current line to Terminal/iTerm |
Date: |
Sat, 14 Jun 2014 17:31:34 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) |
On 2014-06-13 01:59, Jai Dayal <dayalsoap@gmail.com> 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
> <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
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
pgpk2L9qQ6cR4.pgp
Description: PGP signature
- Re: send selection or current line to Terminal/iTerm, (continued)
- Re: send selection or current line to Terminal/iTerm, John Mastro, 2014/06/14
- Re: send selection or current line to Terminal/iTerm, klebsiella, 2014/06/14
- Re: send selection or current line to Terminal/iTerm, John Mastro, 2014/06/14
- Re: send selection or current line to Terminal/iTerm, klebsiella, 2014/06/14
- Re: send selection or current line to Terminal/iTerm, John Mastro, 2014/06/14
- Re: send selection or current line to Terminal/iTerm, klebsiella, 2014/06/14
- Re: send selection or current line to Terminal/iTerm,
Alan Schmitt <=
- Message not available
- Re: send selection or current line to Terminal/iTerm, Emanuel Berg, 2014/06/12
Re: send selection or current line to Terminal/iTerm, Robert Thorpe, 2014/06/12
Message not available
Message not available