[Top][All Lists]

[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 <address@hidden> 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.
> *
> <>*

This file (in org mode contrib)
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) "\""))))


OpenPGP Key ID : 040D0A3B4ED2E5C7

Attachment: pgpy1gp6g6sfQ.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]