homebrew-emacs-plus icon indicating copy to clipboard operation
homebrew-emacs-plus copied to clipboard

Enable org-protocol support out of the box

Open jkp opened this issue 4 years ago • 8 comments

It would be great to have the org-protocol URL handler registered out of the box to enable org-capture to work.

This is supported by another mac-friendly port: emacs-mac or by installing a dedicated utility however the last method seems to be broken on newer versions of the OS.

I saw that this was mentioned in #158 but I thought it would be worth adding a dedicated feature request here to track progress independently of fixing that issue.

jkp avatar Dec 17 '20 08:12 jkp

Any progress to this issue?

kickingvegas avatar Apr 26 '23 00:04 kickingvegas

@kickingvegas I have not worked on this feature. PRs are welcome :)

d12frosted avatar Apr 28 '23 08:04 d12frosted

@d12frosted - How about this counter-proposal - I’d be happy to pair code this PR with you! I’m asking because I’m really not well setup to build Emacs plus for Homebrew. Looking at the two 28.2 repos, it seems like the chief differences are in two files:

  • org-protocol.el
  • Info.plist.in

Repos

diff of emacs-mac/lisp/org/org-protocol.el with emacs-28.2/lisp/org/org-protocol.el

631c631
< (defun org-protocol-check-filename-for-protocol (fname restoffiles client)
---
> (defun org-protocol-check-filename-for-protocol (fname restoffiles _client)
672,675c672
< 		  ;; Emacs Mac port directly handles `org-protocol'
< 		  ;; URLs without the help of external commands or
< 		  ;; apps.  In this case, `client' is set to nil.
<                   (when (and client (plist-get (cdr prolist) :kill-client))
---
>                   (when (plist-get (cdr prolist) :kill-client)

The emacs-mac port makes extensive changes to the Info.plist.in file which is used to generate the Info.plist that is put in app bundle. That said I think the most significant difference with respect to Org Protocol support is adding org-protocol to the CFBundleURLTypes key as shown below.

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLName</key>
    <string>Email Address URL</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>mailto</string>
    </array>
  </dict>
  <dict>
    <key>CFBundleURLName</key>
    <string>Org Protocol URL</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>org-protocol</string>
    </array>
  </dict>
</array>

kickingvegas avatar May 04 '23 05:05 kickingvegas

Any progress on this? If this hasn't just been incorporated silently into master and not referenced in the issue, then I can make the PR

yaqubroli avatar Jul 12 '23 18:07 yaqubroli

My bad. It slipped out of my head. @kickingvegas I will review your comment after I return home and get access to my laptop.

d12frosted avatar Aug 02 '23 07:08 d12frosted

Is there any update on this? Thanks.

maikol-solis avatar Mar 27 '24 10:03 maikol-solis

@maikol-solis there are no updates; I would really apreciate someone just figuring out how to solve this and sending a PR.

d12frosted avatar Mar 31 '24 09:03 d12frosted

Found the commit that introduced org-protocol support in the Mitsuharu fork: 0d4110bb05f080a3f4f07ae9338d4d61b4d29c16

Affected files afaik:

lisp/org/org-protocol.el
lisp/term/mac-win.el
mac/templates/Info.plist.in

The function mac-ae-get-url is what handles a passed URL to the Emacs Mac App from an external app.

commit 0d4110bb05f080a3f4f07ae9338d4d61b4d29c16
Author: YAMAMOTO Mitsuharu <[email protected]>
Date:   Thu Jan 29 12:59:45 2015 +0900

    * emacs-24.4-mac-5.3 (2015-01-29)

    Blend-and-blur of background color on OS X 10.10 is temporarily
    disabled to avoid mode-line erasure on frame focus switch.  For some
    reason, mode-line row's `enabled_p' flag in the current matrix is
    sometimes reset even if it is visible.  This causes blank mode-line on
    "expose" (drawRect:) events.  In principle, this mode-line erasure can
    also happen on older versions of OS X or this version of Emacs Mac
    port.  But it is usually observed on OS X 10.10 together with previous
    5.x versions of Emacs Mac port, because the use of NSVisualEffectView,
    which provides the blend-and-blur feature, triggers full frame
    "exposure" on focus switch.

    ** Fixed bugs

    *** Special-display completion frame becomes transparent.
    Reported by Alan Shumitt.
    Adapt a fix for Bug#16619.

    *** `mac-auto-ascii-mode' on TTY terminals disables prefix keys with
    the meta key.

    *** Control-F2 is passed to the system even if
    mac-pass-control-to-system is set to nil.

    *** Synthetic bold text looks thinner on Retina display/HiDPI mode.
    This is because stroke line width for text drawing is not correctly
    scaled (whereas it is correctly scaled when drawn to bitmaps) on such
    environments.  I've been reporting this to Apple on every OS X update
    since it was 10.7.4, but I couldn't get any response until recently.
    At last Apple answers that there are no plans to address this issue
    (rdar://11644870) currently.  So I added a workaround that would cause
    a bad reverse effect if the original issue were fixed.

    *** `mac-ae-set-reply-parameter', which is used for reporting an error
    in Apple event hander, has not been working since emacs-24.2-mac-3.2.

    *** Input source functions ignore disabled input source ID strings.

    ** Improvements

    *** URL handler via Apple events now accepts the `org-protocol' scheme
    as well as `mailto'.
  • Notes [2023-12-02 Sat 15:10]

Yantar92 posted this on IRC about Org-Protocol support in Core. Apparently it is very difficult to abstract this behavior away to support multi-platform.

#65469 - [PATCH] * etc/emacsclient.desktop: Make Emacs default application for org-protocol - GNU bug report logs

kickingvegas avatar Mar 31 '24 21:03 kickingvegas