unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* ns-do-applescript
       [not found] <87bkvoo38y.fsf.ref@yahoo.com>
@ 2022-05-23 12:14 ` Po Lu
  2022-05-23 20:44   ` ns-do-applescript Filipp Gunbin
  0 siblings, 1 reply; 36+ messages in thread
From: Po Lu @ 2022-05-23 12:14 UTC (permalink / raw)
  To: emacs-devel

Why does Emacs have support for running AppleScript programs?
Even worse, that support is only available on Mac OS.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-23 12:14 ` ns-do-applescript Po Lu
@ 2022-05-23 20:44   ` Filipp Gunbin
  2022-05-24  0:26     ` ns-do-applescript Po Lu
  2022-05-24 21:26     ` ns-do-applescript Richard Stallman
  0 siblings, 2 replies; 36+ messages in thread
From: Filipp Gunbin @ 2022-05-23 20:44 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

On 23/05/2022 20:14 +0800, Po Lu wrote:

> Why does Emacs have support for running AppleScript programs?
> Even worse, that support is only available on Mac OS.

Just FTR, AppleScript is used in eudcb-macos-contacts.el, but via
osascript executable.

Filipp



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-23 20:44   ` ns-do-applescript Filipp Gunbin
@ 2022-05-24  0:26     ` Po Lu
  2022-05-24 20:00       ` ns-do-applescript Daniel Martín
  2022-05-26  8:24       ` ns-do-applescript Richard Stallman
  2022-05-24 21:26     ` ns-do-applescript Richard Stallman
  1 sibling, 2 replies; 36+ messages in thread
From: Po Lu @ 2022-05-24  0:26 UTC (permalink / raw)
  To: emacs-devel

Filipp Gunbin <fgunbin@fastmail.fm> writes:

> Just FTR, AppleScript is used in eudcb-macos-contacts.el, but via
> osascript executable.

Indeed, which is why I further fail to see the point of making that a
builtin.

IMHO Emacs should not integrate the ability to run a language with a
proprietary runtime that is only available on a proprietary operating
system.  Which is completely out of scope of a GUI port (the NS port.)

Does anyone object to its removal? It would also resolve bug#39890 and
other problems stemming from our maintenance of this misfeature, and
people can use `osascript' in a subprocess anyway.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-24  0:26     ` ns-do-applescript Po Lu
@ 2022-05-24 20:00       ` Daniel Martín
  2022-05-24 20:11         ` ns-do-applescript Stefan Monnier
  2022-05-26  8:24       ` ns-do-applescript Richard Stallman
  1 sibling, 1 reply; 36+ messages in thread
From: Daniel Martín @ 2022-05-24 20:00 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

Po Lu <luangruo@yahoo.com> writes:

> Does anyone object to its removal? It would also resolve bug#39890 and
> other problems stemming from our maintenance of this misfeature, and
> people can use `osascript' in a subprocess anyway.

I don't object delegating to osascript as a subprocess, but there are
probably lots of packages and user customizations already calling
ns-do-applescript.  We should deprecate the API before removing it, and
the deprecation message should tell people how they can call osascript
in an equivalent way.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-24 20:00       ` ns-do-applescript Daniel Martín
@ 2022-05-24 20:11         ` Stefan Monnier
  2022-05-25 13:57           ` ns-do-applescript Howard Melman
  0 siblings, 1 reply; 36+ messages in thread
From: Stefan Monnier @ 2022-05-24 20:11 UTC (permalink / raw)
  To: Daniel Martín; +Cc: Po Lu, emacs-devel

Daniel Martín [2022-05-24 22:00:12] wrote:
> I don't object delegating to osascript as a subprocess, but there are
> probably lots of packages and user customizations already calling
> ns-do-applescript.  We should deprecate the API before removing it, and
> the deprecation message should tell people how they can call osascript
> in an equivalent way.

Can we re-implement `ns-do-applescript` as an ELisp function that runs
`osascript`?


        Stefan




^ permalink raw reply	[flat|nested] 36+ messages in thread

* ns-do-applescript
@ 2022-05-24 21:21 Jon Snader
  2022-05-25  2:28 ` ns-do-applescript Po Lu
  0 siblings, 1 reply; 36+ messages in thread
From: Jon Snader @ 2022-05-24 21:21 UTC (permalink / raw)
  To: emacs-devel; +Cc: luangruo

I don't understand the urgent—or, indeed, any—need to eliminate 
this call. I've been using it for years to populate an Emacs 
buffer with the URL of the current page displayed in Safari. I 
used to use osascript as recommended by those advocating 
ns-do-applescript's removal but moved to ns-do-applescript when 
osascript became unacceptably slow. That issue may have been 
resolved but I've never felt the need to revisit the matter.

According the the 2020 Emacs survey, Mac users represent 26.6% of 
Emacs users (https://emacssurvey.org/2020/) so it's hardly a niche 
environment for Emacs. As macOS is the second largest user base, I 
don't see how it hurts to make Mac users' life marginally easier.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-23 20:44   ` ns-do-applescript Filipp Gunbin
  2022-05-24  0:26     ` ns-do-applescript Po Lu
@ 2022-05-24 21:26     ` Richard Stallman
  2022-05-24 23:01       ` ns-do-applescript Filipp Gunbin
  2022-05-25  0:50       ` ns-do-applescript Po Lu
  1 sibling, 2 replies; 36+ messages in thread
From: Richard Stallman @ 2022-05-24 21:26 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: luangruo, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Just FTR, AppleScript is used in eudcb-macos-contacts.el, but via
  > osascript executable.

The comments in that file suggest that this is not a general facility
to execute AppleScript programs, but rather a way to get data out of a
MacOS-specific contacts database.

Am I right about that?

Other systems will have other kinds of contacts databases doing the
same job, and Emacs seems to support them just as well or better.

Am I right about that?

If so, then under the conditions in the node Non-GNU-Only Features of
the GNU Maintainers Guide, this is a system-specific implementation of
a feature that is supported equally well on the GNU system, so it is
ok.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-24 21:26     ` ns-do-applescript Richard Stallman
@ 2022-05-24 23:01       ` Filipp Gunbin
  2022-05-25  0:50       ` ns-do-applescript Po Lu
  1 sibling, 0 replies; 36+ messages in thread
From: Filipp Gunbin @ 2022-05-24 23:01 UTC (permalink / raw)
  To: Richard Stallman; +Cc: luangruo, emacs-devel

On 24/05/2022 17:26 -0400, Richard Stallman wrote:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > Just FTR, AppleScript is used in eudcb-macos-contacts.el, but via
>   > osascript executable.
>
> The comments in that file suggest that this is not a general facility
> to execute AppleScript programs, but rather a way to get data out of a
> MacOS-specific contacts database.
>
> Am I right about that?

Yes.

> Other systems will have other kinds of contacts databases doing the
> same job, and Emacs seems to support them just as well or better.
>
> Am I right about that?

eudcb-macos-contacts is an EUDC backend.  Other backends in Emacs are
mainly eudcb-ldap and eudcb-bbdb, they both work on GNU system (but on
nonfree systems as well), and are more complete than
eudcb-macos-contacts.

> If so, then under the conditions in the node Non-GNU-Only Features of
> the GNU Maintainers Guide, this is a system-specific implementation of
> a feature that is supported equally well on the GNU system, so it is
> ok.

Yes, but the topic was about the C function, ns-do-applescript, not
about eudcb-macos-contacts...

Filipp



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-24 21:26     ` ns-do-applescript Richard Stallman
  2022-05-24 23:01       ` ns-do-applescript Filipp Gunbin
@ 2022-05-25  0:50       ` Po Lu
  2022-05-25 12:09         ` ns-do-applescript Alexander Adolf
  1 sibling, 1 reply; 36+ messages in thread
From: Po Lu @ 2022-05-25  0:50 UTC (permalink / raw)
  To: Richard Stallman; +Cc: Filipp Gunbin, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> The comments in that file suggest that this is not a general facility
> to execute AppleScript programs, but rather a way to get data out of a
> MacOS-specific contacts database.
>
> Am I right about that?

Yes.  But I don't see why that cannot call osascript in a subprocess
either, since what the Emacs C code provides is a general facility for
evaluating arbitrary AppleScript code, which is not present on any free
system.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-24 21:21 ns-do-applescript Jon Snader
@ 2022-05-25  2:28 ` Po Lu
  2022-05-25  2:58   ` ns-do-applescript Tim Cross
  0 siblings, 1 reply; 36+ messages in thread
From: Po Lu @ 2022-05-25  2:28 UTC (permalink / raw)
  To: Jon Snader; +Cc: emacs-devel

Jon Snader <jcs@irreal.org> writes:

> I don't understand the urgent—or, indeed, any—need to eliminate this
> call. I've been using it for years to populate an Emacs buffer with
> the URL of the current page displayed in Safari. I used to use
> osascript as recommended by those advocating ns-do-applescript's
> removal but moved to ns-do-applescript when osascript became
> unacceptably slow. That issue may have been resolved but I've never
> felt the need to revisit the matter.
>
> According the the 2020 Emacs survey, Mac users represent 26.6% of
> Emacs users (https://emacssurvey.org/2020/) so it's hardly a niche
> environment for Emacs. As macOS is the second largest user base, I
> don't see how it hurts to make Mac users' life marginally easier.

macOS is a proprietary operating system.  We don't try to make its users
lives easier, we try to encourage them switch to GNU/Linux.  Supporting
a feature that is only available there would just encourage users to use
it.

Not to mention that the AppleScript support has several bugs, including
bug#39890, that I cannot fix or easily test, since AppleScript is not
available in GNUstep.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-25  2:28 ` ns-do-applescript Po Lu
@ 2022-05-25  2:58   ` Tim Cross
  2022-05-25  4:46     ` ns-do-applescript Po Lu
  0 siblings, 1 reply; 36+ messages in thread
From: Tim Cross @ 2022-05-25  2:58 UTC (permalink / raw)
  To: emacs-devel


Po Lu <luangruo@yahoo.com> writes:

> Jon Snader <jcs@irreal.org> writes:
>
>> I don't understand the urgent—or, indeed, any—need to eliminate this
>> call. I've been using it for years to populate an Emacs buffer with
>> the URL of the current page displayed in Safari. I used to use
>> osascript as recommended by those advocating ns-do-applescript's
>> removal but moved to ns-do-applescript when osascript became
>> unacceptably slow. That issue may have been resolved but I've never
>> felt the need to revisit the matter.
>>
>> According the the 2020 Emacs survey, Mac users represent 26.6% of
>> Emacs users (https://emacssurvey.org/2020/) so it's hardly a niche
>> environment for Emacs. As macOS is the second largest user base, I
>> don't see how it hurts to make Mac users' life marginally easier.
>
> macOS is a proprietary operating system.  We don't try to make its users
> lives easier, we try to encourage them switch to GNU/Linux.  Supporting
> a feature that is only available there would just encourage users to use
> it.
>

This might be a reaonable argument when considering adding additional
support/integration, but falls short when referencing work which ahs
already been completed and has been part of Emacs for some time. 

> Not to mention that the AppleScript support has several bugs, including
> bug#39890, that I cannot fix or easily test, since AppleScript is not
> available in GNUstep.

Perhaps then your not the right person to address those bugs? Perhaps
they need to be addressed by someone who does actually use that
platform? 

The argument that leaving such functionality in place will encourage
users to use it seems somethwat flawed. This functionality is only
available if your running on that platform and if your already running
on that platform, encouragement to run on that platform doesn't amount
to much. I would also suggest far more enrouagement comes from having
support to build Emacs on that platform in the first place. 

It is also possible that having this support means users can actually
use Emacs to perform some tasks which would otherwise require closed
proprietary solutions or which would be easier to do with close
properietary solutions. Maybe this support actually enrouages users to
use Emacs instead of a non-free editor which has applescript support?
 



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-25  2:58   ` ns-do-applescript Tim Cross
@ 2022-05-25  4:46     ` Po Lu
  2022-05-25 10:05       ` ns-do-applescript Filipp Gunbin
  2022-05-25 11:42       ` ns-do-applescript Pankaj Jangid
  0 siblings, 2 replies; 36+ messages in thread
From: Po Lu @ 2022-05-25  4:46 UTC (permalink / raw)
  To: Tim Cross; +Cc: emacs-devel

Tim Cross <theophilusx@gmail.com> writes:

> This might be a reaonable argument when considering adding additional
> support/integration, but falls short when referencing work which ahs
> already been completed and has been part of Emacs for some time. 

If such a feature lands by mistake, our policy is to remove it until it
is also available on a free system.  That has happened many times, most
recently with "tabbed windows" and color fonts on macOS.

> Perhaps then your not the right person to address those bugs? Perhaps
> they need to be addressed by someone who does actually use that
> platform? 

Unfortunately, the "someone who does actually use that platform"
recently quit.

> The argument that leaving such functionality in place will encourage
> users to use it seems somethwat flawed. This functionality is only
> available if your running on that platform and if your already running
> on that platform, encouragement to run on that platform doesn't amount
> to much. I would also suggest far more enrouagement comes from having
> support to build Emacs on that platform in the first place. 
>
> It is also possible that having this support means users can actually
> use Emacs to perform some tasks which would otherwise require closed
> proprietary solutions or which would be easier to do with close
> properietary solutions. Maybe this support actually enrouages users to
> use Emacs instead of a non-free editor which has applescript support?

That horse is already dead, and this is neither the place nor the time
to beat it.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-25  4:46     ` ns-do-applescript Po Lu
@ 2022-05-25 10:05       ` Filipp Gunbin
  2022-05-25 11:42       ` ns-do-applescript Pankaj Jangid
  1 sibling, 0 replies; 36+ messages in thread
From: Filipp Gunbin @ 2022-05-25 10:05 UTC (permalink / raw)
  To: Po Lu; +Cc: Tim Cross, emacs-devel

On 25/05/2022 12:46 +0800, Po Lu wrote:

> Tim Cross <theophilusx@gmail.com> writes:
>
>> This might be a reaonable argument when considering adding additional
>> support/integration, but falls short when referencing work which ahs
>> already been completed and has been part of Emacs for some time. 
>
> If such a feature lands by mistake, our policy is to remove it until it
> is also available on a free system.  That has happened many times, most
> recently with "tabbed windows" and color fonts on macOS.

But here it's not a user-level editor feature, it's an API for
interoperability with host OS.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-25  4:46     ` ns-do-applescript Po Lu
  2022-05-25 10:05       ` ns-do-applescript Filipp Gunbin
@ 2022-05-25 11:42       ` Pankaj Jangid
  1 sibling, 0 replies; 36+ messages in thread
From: Pankaj Jangid @ 2022-05-25 11:42 UTC (permalink / raw)
  To: emacs-devel

Po Lu <luangruo@yahoo.com> writes:

> If such a feature lands by mistake, our policy is to remove it until it
> is also available on a free system.  That has happened many times, most
> recently with "tabbed windows" and color fonts on macOS.

There is one more feature that is available on MacOS but not available
for GNU/Linux users.

The feature is EUDC’s support for Mac OS’s address book. Other backends
supported by EUDC are - bbdb and LDAP. bbdb is Emacs specific address
book but it is not shipped with Emacs and LDAP is too much of a
configuration for a Desktop user.




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-25  0:50       ` ns-do-applescript Po Lu
@ 2022-05-25 12:09         ` Alexander Adolf
  0 siblings, 0 replies; 36+ messages in thread
From: Alexander Adolf @ 2022-05-25 12:09 UTC (permalink / raw)
  To: Po Lu, Richard Stallman; +Cc: Filipp Gunbin, emacs-devel

Hello,

this is the author of eudcb-macos-contacts chiming in. I would not have
any objections to a well managed deprecation, and later removal of the
ns-do-applescript elisp API. The semantics of that API, and the
command-line replacement osascript are very similar: provide the script
in a string, feed that to the API or process, and then handle whatever
that returns. I do hence think making the change should be a
straightforward exercise for any package author.

One aspect that has not been touched on in this thread is performance.
Starting an external process will typically be more expensive than
calling a C API, and thus there could be a noticeable performance
penalty for small scripts which are called often. But that's not the
case for eudcb-macos-contacts.


Hoping to have helped,

  --alexander



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-24 20:11         ` ns-do-applescript Stefan Monnier
@ 2022-05-25 13:57           ` Howard Melman
  2022-05-26  8:27             ` ns-do-applescript Richard Stallman
  0 siblings, 1 reply; 36+ messages in thread
From: Howard Melman @ 2022-05-25 13:57 UTC (permalink / raw)
  To: emacs-devel


Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Daniel Martín [2022-05-24 22:00:12] wrote:
>> I don't object delegating to osascript as a subprocess, but there are
>> probably lots of packages and user customizations already calling
>> ns-do-applescript.  We should deprecate the API before removing it, and
>> the deprecation message should tell people how they can call osascript
>> in an equivalent way.
>
> Can we re-implement `ns-do-applescript` as an ELisp function that runs
> `osascript`?

I do use it for simple interaction with the Finder and Safari such as:

    (do-applescript "tell application \"Safari\" to get the name of window 1")
    (do-applescript "tell application \"Safari\" to get the URL of document 1")

Part of the value of do-applescript is that it returns the
output as a string.  Quickly playing with call-process and
osascript isn't quite as trivial but I'm sure is doable.

-- 

Howard




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-24  0:26     ` ns-do-applescript Po Lu
  2022-05-24 20:00       ` ns-do-applescript Daniel Martín
@ 2022-05-26  8:24       ` Richard Stallman
  2022-05-26  8:49         ` ns-do-applescript Po Lu
  1 sibling, 1 reply; 36+ messages in thread
From: Richard Stallman @ 2022-05-26  8:24 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Does anyone object to its removal?

In principle, it is good to remove it, but there is no principled reason
why we must remove it, if that means breaking a user-level feature
that does work on non-MacOS systems.

It is good to look for alternative wasy to implement those features
on MacOS.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-25 13:57           ` ns-do-applescript Howard Melman
@ 2022-05-26  8:27             ` Richard Stallman
  2022-05-26 14:03               ` ns-do-applescript Howard Melman
  0 siblings, 1 reply; 36+ messages in thread
From: Richard Stallman @ 2022-05-26  8:27 UTC (permalink / raw)
  To: Howard Melman; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I do use it for simple interaction with the Finder and Safari such as:

  >     (do-applescript "tell application \"Safari\" to get the name of window 1")
  >     (do-applescript "tell application \"Safari\" to get the URL of document 1")

Is it possible to do this with call-process
or by running a shell command?


-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-26  8:24       ` ns-do-applescript Richard Stallman
@ 2022-05-26  8:49         ` Po Lu
  2022-05-27 22:49           ` ns-do-applescript Richard Stallman
  0 siblings, 1 reply; 36+ messages in thread
From: Po Lu @ 2022-05-26  8:49 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> In principle, it is good to remove it, but there is no principled reason
> why we must remove it, if that means breaking a user-level feature
> that does work on non-MacOS systems.
>
> It is good to look for alternative wasy to implement those features
> on MacOS.

It should be easy to use the `osascript' binary instead.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re: ns-do-applescript
@ 2022-05-26 11:01 Pedro Andres Aranda Gutierrez
  2022-05-26 14:07 ` ns-do-applescript Howard Melman
  2022-05-26 15:07 ` ns-do-applescript Stefan Monnier
  0 siblings, 2 replies; 36+ messages in thread
From: Pedro Andres Aranda Gutierrez @ 2022-05-26 11:01 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]

> Message: 18
> Date: Tue, 24 May 2022 16:11:00 -0400
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> To: Daniel Martín <mardani29@yahoo.es>
> Cc: Po Lu <luangruo@yahoo.com>,  emacs-devel@gnu.org
> Subject: Re: ns-do-applescript
> Message-ID: <jwv7d6an136.fsf-monnier+emacs@gnu.org>
> Content-Type: text/plain; charset=iso-8859-1

> Daniel Martín [2022-05-24 22:00:12] wrote:
> >  I don't object delegating to osascript as a subprocess, but there are
> > probably lots of packages and user customizations already calling
> > ns-do-applescript.  We should deprecate the API before removing it, and
> > the deprecation message should tell people how they can call osascript
> > in an equivalent way.

> Can we re-implement `ns-do-applescript` as an ELisp function that runs
`osascript`?
>
>
>       Stefan

hi

you mean something like:
;; (ns-do-applescript "tell application \"Emacs\" to activate"))
 (call-process "osascript" nil nil nil "-e" "tell application \"Emacs\" to
activate")

Isn't it easier to explain than to actually write a function? ;-)

Best, /PA
-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet

[-- Attachment #2: Type: text/html, Size: 2766 bytes --]

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-26  8:27             ` ns-do-applescript Richard Stallman
@ 2022-05-26 14:03               ` Howard Melman
  2022-05-26 14:17                 ` ns-do-applescript Andreas Schwab
  0 siblings, 1 reply; 36+ messages in thread
From: Howard Melman @ 2022-05-26 14:03 UTC (permalink / raw)
  To: emacs-devel


Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > I do use it for simple interaction with the Finder and Safari such as:
>
>   >     (do-applescript "tell application \"Safari\" to get the name of window 1")
>   >     (do-applescript "tell application \"Safari\" to get the URL of document 1")
>
> Is it possible to do this with call-process
> or by running a shell command?

I think so, though I have to figure out the right
incantation to get stdout returned as a string.  I might be
nice if call-process' DESTINATION arg had an option for this.

-- 

Howard




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-26 11:01 Re: ns-do-applescript Pedro Andres Aranda Gutierrez
@ 2022-05-26 14:07 ` Howard Melman
  2022-05-26 15:07 ` ns-do-applescript Stefan Monnier
  1 sibling, 0 replies; 36+ messages in thread
From: Howard Melman @ 2022-05-26 14:07 UTC (permalink / raw)
  To: emacs-devel

Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:

>> Can we re-implement `ns-do-applescript` as an ELisp function that runs
>> `osascript`?
>
> you mean something like:
> ;; (ns-do-applescript "tell application \"Emacs\" to activate"))
>  (call-process "osascript" nil nil nil "-e" "tell application \"Emacs\" to activate")
>
> Isn't it easier to explain than to actually write a function? ;-)

And the return value that ns-do-applescript handles?

-- 

Howard




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-26 14:03               ` ns-do-applescript Howard Melman
@ 2022-05-26 14:17                 ` Andreas Schwab
  2022-05-26 14:51                   ` ns-do-applescript Howard Melman
  0 siblings, 1 reply; 36+ messages in thread
From: Andreas Schwab @ 2022-05-26 14:17 UTC (permalink / raw)
  To: Howard Melman; +Cc: emacs-devel

On Mai 26 2022, Howard Melman wrote:

> I think so, though I have to figure out the right
> incantation to get stdout returned as a string.  I might be
> nice if call-process' DESTINATION arg had an option for this.

See shell-command-to-string for how to do that.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-26 14:17                 ` ns-do-applescript Andreas Schwab
@ 2022-05-26 14:51                   ` Howard Melman
  2022-05-26 15:36                     ` ns-do-applescript Andreas Schwab
  0 siblings, 1 reply; 36+ messages in thread
From: Howard Melman @ 2022-05-26 14:51 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: emacs-devel

On May 26, 2022, at 10:17 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> 
> On Mai 26 2022, Howard Melman wrote:
> 
>> I think so, though I have to figure out the right
>> incantation to get stdout returned as a string.  I might be
>> nice if call-process' DESTINATION arg had an option for this.
> 
> See shell-command-to-string for how to do that.

More useful would be a pointer to an example using call-process.

Howard



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-26 11:01 Re: ns-do-applescript Pedro Andres Aranda Gutierrez
  2022-05-26 14:07 ` ns-do-applescript Howard Melman
@ 2022-05-26 15:07 ` Stefan Monnier
  2022-05-27  9:40   ` ns-do-applescript Pedro Andres Aranda Gutierrez
  1 sibling, 1 reply; 36+ messages in thread
From: Stefan Monnier @ 2022-05-26 15:07 UTC (permalink / raw)
  To: Pedro Andres Aranda Gutierrez; +Cc: emacs-devel

> Isn't it easier to explain than to actually write a function? ;-)

I thought it was obvious that my question was in relation to avoid
breaking compatibility with potential user code out there.


        Stefan




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-26 14:51                   ` ns-do-applescript Howard Melman
@ 2022-05-26 15:36                     ` Andreas Schwab
  0 siblings, 0 replies; 36+ messages in thread
From: Andreas Schwab @ 2022-05-26 15:36 UTC (permalink / raw)
  To: Howard Melman; +Cc: emacs-devel

On Mai 26 2022, Howard Melman wrote:

> On May 26, 2022, at 10:17 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>> 
>> On Mai 26 2022, Howard Melman wrote:
>> 
>>> I think so, though I have to figure out the right
>>> incantation to get stdout returned as a string.  I might be
>>> nice if call-process' DESTINATION arg had an option for this.
>> 
>> See shell-command-to-string for how to do that.
>
> More useful would be a pointer to an example using call-process.

That's what shell-command is using, with the same meaning for the output
buffer.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-26 15:07 ` ns-do-applescript Stefan Monnier
@ 2022-05-27  9:40   ` Pedro Andres Aranda Gutierrez
  0 siblings, 0 replies; 36+ messages in thread
From: Pedro Andres Aranda Gutierrez @ 2022-05-27  9:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 837 bytes --]

You are absolutely right...  maybe I was reading too fast :-) ... and
egocentric
in the sense that yes I used it, but hey I could live without
ns-do-applescript.
You are right in that there may be code out there which may benefit from
and an elisp implementation...

Best, /PA

On Thu, 26 May 2022 at 17:07, Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> > Isn't it easier to explain than to actually write a function? ;-)
>
> I thought it was obvious that my question was in relation to avoid
> breaking compatibility with potential user code out there.
>
>
>         Stefan
>
>

-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet

[-- Attachment #2: Type: text/html, Size: 1420 bytes --]

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-26  8:49         ` ns-do-applescript Po Lu
@ 2022-05-27 22:49           ` Richard Stallman
  2022-05-28  0:43             ` ns-do-applescript Po Lu
  0 siblings, 1 reply; 36+ messages in thread
From: Richard Stallman @ 2022-05-27 22:49 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > It should be easy to use the `osascript' binary instead.

I have never heard of "osascript".  What is that?  What systems
support it?  Does it exist on GNU/Linux?

Basically, what are the differences that make it better to use
osascript than applescript?

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-27 22:49           ` ns-do-applescript Richard Stallman
@ 2022-05-28  0:43             ` Po Lu
  2022-05-29 21:21               ` ns-do-applescript Richard Stallman
  0 siblings, 1 reply; 36+ messages in thread
From: Po Lu @ 2022-05-28  0:43 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> I have never heard of "osascript".  What is that?  What systems
> support it?  Does it exist on GNU/Linux?

It's only present in macOS.

> Basically, what are the differences that make it better to use
> osascript than applescript?

I think that binary _is_ Apple's proprietary AppleScript interpreter,
but using it in a subprocess to retrieve only contacts data (which is
already possible on free systems) must be more acceptable than Emacs
including a C primitive to do the same thing.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-28  0:43             ` ns-do-applescript Po Lu
@ 2022-05-29 21:21               ` Richard Stallman
  2022-05-29 23:56                 ` ns-do-applescript Po Lu
  0 siblings, 1 reply; 36+ messages in thread
From: Richard Stallman @ 2022-05-29 21:21 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > Basically, what are the differences that make it better to use
  > > osascript than applescript?

  > I think that binary _is_ Apple's proprietary AppleScript interpreter,

If that is so, what is the significant difference between invoking
osascript and invoking applescript?  Those of us who don't use MacOS
know nothing about this.

  > but using it in a subprocess to retrieve only contacts data (which is
  > already possible on free systems) must be more acceptable than Emacs
  > including a C primitive to do the same thing.

Not necessarily -- it depends on facts that haven't been stated here.
Maybe a C primitive is better, but that depends on what exactly
the C primitive can do.

Since retrieving contact data in Emacs is supported on free systems,
adding code to do the same job on MacOS is ok in principle.  An
implementation which implements only that particular feature poses no
special problem.  Implementing something more general than that might
pose a problem.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-29 21:21               ` ns-do-applescript Richard Stallman
@ 2022-05-29 23:56                 ` Po Lu
  2022-05-31 19:05                   ` ns-do-applescript chad
  0 siblings, 1 reply; 36+ messages in thread
From: Po Lu @ 2022-05-29 23:56 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> If that is so, what is the significant difference between invoking
> osascript and invoking applescript?  Those of us who don't use MacOS
> know nothing about this.

osascript isn't linked into Emacs.

>   > but using it in a subprocess to retrieve only contacts data (which is
>   > already possible on free systems) must be more acceptable than Emacs
>   > including a C primitive to do the same thing.
>
> Not necessarily -- it depends on facts that haven't been stated here.
> Maybe a C primitive is better, but that depends on what exactly
> the C primitive can do.
>
> Since retrieving contact data in Emacs is supported on free systems,
> adding code to do the same job on MacOS is ok in principle.  An
> implementation which implements only that particular feature poses no
> special problem.  Implementing something more general than that might
> pose a problem.

The C primitive allows evaluating arbitrary AppleScript code, not just
extracting contacts data.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-29 23:56                 ` ns-do-applescript Po Lu
@ 2022-05-31 19:05                   ` chad
  2022-06-01  0:35                     ` ns-do-applescript Po Lu
  2022-06-01 22:57                     ` ns-do-applescript Richard Stallman
  0 siblings, 2 replies; 36+ messages in thread
From: chad @ 2022-05-31 19:05 UTC (permalink / raw)
  To: Richard Stallman; +Cc: EMACS development team, Po Lu

[-- Attachment #1: Type: text/plain, Size: 3407 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 3820 bytes --]

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-31  6:34 ns-do-applescript Pedro Andres Aranda Gutierrez
@ 2022-05-31 23:08 ` Stefan Monnier
  0 siblings, 0 replies; 36+ messages in thread
From: Stefan Monnier @ 2022-05-31 23:08 UTC (permalink / raw)
  To: Pedro Andres Aranda Gutierrez; +Cc: emacs-devel, Po Lu

> <flagelante>
> Yes, I repent, I confess... I use Emacs on a macOS...
> </flagelante>

I know this discussion sounds like some of us want to punish macOS users
for their sins, but that's not what this is about.  From the FSF's point
of view, using a proprietary system like Windows or macOS is causing
self-harm rather than harm to others (to some extent it might also harm
others because of the network effect, but that's a secondary concern).


        Stefan




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-31 19:05                   ` ns-do-applescript chad
@ 2022-06-01  0:35                     ` Po Lu
  2022-06-01  1:10                       ` ns-do-applescript Stefan Monnier
  2022-06-01 22:57                     ` ns-do-applescript Richard Stallman
  1 sibling, 1 reply; 36+ messages in thread
From: Po Lu @ 2022-06-01  0:35 UTC (permalink / raw)
  To: chad; +Cc: Richard Stallman, EMACS development team

chad <yandros@gmail.com> writes:

> 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.

From my POV, it is easily replaced by running `osascript' in a
subprocess, and the features provided by the so-called "native
application support" are not available on free operating systems.  It
also comes with various disadvantages, such as quitting being disabled
while the script is running, which isn't the case inside subprocesses.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-06-01  0:35                     ` ns-do-applescript Po Lu
@ 2022-06-01  1:10                       ` Stefan Monnier
  0 siblings, 0 replies; 36+ messages in thread
From: Stefan Monnier @ 2022-06-01  1:10 UTC (permalink / raw)
  To: Po Lu; +Cc: chad, Richard Stallman, EMACS development team

> From my POV, it is easily replaced by running `osascript' in a
> subprocess,

Is it?


        Stefan "who asked already but hasn't seen an answer yet"




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: ns-do-applescript
  2022-05-31 19:05                   ` ns-do-applescript chad
  2022-06-01  0:35                     ` ns-do-applescript Po Lu
@ 2022-06-01 22:57                     ` Richard Stallman
  1 sibling, 0 replies; 36+ messages in thread
From: Richard Stallman @ 2022-06-01 22:57 UTC (permalink / raw)
  To: chad; +Cc: emacs-devel, luangruo

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > 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/.

Sorry, I can't follow that.  I know nothing about Applescript except 
what little I've learned from this conversation.

I'd rather not learn enough about Applescript to be able to judge
whether using it is ok.  I hope that others will understand our
general criteria, and the specific facts of these issues, enough
to be able to make a thoughtful decision about them.

One possible approach would be to delete the Lisp-level interface to
run Appescript code, and add C-level support for doing certain
system-independent tasks by invoking Applescript.  I am not saying
that is the one and only right approach, or that it is the best
approach.  Only that it is one more to consider.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2022-06-01 22:57 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-26 11:01 Re: ns-do-applescript Pedro Andres Aranda Gutierrez
2022-05-26 14:07 ` ns-do-applescript Howard Melman
2022-05-26 15:07 ` ns-do-applescript Stefan Monnier
2022-05-27  9:40   ` ns-do-applescript Pedro Andres Aranda Gutierrez
  -- strict thread matches above, loose matches on Subject: below --
2022-05-31  6:34 ns-do-applescript Pedro Andres Aranda Gutierrez
2022-05-31 23:08 ` ns-do-applescript Stefan Monnier
2022-05-24 21:21 ns-do-applescript Jon Snader
2022-05-25  2:28 ` ns-do-applescript Po Lu
2022-05-25  2:58   ` ns-do-applescript Tim Cross
2022-05-25  4:46     ` ns-do-applescript Po Lu
2022-05-25 10:05       ` ns-do-applescript Filipp Gunbin
2022-05-25 11:42       ` ns-do-applescript Pankaj Jangid
     [not found] <87bkvoo38y.fsf.ref@yahoo.com>
2022-05-23 12:14 ` ns-do-applescript Po Lu
2022-05-23 20:44   ` ns-do-applescript Filipp Gunbin
2022-05-24  0:26     ` ns-do-applescript Po Lu
2022-05-24 20:00       ` ns-do-applescript Daniel Martín
2022-05-24 20:11         ` ns-do-applescript Stefan Monnier
2022-05-25 13:57           ` ns-do-applescript Howard Melman
2022-05-26  8:27             ` ns-do-applescript Richard Stallman
2022-05-26 14:03               ` ns-do-applescript Howard Melman
2022-05-26 14:17                 ` ns-do-applescript Andreas Schwab
2022-05-26 14:51                   ` ns-do-applescript Howard Melman
2022-05-26 15:36                     ` ns-do-applescript Andreas Schwab
2022-05-26  8:24       ` ns-do-applescript Richard Stallman
2022-05-26  8:49         ` ns-do-applescript Po Lu
2022-05-27 22:49           ` ns-do-applescript Richard Stallman
2022-05-28  0:43             ` ns-do-applescript Po Lu
2022-05-29 21:21               ` ns-do-applescript Richard Stallman
2022-05-29 23:56                 ` ns-do-applescript Po Lu
2022-05-31 19:05                   ` ns-do-applescript chad
2022-06-01  0:35                     ` ns-do-applescript Po Lu
2022-06-01  1:10                       ` ns-do-applescript Stefan Monnier
2022-06-01 22:57                     ` ns-do-applescript Richard Stallman
2022-05-24 21:26     ` ns-do-applescript Richard Stallman
2022-05-24 23:01       ` ns-do-applescript Filipp Gunbin
2022-05-25  0:50       ` ns-do-applescript Po Lu
2022-05-25 12:09         ` ns-do-applescript Alexander Adolf

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).