[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Changes 2009-07-15/16 in branch?
From: |
Stephen J. Turnbull |
Subject: |
Re: Changes 2009-07-15/16 in branch? |
Date: |
Sat, 01 Aug 2009 15:28:19 +0900 |
Ian Eure writes:
> I think it would be unfortunate if it were removed. As Emacs can be
> used to develop AppleScript (or other OSA supported languages) this
> feature would be needed to run them from within Emacs to test the
> code. Without it, you must rely on other tools outside of Emacs for
> this functionality.
Yeah, but as Harald pointed out, you only have to go as far as
osascript (part of Mac OS, or maybe Xcode) and .emacs:
;; Copyright 2009 Stephen J. Turnbull
;; this code and inlined documentation is licensed to you under the
;; GNU GPL, v2 or later at your option
;; tested in XEmacs 21.5.29, YMMV (see the NO WARRANTY clause of the license)
(defun osascript (script &rest args)
"Run string SCRIPT as an OSA script \(eg, Applescript), with arguments ARGS.
Each element of the list ARGS is added to the invocation of osascript(1)
formatted with \" %s\".
BUG: in interactive use, ARGS must be provided as a Lisp list."
;; A custom read-list could be provided to allow the following style
;; of interface. Example script from osascript(1).
;; Prompts abbreviated, user input only:
;; M-x osascript RET
;; SCRIPT: on run argv C-q C-j
;; return "hello, " & item 1 of argv & "." C-q C-j
;; end run C-q C-j RET
;; ARG: world RET
;; ARG: moon RET
;; ARG: RET
;; and the empty arg terminates the list and runs the command.
(interactive "sEnter the text of the script (use C-q C-j for newlines):
xScript arguments (as a Lisp list): ")
;; kludge to deal with `interactive's lack of awareness of &rest
(when (interactive-p)
(setq args (car args)))
(shell-command (concat (format "osascript -e '%s'" script)
(mapconcat (lambda (x) (format " %s" x)) args ""))))