this post was submitted on 24 Nov 2023
3 points (100.0% liked)

Emacs

312 readers
3 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 
top 13 comments
sorted by: hot top controversial new old
[–] xenodium@alien.top 1 points 11 months ago (1 children)

A year ago, u/vsavchenko announced https://www.reddit.com/r/emacs/comments/wemj1z/writing_emacs_dynamic_modules_in_swift. I had been meaning to try it out for some time. Finally had the chance and it's really neat!

For example, most of the sharing logic from the experiment in the screen grab is below:

try env.defun(
  "macos-module--share",
  with: """
    Share files in ARG1.

    ARG1 must be a vector (not a list) of file paths.
    """
) { (env: Environment, files: [String]) in
  let urls = files.map { URL(fileURLWithPath: $0) }

  let picker = NSSharingServicePicker(items: urls)
  guard let view = NSApp.mainWindow?.contentView else {
    return
  }

  let x = try env.funcall("macos--emacs-point-x") as Int
  let y = try env.funcall("macos--emacs-point-y") as Int

  let rect = NSRect(
    x: x + 15, y: Int(view.bounds.height) - y + 15, width: 1, height: 1
  )
  picker.show(relativeTo: rect, of: view, preferredEdge: .maxY)

  return
}
[–] vsavchenko@alien.top 1 points 11 months ago (1 children)

Nice that you had a chance to try it. Would be amazing to hear your feedback and maybe some improvement ideas!

[–] xenodium@alien.top 1 points 11 months ago

So far, in the small experiments I've done, it's been fantastic. Thank you! You've also done a wonderful job with the documentation https://savchenkovaleriy.github.io/emacs-swift-module/documentation/emacsswiftmodule

I'll file issues if I run into any troubles.

Apart from https://github.com/roife/emt (which reminded me to look at your project), I haven't seen other integrations. I'd love to see what others are doing. What are you using it for?

So far, I'm replacing my previous implementations of reveal in finder (w/ selection) and sharing, with a snappy module implementation. Good times :)

Thanks again for the thorough work on it.

[–] Mamonimoni@alien.top 1 points 11 months ago
[–] Fit_Extent712@alien.top 1 points 11 months ago (1 children)
[–] xenodium@alien.top 1 points 11 months ago (2 children)
[–] Drone30389@alien.top 1 points 11 months ago (1 children)

I like that Nyan Cat line counter.

[–] xenodium@alien.top 1 points 11 months ago

It's been a solid companion for many years :)

[–] rowini30@alien.top 1 points 11 months ago (1 children)

Thanks for that write-up. Lots of interesting stuff there.

[–] xenodium@alien.top 1 points 11 months ago
[–] Psionikus@alien.top 1 points 11 months ago

Xenodium's Github repo for the dynamic module needs more stars and links so more people find it

I'll be collecting dynamic modules while deciding how to make a template for elisp repo kit (Rust).

[–] konrad1977@alien.top 1 points 11 months ago (1 children)

This is really nice, I totally missed that you can use swift code in a module. Thanks for sharing.

[–] xenodium@alien.top 1 points 11 months ago

I hope this post brings more visibility to u/vsavchenko’s https://github.com/SavchenkoValeriy/emacs-swift-module and spark more more integrations. u/divinedominion got ideas https://mastodon.social/@ctietze/111470001921901575 Maybe Maps https://xenodium.com/hey-emacs-where-did-i-take-that-photo?