GNU bug report logs - #58626
Proposed changes to implement opening URLs on macOS

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Perry Smith <pedzsan@HIDDEN>; Keywords: patch; dated Wed, 19 Oct 2022 11:07:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 58626 <at> debbugs.gnu.org:


Received: (at 58626) by debbugs.gnu.org; 23 Feb 2025 01:33:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 22 20:33:56 2025
Received: from localhost ([127.0.0.1]:58224 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tm0sW-0003Gq-08
	for submit <at> debbugs.gnu.org; Sat, 22 Feb 2025 20:33:56 -0500
Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:50428)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>)
 id 1tm0sT-0003GX-B8
 for 58626 <at> debbugs.gnu.org; Sat, 22 Feb 2025 20:33:54 -0500
Received: by mail-ed1-x534.google.com with SMTP id
 4fb4d7f45d1cf-5e04064af07so4593738a12.0
 for <58626 <at> debbugs.gnu.org>; Sat, 22 Feb 2025 17:33:53 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1740274427; x=1740879227; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date
 :mime-version:references:in-reply-to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=NY7Cj4AzdJD32C1C/1TZm2eyxZ4vaK0knnDe6ZrQmbw=;
 b=L1lyuK3z0Qa2cBU9vrYzVvtOu0RwWE3n+p+SetM7G+ys/Ld6JbX1GxB0kaVTWDjE2A
 nkfHgOnBc4+U85QZHKf/o7JmZ35JcUOQIAe2jqUWeCs7O9OMUn3ziNuaqsEU6VfqIdTO
 gb/cePcB43pluXUrBXdbVf9oxByndX8SgAiD52lEUuNa29P8JM56/+IKTmU2T45Ao5o+
 2q5NrlX3UhpZWt7JVK2dvYEBvU1fYBqIBCh6XGTzwDiJiuBBzH7BzR/3exwTENrp8kiw
 jsZg8wjWoj2Ww3eHuOVUW4Lcz2FOb3aJ1hwAPh98BVVcbmsB3dvwp+bPS1Yu+dJL4/X9
 Oh9Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1740274427; x=1740879227;
 h=content-transfer-encoding:cc:to:subject:message-id:date
 :mime-version:references:in-reply-to:from:x-gm-message-state:from:to
 :cc:subject:date:message-id:reply-to;
 bh=NY7Cj4AzdJD32C1C/1TZm2eyxZ4vaK0knnDe6ZrQmbw=;
 b=DhC5G6cy9vHUNy6N5JQEKD/wm+wHIcwQT6YmXjaBGDwGXv3WCVesf2rLbv6tYiYqsa
 d8y9KqK6jqsCFHrkLBzHvrPQzng8jXo6NP3BRyHWuajh6A5jcaCgTSjw97Xn1ImC1NSS
 z5jMzDYicsI9cLrAtkZiQKYruBSJ7QvjurhGJUffm/YbIxXQrkoO5ro4IgNxnE9AFdIs
 0QBznA9TLG/2Vv1QoKM9nNEFge1k1vjnCMh6TYRCGo+NaqnpNSnrcnRQrwoU1qpfyxoW
 +S4R2yzZMzJWOhjW18IIebZiSoEAaVrcnE1NjNitekDIXR5pvp73kOtc/o7KUMqwBMAF
 5RMw==
X-Gm-Message-State: AOJu0YyjgPPVgvAcGEP8xdnnP2Amlx6v+vRblXn9Jkg81XfXwkY+K/ig
 K8QZokCsoTiy+hy2ZA5t0XiUd1q4Um10uS36xczdl8eyCjl3pzTmu8neqa7z+UcwJyP6n9g37P7
 RYj0e97AqgYQ/MuTY30IO6kW62/4=
X-Gm-Gg: ASbGnctNlQHjPZQDJ8y53Mplz9PDFRjAlJO/C7oFpit/4bmW+L6mY/C1wp8RtmfzdQZ
 arj00iy0nrwF+GgY0UmcAUz1LD5vxadsO9LnLm/u5sSrf4aW8nVdJjUYcgb/Gv5+b6seBb+OQ/g
 eYjL/sXo+H
X-Google-Smtp-Source: AGHT+IE2TnduXV+V3LiLYSYiBYVbipPKFSZPV4mzq3EPHUMGB1C1wWN+CjSM0wtx9iryeHDhWZ8CLjpGOAqVVQlduGk=
X-Received: by 2002:a05:6402:1d4b:b0:5e0:36c0:7b00 with SMTP id
 4fb4d7f45d1cf-5e0b7257b92mr8335416a12.31.1740274426922; Sat, 22 Feb 2025
 17:33:46 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sun, 23 Feb 2025 01:33:46 +0000
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <0633A467-B560-456E-A096-81CCDA89B1BF@HIDDEN>
References: <378CF744-E39E-490C-9CFF-E65CB325BE25@HIDDEN>
 <CADwFkmmiQ5Guy1gzXQ+QNOVn8o6uq7vQWV55Vx36GZHgv7o2fA@HIDDEN>
 <0633A467-B560-456E-A096-81CCDA89B1BF@HIDDEN>
MIME-Version: 1.0
Date: Sun, 23 Feb 2025 01:33:46 +0000
X-Gm-Features: AWEUYZmXA2yp3Q3RyFCoV2KMZkzDGVTuETtWZk-_ZEJqgf-Q5LBTEX2DlzWCGVw
Message-ID: <CADwFkmk9SmfTrUqQXtT+NCtbNsEkp-OwvPN3v6Z9R_M-9+tJig@HIDDEN>
Subject: Re: bug#58626: Proposed changes to implement opening URLs on macOS
To: Perry Smith <pedzsan@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 58626
Cc: 58626 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Perry Smith <pedzsan@HIDDEN> writes:

>> On Nov 12, 2022, at 14:57, Stefan Kangas <stefankangas@HIDDEN> wrote:
>>
>> Perry Smith <pedzsan@HIDDEN> writes:
>>
>>> Attached is my patch file based upon the emacs-28.2 tar ball.  With
>>> these changes, I can do:
>>>
>>>    open emacs:///some/path/to/file.txt#25,40
>>
>> Could you send the patch in uncompressed instead?  That will simplify
>> reviewing it.
>
> Please let me know if this doesn=E2=80=99t work...
>
> Only in emacs-28.2-new: .DS_Store
> Only in emacs-28.2-new: What-I-Did.txt
> Only in emacs-28.2/admin/unidata: unidata-gen.elc
> Only in emacs-28.2/admin/unidata: unidata.txt
> Only in emacs-28.2/admin/unidata: uvs.elc
> Only in emacs-28.2-new/lib: sys
> Only in emacs-28.2-new/lib-src: ctags.dSYM
> Only in emacs-28.2-new/lib-src: ebrowse.dSYM
> Only in emacs-28.2-new/lib-src: emacsclient.dSYM
> Only in emacs-28.2-new/lib-src: etags.dSYM
> Only in emacs-28.2-new/lib-src: hexl.dSYM
> Only in emacs-28.2-new/lib-src: make-docfile.dSYM
> Only in emacs-28.2-new/lib-src: make-fingerprint.dSYM
> Only in emacs-28.2-new/lib-src: movemail.dSYM
> Only in emacs-28.2/lisp: loaddefs.el
> Only in emacs-28.2-new/lisp: loaddefs.el~
> diff -rc emacs-28.2/lisp/term/common-win.el emacs-28.2-new/lisp/term/comm=
on-win.el
> *** emacs-28.2/lisp/term/common-win.el 2022-09-06 16:31:54.000000000 -050=
0
> --- emacs-28.2-new/lisp/term/common-win.el 2022-10-16 07:53:34.000000000 =
-0500
> ***************
> *** 73,78 ****
> --- 73,79 ----
>         (cons 12 'ns-new-frame)
>         (cons 13 'ns-toggle-toolbar)
>         (cons 14 'ns-show-prefs)
> +       (cons 15 'ns-open-url)
>         ))))
>       (set-terminal-parameter frame 'x-setup-function-keys t)))
>   Binary files emacs-28.2/lisp/term/common-win.elc and emacs-28.2-new/lis=
p/term/common-win.elc differ
> diff -rc emacs-28.2/lisp/term/ns-win.el emacs-28.2-new/lisp/term/ns-win.e=
l
> *** emacs-28.2/lisp/term/ns-win.el 2022-09-06 16:31:54.000000000 -0500
> --- emacs-28.2-new/lisp/term/ns-win.el 2022-10-18 11:36:44.000000000 -050=
0
> ***************
> *** 182,187 ****
> --- 182,188 ----
>   (define-key global-map [ns-new-frame] 'make-frame)
>   (define-key global-map [ns-toggle-toolbar] 'ns-toggle-toolbar)
>   (define-key global-map [ns-show-prefs] 'customize)
> + (define-key global-map [ns-open-url] 'ns-open-url)
>       ;; Set up a number of aliases and other layers to pretend we're usi=
ng
> ***************
> *** 530,535 ****
> --- 531,578 ----
>     (global-set-key [drag-n-drop] 'ns-drag-n-drop)
>   + (defvar ns-input-url-scheme)            ; nsterm.m
> + (defvar ns-input-url-user)              ; nsterm.m
> + (defvar ns-input-url-password)          ; nsterm.m
> + (defvar ns-input-url-host)              ; nsterm.m
> + (defvar ns-input-url-port)              ; nsterm.m
> + (defvar ns-input-url-path)              ; nsterm.m
> + (defvar ns-input-url-query)             ; nsterm.m
> + (defvar ns-input-url-fragment)          ; nsterm.m
> +
> + (defun ns-open-url ()
> +   "Open a buffer as directed by the URL which has been broken down
> +   into components:
> +     `ns-input-url-scheme'   - the URL's scheme   (string)
> +     `ns-input-url-user'     - the URL's user     (string)
> +     `ns-input-url-password' - the URL's password (string)
> +     `ns-input-url-host'     - the URL's host     (string)
> +     `ns-input-url-port'     - the URL's port     (integer)
> +     `ns-input-url-path'     - the URL's path     (string)
> +     `ns-input-url-query'    - the URL's query    (string)
> +     `ns-input-url-fragment' - the URL's fragment (string)
> + "
> +   (interactive)
> +   (cond
> +    ((equal ns-input-url-scheme "file")
> +     (progn (setq ns-input-file (append (list ns-input-url-path)))
> +            (setq ns-input-line nil)     ; My testing on macOS 12.6 show=
s the fragment is never passed
> +            (ns-open-file-select-line)))
> +    ((equal ns-input-url-scheme "emacs")
> +     (progn (setq ns-input-file (append (list ns-input-url-path)))
> +            (setq ns-input-line
> +                  (and ns-input-url-fragment
> +                       (let ((seq (mapcar #'string-to-number (split-stri=
ng ns-input-url-fragment "[-,:]" t))))
> +                         (cond
> +                          ((=3D (length seq) 1) (car seq))
> +                          ((=3D (length seq) 2) (cons (car seq) (car (cd=
r seq))))))))
> +            (ns-open-file-select-line)))
> +    (t (message (format "scheme: %s; user: %s; password: %s; host: %s; p=
ort: %d; path: %s; query: %s; fragment: %s"
> +                        ns-input-url-scheme ns-input-url-user
> +                        ns-input-url-password ns-input-url-host
> +                        ns-input-url-port ns-input-url-path
> +                        ns-input-url-query ns-input-url-fragment)))))
> +
>   ;;;; Frame-related functions.
>     ;; nsterm.m
> Binary files emacs-28.2/lisp/term/ns-win.elc and emacs-28.2-new/lisp/term=
/ns-win.elc differ
> Only in emacs-28.2-new/nextstep: .DS_Store
> Only in emacs-28.2-new/nextstep/Cocoa/Emacs.base/Contents/Resources: Engl=
ish.lproj
> diff -rc emacs-28.2/nextstep/templates/Info.plist.in emacs-28.2-new/nexts=
tep/templates/Info.plist.in
> *** emacs-28.2/nextstep/templates/Info.plist.in 2022-09-06 16:31:54.00000=
0000 -0500
> --- emacs-28.2-new/nextstep/templates/Info.plist.in 2022-10-15 11:31:41.0=
00000000 -0500
> ***************
> *** 672,677 ****
> --- 672,687 ----
>   <string>mailto</string>
>   </array>
>   </dict>
> + <dict>
> + <key>CFBundleTypeRole</key>
> + <string>Editor</string>
> + <key>CFBundleURLName</key>
> + <string>Emacs Local Address URL</string>
> + <key>CFBundleURLSchemes</key>
> + <array>
> + <string>emacs</string>
> + </array>
> + </dict>
>   </array>
>   <key>NSAppleScriptEnabled</key>
>   <string>YES</string>
> Only in emacs-28.2-new/nextstep/templates: Info.plist.in-orig
> diff -rc emacs-28.2/src/nsterm.m emacs-28.2-new/src/nsterm.m
> *** emacs-28.2/src/nsterm.m 2022-09-06 16:31:54.000000000 -0500
> --- emacs-28.2-new/src/nsterm.m 2022-10-16 12:13:33.000000000 -0500
> ***************
> *** 292,298 ****
>   static struct input_event *q_event_ptr =3D NULL;
>   static int n_emacs_events_pending =3D 0;
>   static NSMutableArray *ns_pending_files, *ns_pending_service_names,
> !   *ns_pending_service_args;
>   static BOOL ns_do_open_file =3D NO;
>   static BOOL ns_last_use_native_fullscreen;
>   --- 292,298 ----
>   static struct input_event *q_event_ptr =3D NULL;
>   static int n_emacs_events_pending =3D 0;
>   static NSMutableArray *ns_pending_files, *ns_pending_service_names,
> !   *ns_pending_service_args, *ns_pending_urls;
>   static BOOL ns_do_open_file =3D NO;
>   static BOOL ns_last_use_native_fullscreen;
>   ***************
> *** 4361,4366 ****
> --- 4361,4372 ----
>             [ns_pending_service_names removeObjectAtIndex: 0];
>             [ns_pending_service_args removeObjectAtIndex: 0];
>           }
> +       /* Process the open URL requests */
> +       else if (ns_pending_urls && [ns_pending_urls count] !=3D 0
> +                && [(EmacsApp *) NSApp openURL: [ns_pending_urls objectA=
tIndex: 0]])
> +         {
> +             [ns_pending_urls removeObjectAtIndex: 0];
> +         }
>         else
>           {
>             /* Run and wait for events.  We must always send one NX_APPDE=
FINED event
> ***************
> *** 5123,5128 ****
> --- 5129,5135 ----
>     ns_pending_files =3D [[NSMutableArray alloc] init];
>     ns_pending_service_names =3D [[NSMutableArray alloc] init];
>     ns_pending_service_args =3D [[NSMutableArray alloc] init];
> +   ns_pending_urls =3D [[NSMutableArray alloc] init];
>       /* Start app and create the main menu, window, view.
>        Needs to be here because ns_initialize_display_info () uses AppKit=
 classes.
> ***************
> *** 5938,5943 ****
> --- 5945,6004 ----
>     /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
>   +     Open URL
> +
> +    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D */
> +
> + /* Open a URL after going into queue read by ns_read_socket.  */
> + - (BOOL) openURL: (NSURL *)url
> + {
> +   NSTRACE ("[EmacsApp openURL:]");
> +
> +   struct frame *emacsframe =3D SELECTED_FRAME ();
> +   NSEvent *theEvent =3D [NSApp currentEvent];
> +
> +   if (!emacs_event)
> +     return NO;
> +
> +   emacs_event->kind =3D NS_NONKEY_EVENT;
> +   emacs_event->code =3D KEY_NS_OPEN_URL;
> +   ns_input_url_scheme   =3D [[url scheme]   lispString];
> +   ns_input_url_user     =3D [[url user]     lispString];
> +   ns_input_url_password =3D [[url password] lispString];
> +   ns_input_url_host     =3D [[url host]     lispString];
> +   ns_input_url_port     =3D make_int([[url port] intValue]);
> +   ns_input_url_path     =3D [[url path]     lispString];
> +   ns_input_url_query    =3D [[url query]    lispString];
> +   ns_input_url_fragment =3D [[url fragment] lispString];
> +   EV_TRAILER (theEvent);
> +
> +   return YES;
> + }
> +
> + /* Notification from the Workspace to open a URL.  */
> + - (void)application: sender openURLs: (NSArray<NSURL *> *)urlList
> + {
> +   NSEnumerator *urls =3D [urlList objectEnumerator];
> +   NSURL *url;
> +
> +   NSTRACE ("[EmacsApp openURLs:]");
> +   while ((url =3D [urls nextObject]) !=3D nil)
> +     if (ns_do_open_file || not_in_argv ([url path])) {
> +       [ns_pending_urls addObject: url];
> +     }
> +
> +   /* The documentation says to do this for openFiles but it is not
> +    * mentioned in the openURLs doc so I'm going to leave it out for
> +    * now.
> +
> +   [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess];
> +    */
> +
> + }
> +
> +
> + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
> +
>       Service provision
>        =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D */
> ***************
> *** 7004,7010 ****
>     height =3D (int)NSHeight (frame);
>       NSTRACE_SIZE ("New size", NSMakeSize (width, height));
> !   NSTRACE_SIZE ("Original size", size);
>       /* Reset the frame size to match the bounds of the superview (the
>        NSWindow's contentView).  We need to do this as sometimes the
> --- 7065,7071 ----
>     height =3D (int)NSHeight (frame);
>       NSTRACE_SIZE ("New size", NSMakeSize (width, height));
> !   NSTRACE_SIZE ("Original size", oldSize);
>       /* Reset the frame size to match the bounds of the superview (the
>        NSWindow's contentView).  We need to do this as sometimes the
> ***************
> *** 9845,9850 ****
> --- 9906,9947 ----
>                 "The file specified in the last NS event.");
>     ns_input_file =3DQnil;
>   +   /* -- URL components */
> +
> +   DEFVAR_LISP ("ns-input-url-scheme", ns_input_url_scheme,
> +                "The scheme component of the URL specified in the last N=
S event.");
> +   ns_input_url_scheme =3DQnil;
> +
> +   DEFVAR_LISP ("ns-input-url-user", ns_input_url_user,
> +                "The user component of the URL specified in the last NS =
event.");
> +   ns_input_url_user =3DQnil;
> +
> +   DEFVAR_LISP ("ns-input-url-password", ns_input_url_password,
> +                "The password component of the URL specified in the last=
 NS event.");
> +   ns_input_url_password =3DQnil;
> +
> +   DEFVAR_LISP ("ns-input-url-host", ns_input_url_host,
> +                "The host component of the URL specified in the last NS =
event.");
> +   ns_input_url_host =3DQnil;
> +
> +   DEFVAR_LISP ("ns-input-url-port", ns_input_url_port,
> +                "The port component of the URL specified in the last NS =
event.");
> +   ns_input_url_port =3DQnil;
> +
> +   DEFVAR_LISP ("ns-input-url-path", ns_input_url_path,
> +                "The path component of the URL specified in the last NS =
event.");
> +   ns_input_url_path =3DQnil;
> +
> +   DEFVAR_LISP ("ns-input-url-query", ns_input_url_query,
> +                "The query component of the URL specified in the last NS=
 event.");
> +   ns_input_url_query =3DQnil;
> +
> +   DEFVAR_LISP ("ns-input-url-fragment", ns_input_url_fragment,
> +                "The fragment component of the URL specified in the last=
 NS event.");
> +   ns_input_url_fragment =3DQnil;
> +
> +   /* -- */
> +
>     DEFVAR_LISP ("ns-working-text", ns_working_text,
>                 "String for visualizing working composition sequence.");
>     ns_working_text =3DQnil;
> Only in emacs-28.2-new: trace

Sorry, but could you please resend this as formatted by

    git format-patch -1

?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#58626; Package emacs. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 58626 <at> debbugs.gnu.org:


Received: (at 58626) by debbugs.gnu.org; 13 Nov 2022 08:28:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 13 03:28:29 2022
Received: from localhost ([127.0.0.1]:50000 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ou8Lr-0002Xx-W6
	for submit <at> debbugs.gnu.org; Sun, 13 Nov 2022 03:28:28 -0500
Received: from ms11p00im-qufo17281301.me.com ([17.58.38.50]:57926)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pedzsan@HIDDEN>) id 1ou031-0001Ue-Oo
 for 58626 <at> debbugs.gnu.org; Sat, 12 Nov 2022 18:36:28 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com;
 s=1a1hai; t=1668296181;
 bh=4ZTGhhtrXAL1A1MC6dbZ+r8jt13XDJdX3fx8MWE8jS0=;
 h=Content-Type:Mime-Version:Subject:From:Date:Message-Id:To;
 b=C9VSrernR/5kuvzxvTBLu1bVGmWQgjb4yttEThYHqL/5/rgBisVp3ryFYLygovVtV
 3QVACGYjnG+MMfxnn6rjh4IAj7LZK+vzyacQQGcDFz2lNpAlYn2VzsCas768R99OYi
 f9CydrqesQaNBoawE8qoNaIxy3LzzBnoD5hwAPZZwUzXUa857egyTzD0v0InEIs/DL
 Ka9CpoGHaznEh2Hd1PkXlaK4wirr0wTUUIbQrLmshqq0/30HaR+Pw593Rl0ewlMfOw
 qNv45KDRsPH2sCsgyqsSuU0QTf6OFMvnUQvKD6/ax4m18H75QfzaWHWBlkmI56rNpL
 HCY+3AG7jCbOg==
Received: from smtpclient.apple (ms11p00im-dlb-asmtpmailmevip.me.com
 [17.57.154.19])
 by ms11p00im-qufo17281301.me.com (Postfix) with ESMTPSA id 963D7CC01A3;
 Sat, 12 Nov 2022 23:36:20 +0000 (UTC)
Content-Type: text/plain;
	charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.200.110.1.12\))
Subject: Re: bug#58626: Proposed changes to implement opening URLs on macOS
From: Perry Smith <pedzsan@HIDDEN>
In-Reply-To: <CADwFkmmiQ5Guy1gzXQ+QNOVn8o6uq7vQWV55Vx36GZHgv7o2fA@HIDDEN>
Date: Sat, 12 Nov 2022 17:36:07 -0600
Content-Transfer-Encoding: quoted-printable
Message-Id: <0633A467-B560-456E-A096-81CCDA89B1BF@HIDDEN>
References: <378CF744-E39E-490C-9CFF-E65CB325BE25@HIDDEN>
 <CADwFkmmiQ5Guy1gzXQ+QNOVn8o6uq7vQWV55Vx36GZHgv7o2fA@HIDDEN>
To: Stefan Kangas <stefankangas@HIDDEN>
X-Mailer: Apple Mail (2.3731.200.110.1.12)
X-Proofpoint-GUID: G7JTHRE4n6JZ3O24darzd8S2pAruOl5G
X-Proofpoint-ORIG-GUID: G7JTHRE4n6JZ3O24darzd8S2pAruOl5G
X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?=
 =?UTF-8?Q?2903e8d5c8f:6.0.138,18.0.572,17.0.605.474.0000000_definitions?=
 =?UTF-8?Q?=3D2020-02-14=5F11:2020-02-14=5F02,2020-02-14=5F11,2020-01-23?=
 =?UTF-8?Q?=5F02_signatures=3D0?=
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0
 mlxscore=0 adultscore=0
 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 clxscore=1011
 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1
 engine=8.12.0-2209130000 definitions=main-2211120168
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 58626
X-Mailman-Approved-At: Sun, 13 Nov 2022 03:28:26 -0500
Cc: 58626 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)



> On Nov 12, 2022, at 14:57, Stefan Kangas <stefankangas@HIDDEN> =
wrote:
>=20
> Perry Smith <pedzsan@HIDDEN> writes:
>=20
>> Attached is my patch file based upon the emacs-28.2 tar ball.  With
>> these changes, I can do:
>>=20
>>    open emacs:///some/path/to/file.txt#25,40
>=20
> Could you send the patch in uncompressed instead?  That will simplify
> reviewing it.

Please let me know if this doesn=E2=80=99t work...

Only in emacs-28.2-new: .DS_Store
Only in emacs-28.2-new: What-I-Did.txt
Only in emacs-28.2/admin/unidata: unidata-gen.elc
Only in emacs-28.2/admin/unidata: unidata.txt
Only in emacs-28.2/admin/unidata: uvs.elc
Only in emacs-28.2-new/lib: sys
Only in emacs-28.2-new/lib-src: ctags.dSYM
Only in emacs-28.2-new/lib-src: ebrowse.dSYM
Only in emacs-28.2-new/lib-src: emacsclient.dSYM
Only in emacs-28.2-new/lib-src: etags.dSYM
Only in emacs-28.2-new/lib-src: hexl.dSYM
Only in emacs-28.2-new/lib-src: make-docfile.dSYM
Only in emacs-28.2-new/lib-src: make-fingerprint.dSYM
Only in emacs-28.2-new/lib-src: movemail.dSYM
Only in emacs-28.2/lisp: loaddefs.el
Only in emacs-28.2-new/lisp: loaddefs.el~
diff -rc emacs-28.2/lisp/term/common-win.el =
emacs-28.2-new/lisp/term/common-win.el
*** emacs-28.2/lisp/term/common-win.el 2022-09-06 16:31:54.000000000 =
-0500
--- emacs-28.2-new/lisp/term/common-win.el 2022-10-16 07:53:34.000000000 =
-0500
***************
*** 73,78 ****
--- 73,79 ----
        (cons 12 'ns-new-frame)
        (cons 13 'ns-toggle-toolbar)
        (cons 14 'ns-show-prefs)
+       (cons 15 'ns-open-url)
        ))))
      (set-terminal-parameter frame 'x-setup-function-keys t)))
  Binary files emacs-28.2/lisp/term/common-win.elc and =
emacs-28.2-new/lisp/term/common-win.elc differ
diff -rc emacs-28.2/lisp/term/ns-win.el =
emacs-28.2-new/lisp/term/ns-win.el
*** emacs-28.2/lisp/term/ns-win.el 2022-09-06 16:31:54.000000000 -0500
--- emacs-28.2-new/lisp/term/ns-win.el 2022-10-18 11:36:44.000000000 =
-0500
***************
*** 182,187 ****
--- 182,188 ----
  (define-key global-map [ns-new-frame] 'make-frame)
  (define-key global-map [ns-toggle-toolbar] 'ns-toggle-toolbar)
  (define-key global-map [ns-show-prefs] 'customize)
+ (define-key global-map [ns-open-url] 'ns-open-url)
      ;; Set up a number of aliases and other layers to pretend we're =
using
***************
*** 530,535 ****
--- 531,578 ----
    (global-set-key [drag-n-drop] 'ns-drag-n-drop)
  + (defvar ns-input-url-scheme)            ; nsterm.m
+ (defvar ns-input-url-user)              ; nsterm.m
+ (defvar ns-input-url-password)          ; nsterm.m
+ (defvar ns-input-url-host)              ; nsterm.m
+ (defvar ns-input-url-port)              ; nsterm.m
+ (defvar ns-input-url-path)              ; nsterm.m
+ (defvar ns-input-url-query)             ; nsterm.m
+ (defvar ns-input-url-fragment)          ; nsterm.m
+=20
+ (defun ns-open-url ()
+   "Open a buffer as directed by the URL which has been broken down
+   into components:
+     `ns-input-url-scheme'   - the URL's scheme   (string)
+     `ns-input-url-user'     - the URL's user     (string)
+     `ns-input-url-password' - the URL's password (string)
+     `ns-input-url-host'     - the URL's host     (string)
+     `ns-input-url-port'     - the URL's port     (integer)
+     `ns-input-url-path'     - the URL's path     (string)
+     `ns-input-url-query'    - the URL's query    (string)
+     `ns-input-url-fragment' - the URL's fragment (string)
+ "
+   (interactive)
+   (cond
+    ((equal ns-input-url-scheme "file")
+     (progn (setq ns-input-file (append (list ns-input-url-path)))
+            (setq ns-input-line nil)     ; My testing on macOS 12.6 =
shows the fragment is never passed
+            (ns-open-file-select-line)))
+    ((equal ns-input-url-scheme "emacs")
+     (progn (setq ns-input-file (append (list ns-input-url-path)))
+            (setq ns-input-line
+                  (and ns-input-url-fragment
+                       (let ((seq (mapcar #'string-to-number =
(split-string ns-input-url-fragment "[-,:]" t))))
+                         (cond
+                          ((=3D (length seq) 1) (car seq))
+                          ((=3D (length seq) 2) (cons (car seq) (car =
(cdr seq))))))))
+            (ns-open-file-select-line)))
+    (t (message (format "scheme: %s; user: %s; password: %s; host: %s; =
port: %d; path: %s; query: %s; fragment: %s"
+                        ns-input-url-scheme ns-input-url-user
+                        ns-input-url-password ns-input-url-host
+                        ns-input-url-port ns-input-url-path
+                        ns-input-url-query ns-input-url-fragment)))))
+=20
  ;;;; Frame-related functions.
    ;; nsterm.m
Binary files emacs-28.2/lisp/term/ns-win.elc and =
emacs-28.2-new/lisp/term/ns-win.elc differ
Only in emacs-28.2-new/nextstep: .DS_Store
Only in emacs-28.2-new/nextstep/Cocoa/Emacs.base/Contents/Resources: =
English.lproj
diff -rc emacs-28.2/nextstep/templates/Info.plist.in =
emacs-28.2-new/nextstep/templates/Info.plist.in
*** emacs-28.2/nextstep/templates/Info.plist.in 2022-09-06 =
16:31:54.000000000 -0500
--- emacs-28.2-new/nextstep/templates/Info.plist.in 2022-10-15 =
11:31:41.000000000 -0500
***************
*** 672,677 ****
--- 672,687 ----
  <string>mailto</string>
  </array>
  </dict>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>CFBundleURLName</key>
+ <string>Emacs Local Address URL</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>emacs</string>
+ </array>
+ </dict>
  </array>
  <key>NSAppleScriptEnabled</key>
  <string>YES</string>
Only in emacs-28.2-new/nextstep/templates: Info.plist.in-orig
diff -rc emacs-28.2/src/nsterm.m emacs-28.2-new/src/nsterm.m
*** emacs-28.2/src/nsterm.m 2022-09-06 16:31:54.000000000 -0500
--- emacs-28.2-new/src/nsterm.m 2022-10-16 12:13:33.000000000 -0500
***************
*** 292,298 ****
  static struct input_event *q_event_ptr =3D NULL;
  static int n_emacs_events_pending =3D 0;
  static NSMutableArray *ns_pending_files, *ns_pending_service_names,
!   *ns_pending_service_args;
  static BOOL ns_do_open_file =3D NO;
  static BOOL ns_last_use_native_fullscreen;
  --- 292,298 ----
  static struct input_event *q_event_ptr =3D NULL;
  static int n_emacs_events_pending =3D 0;
  static NSMutableArray *ns_pending_files, *ns_pending_service_names,
!   *ns_pending_service_args, *ns_pending_urls;
  static BOOL ns_do_open_file =3D NO;
  static BOOL ns_last_use_native_fullscreen;
  ***************
*** 4361,4366 ****
--- 4361,4372 ----
            [ns_pending_service_names removeObjectAtIndex: 0];
            [ns_pending_service_args removeObjectAtIndex: 0];
          }
+       /* Process the open URL requests */
+       else if (ns_pending_urls && [ns_pending_urls count] !=3D 0
+                && [(EmacsApp *) NSApp openURL: [ns_pending_urls =
objectAtIndex: 0]])
+         {
+             [ns_pending_urls removeObjectAtIndex: 0];
+         }
        else
          {
            /* Run and wait for events.  We must always send one =
NX_APPDEFINED event
***************
*** 5123,5128 ****
--- 5129,5135 ----
    ns_pending_files =3D [[NSMutableArray alloc] init];
    ns_pending_service_names =3D [[NSMutableArray alloc] init];
    ns_pending_service_args =3D [[NSMutableArray alloc] init];
+   ns_pending_urls =3D [[NSMutableArray alloc] init];
      /* Start app and create the main menu, window, view.
       Needs to be here because ns_initialize_display_info () uses =
AppKit classes.
***************
*** 5938,5943 ****
--- 5945,6004 ----
    /* =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
  +     Open URL
+=20
+    =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =
*/
+=20
+ /* Open a URL after going into queue read by ns_read_socket.  */
+ - (BOOL) openURL: (NSURL *)url
+ {
+   NSTRACE ("[EmacsApp openURL:]");
+=20
+   struct frame *emacsframe =3D SELECTED_FRAME ();
+   NSEvent *theEvent =3D [NSApp currentEvent];
+=20
+   if (!emacs_event)
+     return NO;
+=20
+   emacs_event->kind =3D NS_NONKEY_EVENT;
+   emacs_event->code =3D KEY_NS_OPEN_URL;
+   ns_input_url_scheme   =3D [[url scheme]   lispString];
+   ns_input_url_user     =3D [[url user]     lispString];
+   ns_input_url_password =3D [[url password] lispString];
+   ns_input_url_host     =3D [[url host]     lispString];
+   ns_input_url_port     =3D make_int([[url port] intValue]);
+   ns_input_url_path     =3D [[url path]     lispString];
+   ns_input_url_query    =3D [[url query]    lispString];
+   ns_input_url_fragment =3D [[url fragment] lispString];
+   EV_TRAILER (theEvent);
+=20
+   return YES;
+ }
+=20
+ /* Notification from the Workspace to open a URL.  */
+ - (void)application: sender openURLs: (NSArray<NSURL *> *)urlList
+ {
+   NSEnumerator *urls =3D [urlList objectEnumerator];
+   NSURL *url;
+=20
+   NSTRACE ("[EmacsApp openURLs:]");
+   while ((url =3D [urls nextObject]) !=3D nil)
+     if (ns_do_open_file || not_in_argv ([url path])) {
+       [ns_pending_urls addObject: url];
+     }
+=20
+   /* The documentation says to do this for openFiles but it is not
+    * mentioned in the openURLs doc so I'm going to leave it out for
+    * now.
+   =20
+   [self replyToOpenOrPrint: NSApplicationDelegateReplySuccess];
+    */
+=20
+ }
+=20
+=20
+ /* =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
+=20
      Service provision
       =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =
*/
***************
*** 7004,7010 ****
    height =3D (int)NSHeight (frame);
      NSTRACE_SIZE ("New size", NSMakeSize (width, height));
!   NSTRACE_SIZE ("Original size", size);
      /* Reset the frame size to match the bounds of the superview (the
       NSWindow's contentView).  We need to do this as sometimes the
--- 7065,7071 ----
    height =3D (int)NSHeight (frame);
      NSTRACE_SIZE ("New size", NSMakeSize (width, height));
!   NSTRACE_SIZE ("Original size", oldSize);
      /* Reset the frame size to match the bounds of the superview (the
       NSWindow's contentView).  We need to do this as sometimes the
***************
*** 9845,9850 ****
--- 9906,9947 ----
                "The file specified in the last NS event.");
    ns_input_file =3DQnil;
  +   /* -- URL components */
+=20
+   DEFVAR_LISP ("ns-input-url-scheme", ns_input_url_scheme,
+                "The scheme component of the URL specified in the last =
NS event.");
+   ns_input_url_scheme =3DQnil;
+=20
+   DEFVAR_LISP ("ns-input-url-user", ns_input_url_user,
+                "The user component of the URL specified in the last NS =
event.");
+   ns_input_url_user =3DQnil;
+=20
+   DEFVAR_LISP ("ns-input-url-password", ns_input_url_password,
+                "The password component of the URL specified in the =
last NS event.");
+   ns_input_url_password =3DQnil;
+=20
+   DEFVAR_LISP ("ns-input-url-host", ns_input_url_host,
+                "The host component of the URL specified in the last NS =
event.");
+   ns_input_url_host =3DQnil;
+=20
+   DEFVAR_LISP ("ns-input-url-port", ns_input_url_port,
+                "The port component of the URL specified in the last NS =
event.");
+   ns_input_url_port =3DQnil;
+=20
+   DEFVAR_LISP ("ns-input-url-path", ns_input_url_path,
+                "The path component of the URL specified in the last NS =
event.");
+   ns_input_url_path =3DQnil;
+=20
+   DEFVAR_LISP ("ns-input-url-query", ns_input_url_query,
+                "The query component of the URL specified in the last =
NS event.");
+   ns_input_url_query =3DQnil;
+=20
+   DEFVAR_LISP ("ns-input-url-fragment", ns_input_url_fragment,
+                "The fragment component of the URL specified in the =
last NS event.");
+   ns_input_url_fragment =3DQnil;
+=20
+   /* -- */
+=20
    DEFVAR_LISP ("ns-working-text", ns_working_text,
                "String for visualizing working composition sequence.");
    ns_working_text =3DQnil;
Only in emacs-28.2-new: trace






Information forwarded to bug-gnu-emacs@HIDDEN:
bug#58626; Package emacs. Full text available.
Added tag(s) patch. Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 58626 <at> debbugs.gnu.org:


Received: (at 58626) by debbugs.gnu.org; 12 Nov 2022 20:57:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 12 15:57:46 2022
Received: from localhost ([127.0.0.1]:49320 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1otxZS-0007mM-6S
	for submit <at> debbugs.gnu.org; Sat, 12 Nov 2022 15:57:46 -0500
Received: from mail-oa1-f48.google.com ([209.85.160.48]:41947)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1otxZR-0007lb-4N
 for 58626 <at> debbugs.gnu.org; Sat, 12 Nov 2022 15:57:45 -0500
Received: by mail-oa1-f48.google.com with SMTP id
 586e51a60fabf-13b23e29e36so8820466fac.8
 for <58626 <at> debbugs.gnu.org>; Sat, 12 Nov 2022 12:57:45 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=YhYo18/cYs6KdghtGSRWORbX3iPuwJcFReHs/jd6kZM=;
 b=bGi+mjRB7CAMcLIKv6cN/5kb5rzTdr5nOexJfmm4YDKJ8A7AQdOVoCdxiezQYMf1QE
 sm1usirsPaGPLA1lqucTiaHMNxJTfy2D8/M3x9W5bD5/Pb+TiDX07U/balpgB59JgwUn
 pP4OfQACBA2KMYCGE1nfDOAgyw0oWXY5e00oX+zbYvTH2J9pNb/+6PUOkl/tcoAyGBZo
 dtZdW00PhPDClPEveqplZY/XAWmQNRwcTIxu0t+Hy8XaQ0vzY3Rga/9nfeGeJ/e+PTw6
 QQeSpcz90l4ivv2UFEtTIXkN/eXuGSRCIMJ3Rfn61edDGYZB0d94JlwgOwHbHuzsHF//
 wbjQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=YhYo18/cYs6KdghtGSRWORbX3iPuwJcFReHs/jd6kZM=;
 b=Tje5ntx5VFoxPYejI3sCGfP748QaXsBZENzft58Piaz6rhQqHN8dHGBKAxGABaNsJx
 ERUg16q6TySI4Mh6DJxq6LXvG9Zy4qWwtdRPfi+7ihO12iXQpzECnOW7+8MnJ3f9r1HY
 PiFwGjjdaYKQf2wnCJSG/bxogjxtPPRr6DVMf92x4P1rFK2n/NJVMmqlsAbGI0mENiiD
 TZD0LfHbJet6G1Ggy1xrUjBjXLq5Ri9cvaoPIadlTQJZUxNzYpB0yle0xypcHZu2g+kJ
 RuArZN/TxOviA39vTFP36WP07cV+Aj32P9CTllUZHxHXFqND4UIj5IWcFDZQQ+2Fk94i
 Jr5w==
X-Gm-Message-State: ANoB5pkk7D6ZzQIXwcQ+H3UiOioIPnfc6dT7nymp/cTfk+MygwDIvgzY
 T13iqMrbcoeoPvVur1zXYJGAnEW6ey+tCExHuUnzttps
X-Google-Smtp-Source: AA0mqf4WH7VKsIZ+piTcwDgyXnnvOnoNswGWoniuHqzE+oElKm1+MI5g2yWH1EqN5IN3Q9Y980yr67gcTHSYh3rGsLk=
X-Received: by 2002:a05:6870:6c15:b0:13b:8a07:2a1f with SMTP id
 na21-20020a0568706c1500b0013b8a072a1fmr3986031oab.199.1668286664888; Sat, 12
 Nov 2022 12:57:44 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sat, 12 Nov 2022 12:57:44 -0800
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <378CF744-E39E-490C-9CFF-E65CB325BE25@HIDDEN> (Perry Smith's
 message of "Tue, 18 Oct 2022 17:53:22 -0500")
References: <378CF744-E39E-490C-9CFF-E65CB325BE25@HIDDEN>
X-Hashcash: 1:20:221112:58626 <at> debbugs.gnu.org::gjFH50u6c6396rcW:1HPe
MIME-Version: 1.0
Date: Sat, 12 Nov 2022 12:57:44 -0800
Message-ID: <CADwFkmmiQ5Guy1gzXQ+QNOVn8o6uq7vQWV55Vx36GZHgv7o2fA@HIDDEN>
Subject: Re: bug#58626: Proposed changes to implement opening URLs on macOS
To: Perry Smith <pedzsan@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 58626
Cc: 58626 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Perry Smith <pedzsan@HIDDEN> writes:

> Attached is my patch file based upon the emacs-28.2 tar ball.  With
> these changes, I can do:
>
>     open emacs:///some/path/to/file.txt#25,40

Could you send the patch in uncompressed instead?  That will simplify
reviewing it.

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#58626; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 19 Oct 2022 11:06:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 19 07:06:15 2022
Received: from localhost ([127.0.0.1]:55965 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ol6tf-0007BJ-Tf
	for submit <at> debbugs.gnu.org; Wed, 19 Oct 2022 07:06:15 -0400
Received: from lists.gnu.org ([209.51.188.17]:49216)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pedzsan@HIDDEN>) id 1okvSl-0008PV-NK
 for submit <at> debbugs.gnu.org; Tue, 18 Oct 2022 18:53:34 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:48420)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <pedzsan@HIDDEN>)
 id 1okvSl-0006Y9-GI
 for bug-gnu-emacs@HIDDEN; Tue, 18 Oct 2022 18:53:31 -0400
Received: from ms11p00im-qufo17282101.me.com ([17.58.38.58]:35818)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <pedzsan@HIDDEN>)
 id 1okvSj-0002TT-CR
 for bug-gnu-emacs@HIDDEN; Tue, 18 Oct 2022 18:53:31 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com;
 s=1a1hai; t=1666133604;
 bh=4iJyBA0fHbLie/9jzR/hBivemUs1FCdp1h9d/zpbOe0=;
 h=From:Content-Type:Mime-Version:Subject:Message-Id:Date:To;
 b=i1m+Siattg4q2vuVPM4edQrKrM7LzYKGsXHioqQ3hmJYZI9upjlx+U78Lncz1O72P
 xSQ6MKOUSzbW25ifnLIabLOqt90UsLazSofRpfqdBWqBWn2mcQER8mVKCWqpYYySf1
 vVQ1Gk9Un+ZpqQ8/paXgvJaOK1GYUh9QsvwDOUWTXw7XzePObj8Ad3f5UDi3F5jHbB
 Y1fXQN5lCuVK/h2wmm4HSk83+FREAvusoFxYBRb0I5aJFFcjfay9cnOAc+tdOaVSGj
 sMa82bZy5XQiWetcfXo8ospMj92fKu8kSbTVoY34KuwM2gd/eLNj+DMegpqVM1/uF1
 6bG37/1M7eCUA==
Received: from smtpclient.apple (ms11p00im-dlb-asmtpmailmevip.me.com
 [17.57.154.19])
 by ms11p00im-qufo17282101.me.com (Postfix) with ESMTPSA id 8CD438C05BB
 for <bug-gnu-emacs@HIDDEN>; Tue, 18 Oct 2022 22:53:24 +0000 (UTC)
From: Perry Smith <pedzsan@HIDDEN>
Content-Type: multipart/mixed;
 boundary="Apple-Mail=_6571DF02-165E-4CDC-B35F-070E0D216D4A"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Proposed changes to implement opening URLs on macOS
Message-Id: <378CF744-E39E-490C-9CFF-E65CB325BE25@HIDDEN>
Date: Tue, 18 Oct 2022 17:53:22 -0500
To: bug-gnu-emacs@HIDDEN
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Proofpoint-GUID: CpnejG2E8fLsOkePXtZUp7mGzcyn1_6O
X-Proofpoint-ORIG-GUID: CpnejG2E8fLsOkePXtZUp7mGzcyn1_6O
X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?=
 =?UTF-8?Q?2903e8d5c8f:6.0.138,18.0.572,17.11.62.513.0000000_definitions?=
 =?UTF-8?Q?=3D2020-02-14=5F11:2020-02-14=5F02,2020-02-14=5F11,2021-12-02?=
 =?UTF-8?Q?=5F01_signatures=3D0?=
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0
 suspectscore=0
 malwarescore=0 mlxlogscore=893 clxscore=1011 adultscore=0 spamscore=0
 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1
 engine=8.12.0-2209130000 definitions=main-2210180129
Received-SPF: pass client-ip=17.58.38.58; envelope-from=pedzsan@HIDDEN;
 helo=ms11p00im-qufo17282101.me.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 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,
 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 19 Oct 2022 07:06:02 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--Apple-Mail=_6571DF02-165E-4CDC-B35F-070E0D216D4A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

NOTE: I am subscribed to this list but I do not receive emails from
the list.  Please CC me on replies and updates.  I will also check in
the archive every few days.

My email to the developers list explains better why I did this.[1] The
short version is an exception thrown by my Ruby on Rails app displays
a stack trace with file names and line numbers.  In the past, it was
possible to click on the line and it would pop into Emacs.  This was
after adding in Mitsuharu Yamamoto mods and other effort.  I wanted to
recreate that facility but in such a way that it might be accepted
into the main Emacs development.

It appears macOS uses the scheme in URLs a lot so these changes seem
to fit in with their general designs.

Attached is my patch file based upon the emacs-28.2 tar ball.  With
these changes, I can do:

    open emacs:///some/path/to/file.txt#25,40

and the file opens in Emacs with lines 25-40 highlighted.  Clicking a
link in a browser page with the same href as above causes the same
action.  The fragment can be omitted entirely or can be just a single
line.  The comma can also be a dash or a colon.

(I=E2=80=99m also going to submit a feature request to RoR to leverage =
this
feature.)

I don=E2=80=99t claim to be a lisp programmer so feel free to clean up =
what
I=E2=80=99ve done.

Note that the documentation says:

    If your delegate implements this method, AppKit does not call the
    application:openFile: or application:openFiles: methods.

I left the code for openFile and openFiles under an **assumption**
that on macOS before 10.13, openURLs will not be called and the system
will fall back to the openFile and openFiles entry points but I'm not
a macOS programmer either.

Thank you to Daniel Martin.  His reply to my email helped a lot.

Thank you for your time,
Perry
[1] =
https://lists.gnu.org/archive/html/emacs-devel/2022-10/msg01271.htmlf



--Apple-Mail=_6571DF02-165E-4CDC-B35F-070E0D216D4A
Content-Disposition: attachment;
	filename=open-url.diff.gz
Content-Type: application/x-gzip;
	x-unix-mode=0644;
	name="open-url.diff.gz"
Content-Transfer-Encoding: base64

H4sICFYkT2MAA29wZW4tdXJsLmRpZmYA1Vp7c9pIEv87/hQdX90asYinsQ12UuVNSK1rHciZbHJ7
LooT0gBaC42ikUy8u7nPft0zGiFAGCXne6lSRmp19/T09OM3owx87wFcH9jCsoXZPKs2TZ8tu1B9
PRwPIx6yg8EOjo9zKzKvzNeuU40+RzlsNctZuH4t9l3HiqwuJDfmjPlV5tnFJYrqvxc79JLBNc+d
dEE8iEfemyK0u2BH1kxUneEvb/eysknIl4IVZCa67bnMjwoKFDdkzj57xTgX1h0zHW5PXa+g3VJi
6vozFgahW9T4Bb/HV+5Oq5BTBF3wuOU4bEort1vlBuM/Dhx3OgUztDf11SIWLmo2Xyy4by5dirM8
bTlsB+VyuYC2Z816s2nWO2b9BBon3Vaj2z6u1vUFZr1drx+YpllwVKWuUTcbJ1A/7bZb3da2uvL6
JS09bVVOz0A+0mj02AG8Mw8AnoG6Sjb3BTSacOQLMsKchtaCGdscLckR8dnMY/jDvYkV5rAdSzYx
50szCHEljIPvN1nakoUHzDfj0MvqMPA6SHg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GrYXAlC9Y5BL4
IyXyvyTUT9rorNPGCmb+153FPWf4v+ivvGDrnCH265y16ys42OnUTyqdzvHp9s6PrkOqMLKKiYDZ
WPZXVYJ2nmij2ihUD40UgqtepDatf8HaeK4RIXoGR6RCvPqsmGY5AO48PlzejK+vhu/Qzzkn2+jt
HPRR2d64SasTbJIOpZ1N4xeYzC6sk0xpv82EaDYtJtoueyUkejJrpbbCtmoQtWmvpu+yOUVjT2b3
Ct8VtZ1w3KbdRNtlswSCT2av1Fbcz4gYt3yMtJ3+Jez5dL4lbV8RE9F8Ox6wPu6MBYS6TxgHqK2w
rRIcbxoribusVfj6ycxV6grbqzH5psmavsvqFNw/meGr7cKa7apUq9oMeXPBHL2T34gRC6tZJJQx
USrbjURtPCQeRZAV08EGPSdSakLCVRiWTvV8m2WbSla7tnXX/yKOQtyGHPwTSOPze4YsAAA=
--Apple-Mail=_6571DF02-165E-4CDC-B35F-070E0D216D4A--




Acknowledgement sent to Perry Smith <pedzsan@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#58626; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 23 Feb 2025 01:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.