Alien Top
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
xenodiumB to Emacs@communick.newsEnglish · 2 years ago

Emacs Swift module is wonderful for macOS native UX integrations

message-square
13
link
fedilink
4

Emacs Swift module is wonderful for macOS native UX integrations

xenodiumB to Emacs@communick.newsEnglish · 2 years ago
message-square
13
link
fedilink
alert-triangle
You must log in or register to comment.
  • xenodiumOPB
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 years ago

    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
    }
    
  • MamonimoniB
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 years ago

    Love it!

  • konrad1977B
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 years ago

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

    • xenodiumOPB
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 years 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?

Emacs@communick.news

emacs@communick.news

Subscribe from Remote Instance

You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !emacs@communick.news
lock
Community locked: only moderators can create posts. You can still comment on posts.

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

Get Emacs

  • Windows
  • Mac OS X
  • GNU/Linux and BSD (Just get it from your distribution’s package manager)

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 Wiki
  • WikEmacs
  • Emacs Reference (PDF)
  • Learning & Mastering Emacs
  • Weekly tips/tricks/etc threads

Emacs Tutorials

  • Beginner’s Guide to Emacs
  • Absolute Beginner’s Guide to Emacs
  • How to Learn Emacs: A Hand-drawn One-pager for Beginners

Useful Emacs configuration files and distributions

  • Better Defaults
  • Example configurations

Quick pain-saver tip

  • Put the Caps Lock key to better use!
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1 user / day
  • 1 user / week
  • 1 user / month
  • 25 users / 6 months
  • 8 local subscribers
  • 368 subscribers
  • 544 Posts
  • 2.31K Comments
  • Modlog
  • mods:
  • rglullis@communick.news
  • raphael@communick.news
  • BE: 0.19.11
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org