From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: chad Newsgroups: gmane.emacs.devel Subject: Re: ns-do-applescript Date: Tue, 31 May 2022 15:05:48 -0400 Message-ID: References: <87bkvoo38y.fsf.ref@yahoo.com> <87bkvoo38y.fsf@yahoo.com> <871qwjn5ca.fsf@yahoo.com> <87fskwk79v.fsf@yahoo.com> <87leumebby.fsf@yahoo.com> <87ee0bdhah.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000008fd1e305e053766b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40320"; mail-complaints-to="usenet@ciao.gmane.io" Cc: EMACS development team , Po Lu To: Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 31 21:07:31 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nw7DH-000AMo-4z for ged-emacs-devel@m.gmane-mx.org; Tue, 31 May 2022 21:07:31 +0200 Original-Received: from localhost ([::1]:34572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nw7DG-0002sA-7F for ged-emacs-devel@m.gmane-mx.org; Tue, 31 May 2022 15:07:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nw7Bt-0001Me-Vt for emacs-devel@gnu.org; Tue, 31 May 2022 15:06:08 -0400 Original-Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]:34606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nw7Bq-0004p0-Rz; Tue, 31 May 2022 15:06:05 -0400 Original-Received: by mail-lj1-x22b.google.com with SMTP id k20so7072273ljc.1; Tue, 31 May 2022 12:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+NG4svwOwVuOz2C7KdvEHLw4wSU6wwHgOjbaWGzq57U=; b=J6dL4BXw3buCQYD3X1Gj4H3os7okB2dvhix98BYxpf7NGFE2lObrkQfcQi6uT5sY4v U3rJBpt6j/5lxBv9WAOby2OYIPKf7SCsZRWyrR3Lfj+FcrcHK5dOAz3WEaiPjaoMFh+o cY8GtfWhHdml1gveWRNQv4Hm7F1xyJTCfxqmtG9vyE7D01RhVgtH5WlqhhI1E01ZCBNY OJwcTXdFEC2lg/A0mgxmT2B+/p+3jF241T/mRc5euMLEIKhHKuEvCD+aBPoToRkS0KxJ +p2pBLzJyJiowiGxd2T9CI1He3J+Mh2aMI5rvT2xzGVdR3t0WiIEbqxk70AOh9+Fyz4U f0Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+NG4svwOwVuOz2C7KdvEHLw4wSU6wwHgOjbaWGzq57U=; b=TN+zKNSRWMB+TmWgitlKdNWP5MbAJ2juVANreYEcePy3wVbk6DoEABnOqQWTjS73rK n/fJtdO976skfVeq4sd1Gfj1hzOjO5pSy1GAGDdqUuCrfSBayIubJExi2Uu7L85r+gwz qzJLXnfexcTN3sCjd4YoIHgIEKr4cps7wir2Fd43D5oEKnFbzVv9kwhfyaGUG+Ah3aR1 GWgU1U9346ICgaEUIPmEKUaFbflWOaXiBEOm48KvYq5Mfd/cEUNTZVSkYDS1L43VGHnN WvWqXK0IFVQKFJOZApB8J0vix7OFbOiehUyUDphW3GYqh/e4e2QMqGTMdukWo4GOsFnW g8Cw== X-Gm-Message-State: AOAM531ONjOk1dzwtOGbNhp1OWYryYrE3F5PYq1kuY9/Ll6eLKsMg1rA 9Zkb4GpSn2YM9kD3niW5CO4SL29nKU1QACRdBklSJyLv X-Google-Smtp-Source: ABdhPJzoxEvyRZCRP576yGnWKcVln/lu1sTdF3WxX1urNesiEqldwRIeL1c8/zzUPWDpq2wLlJOoqMC9dNDLxsfPE18= X-Received: by 2002:a2e:9b52:0:b0:253:d8fd:abc5 with SMTP id o18-20020a2e9b52000000b00253d8fdabc5mr35021933ljj.24.1654023959596; Tue, 31 May 2022 12:05:59 -0700 (PDT) In-Reply-To: <87ee0bdhah.fsf@yahoo.com> Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=yandros@gmail.com; helo=mail-lj1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:290444 Archived-At: --0000000000008fd1e305e053766b Content-Type: text/plain; charset="UTF-8" Short, short version: imagine that Sun built a version of solaris that almost entirely replaced "shell" with a variant of Java that didn't *inititally* come with a stand-alone interpreter, but did add one later. Then: s/Sun/Apple/, s/solaris/macosx/, and s/Java/AppleScript/. Longer version: Since Apple bundles together the user toolkit, system UI, "window manager", and system services all behind a (sadly mostly proprietary) wall, native macOS applications that want to do "plumbing" use a scripting language called "Applescript", based very loosely around HyperCard. This dates back to the previous millenium, to well before the Unix-like Mac OS X was built from a combination of Mach, FreeBSD, and NextSTEP. In those days, there was no multi-user OS underpinning that understood things like shell scripts and forking processing. Applications that are "Applescript aware", which includes basically everything that comes with the OS as well as much of the 3rd party software could be interacted with using "code" like "tell application Music to play U2" or "tell application Mail to open new message addressed to monopoly@microsoft.com" (as well as more complicated scripts with variables, logic, etc). At some point, Apple regularized the OS-level interface to this language, and named it the "Open Scripting Architecture" -- presumably back when adding the word "Open" to every kind of software was de rigueur. The ns port of Emacs to macosx added the ability to use the system library calls that tie applications into the OS-level infrastructure, known as "the scripting system", "the scripting layer", or similar variants. If memory serves, some time later macosx itself grew a unix-level cli for this system itself, which is where "the osascript executable" came into play, which allowed mixing between Applescript and other scripting languages (I have seen both perl and tcl code that "automated" macosx by generating AppleScript and feeding it to the system, probably via osascript or a predecessor thereof). Before then, applications needed to link to the built-in system scripting libraries and call the related functions. In emacs, there are a few nice things that can be done by having Emacs ask the OS to execute Applescript. Some of these, *in theory*, benefit from not needing to fork an interpreter each time. In practice, macos these days (note: I stopped using it regularly several years ago) has more or less enough of a unix-like underpinning that people can mostly use the same sort of inter-process techniques that they use on other operating systems. The remaining areas of friction come from interacting with the system software; for example, asking the default web browser the URL of its various windows. >From my point of view, this pretty clearly falls into the category of native application support on a proprietary OS. It's not enabling anything that doesn't already exist, by definition; but it is potentially making life easier for Emacs users on that platform. In practice, there wasn't a lot of upside when last I looked, so it probably doesn't warrant a lot of effort to continue, but there are a few platform-standard things that it enables that are useful and benefit from calling a library function rather than forking an interpreter. Of course, that relies on there being someone willing to maintain the glue to those library functions. Hope that helps, ~Chad --0000000000008fd1e305e053766b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Short, short version: imagine that Sun built a versio= n of solaris that almost entirely replaced "shell" with a variant= =C2=A0of Java that didn't *inititally* come with a stand-alone interpre= ter, but did add one later. Then: s/Sun/Apple/, s/solaris/macosx/, and s/Ja= va/AppleScript/.

Longer version:

Since Apple bundles together the user toolkit, system UI, "window m= anager", and system services all behind a (sadly mostly proprietary) w= all, native macOS applications that want to do "plumbing" use a s= cripting language called "Applescript", based very loosely around= HyperCard. This dates back to the previous millenium, to well before the U= nix-like Mac OS X was built from a combination of Mach, FreeBSD, and NextST= EP. In those days, there was no multi-user OS underpinning=C2=A0that unders= tood things like shell scripts and forking=C2=A0processing. Applications th= at are "Applescript aware", which includes basically everything t= hat comes with the OS as well as much of the 3rd party software could be in= teracted=C2=A0with using "code" like "tell application Music= to play U2" or "tell application Mail to open new message addres= sed to monopoly@microsoft.com= " (as well as more complicated scripts with variables, logic, etc).
At some point, Apple regularized=C2=A0the OS-level interfa= ce to this language, and named it the "Open Scripting Architecture&quo= t; -- presumably back when adding the word "Open" to every kind o= f software was de rigueur. The ns port of Emacs to macosx=C2=A0added the ab= ility to use the system library calls that tie applications into the OS-lev= el infrastructure, known as "the scripting system", "the scr= ipting layer", or similar variants.=C2=A0

If = memory serves, some time later macosx=C2=A0itself grew a unix-level cli for= this system itself, which is where "the osascript executable" ca= me into play, which allowed mixing between Applescript and other scripting = languages (I have seen both perl and tcl code that "automated" ma= cosx by generating AppleScript and feeding it to the system, probably via o= sascript or a predecessor thereof). Before then, applications needed to lin= k to the built-in system scripting libraries and call the related functions= .

In emacs, there are a few nice things that can b= e done by having Emacs ask the OS to execute Applescript. Some of these, *i= n theory*, benefit from not needing to fork an interpreter each time. In pr= actice, macos these days (note: I stopped using it regularly several years = ago) has more or less enough of a unix-like underpinning that people can mo= stly use the same sort of inter-process techniques that they use on other o= perating systems. The remaining areas of friction come from interacting wit= h the system software; for example, asking the default web browser the URL = of its various windows.

From my point of view, thi= s pretty clearly falls into the category of native application support on a= proprietary OS. It's not enabling anything that doesn't already ex= ist, by definition; but it is potentially making life easier for Emacs user= s on that platform. In practice, there wasn't a lot of upside when last= I looked, so it probably doesn't warrant a lot of effort to continue, = but there are a few platform-standard things that it enables that are usefu= l and benefit from calling a library function rather than forking an interp= reter. Of course, that relies on there being someone willing to maintain th= e glue to those library functions.

Hope that helps= ,
~Chad
--0000000000008fd1e305e053766b--