From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Felician Nemeth Newsgroups: gmane.emacs.bugs Subject: bug#69098: [PATCH] Add new command 'browse-url-here' Date: Sun, 18 Feb 2024 09:41:15 +0100 Message-ID: <87a5nynp04.fsf@betli.tmit.bme.hu> References: <87ttmc7k0h.fsf@posteo.net> <877cj8d1a2.fsf@betli.tmit.bme.hu> <875xyrged4.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36389"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cc: 69098@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 18 09:43:08 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rbclP-0009EN-VO for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Feb 2024 09:43:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rbcl1-0002GK-Il; Sun, 18 Feb 2024 03:42:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rbcl0-0002Fp-9k for bug-gnu-emacs@gnu.org; Sun, 18 Feb 2024 03:42:42 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rbcl0-0007cR-1v for bug-gnu-emacs@gnu.org; Sun, 18 Feb 2024 03:42:42 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rbclK-0005Rd-6R for bug-gnu-emacs@gnu.org; Sun, 18 Feb 2024 03:43:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Felician Nemeth Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Feb 2024 08:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69098 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 69098-submit@debbugs.gnu.org id=B69098.170824576720896 (code B ref 69098); Sun, 18 Feb 2024 08:43:02 +0000 Original-Received: (at 69098) by debbugs.gnu.org; 18 Feb 2024 08:42:47 +0000 Original-Received: from localhost ([127.0.0.1]:34136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbcl4-0005Qx-EL for submit@debbugs.gnu.org; Sun, 18 Feb 2024 03:42:47 -0500 Original-Received: from mail-ej1-f41.google.com ([209.85.218.41]:44436) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbcl2-0005QY-6u for 69098@debbugs.gnu.org; Sun, 18 Feb 2024 03:42:45 -0500 Original-Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a3e7ce7dac9so12381866b.1 for <69098@debbugs.gnu.org>; Sun, 18 Feb 2024 00:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708245677; x=1708850477; darn=debbugs.gnu.org; h=mime-version:face:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=KI3fhPfEvvZs9IaAeBuR72ijU2Q7E9vLjZ3gIwyDqtc=; b=LWyORp5YBOhRv4yFhgf+rsFacVDEpOgnFwTiPMWvcWGH8b8nFyO99ZWOywxls9tbjx VgqSdzmjwfm1Py2GupIXIosVof32ceZalEqWHvZN9s/j3QDRSUiFb6ysYkKcnPBNJ9A/ Z3tcWfTXg6CbuZ4/Qp/i53mgU5ytyYYIug6I4iwJ8UVVQDvTDd68Zk6PFH0jtgvHsP/Z VFWw1B5fzpf6rl0NI2uuegF5Ef+JvNvMBn/TkZE8e2ME82QcJTB+4vsEpwWgaTRoKb6m bLM6KgJiTVez0AX6FaLs6phYdmSyD3AHdUOZfeh/Z0ykjwl4RX7CrXKV5b+In9A/vVwZ LcxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708245677; x=1708850477; h=mime-version:face:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KI3fhPfEvvZs9IaAeBuR72ijU2Q7E9vLjZ3gIwyDqtc=; b=hVx18zj+3qsH54Jl/JnSKgemUh9uPPNCbm/zEAG3EFtRKJqcpVDFVIf/pYO/L6LEdP u3ouCSZyP6gfxlry1UQSCNzL50d8DT72JPbBtWxP/7hgByg2DW85SY2R40yjRnaJAgfQ P4ggMbLXZVwAAmQ/H6WC3JpJcqVtNbxAY8c2uxTFOzivCI0aIwckQ3s3Vy2OHecM9jlp X3zN777fsuZIg5vgqaHit4htTlWLQ7yjd2hMZSHeicOnSjRxFeCK3ZtH7/fb4QAw3kjN X1Yge/UZCvdLSCSy6wOZ0cSoulKZoGj2/ozk5OawXJ73VvEBk7VEuHNeKQCiKCn1kz+Y KN7w== X-Gm-Message-State: AOJu0YzCgiRYeqYXhGoSau1qdyZbWqfi1ds7Fp5LiMkmZkoJRYOs5dh8 Hff7f/NhUjY3JFNhOGTuQc1dck3dGAqQ4SyfKMt9z2ldWq6wDEX7OCkttlCo X-Google-Smtp-Source: AGHT+IHkfhOHAKMhgT3dH5JqThTlMyMOvVoU/Rh/xHw3nMyuSiyJHChu77ogVO4mxVBjouNUF+Ct3w== X-Received: by 2002:a17:906:d9d1:b0:a3e:4813:d4d8 with SMTP id qk17-20020a170906d9d100b00a3e4813d4d8mr1890279ejb.46.1708245677059; Sun, 18 Feb 2024 00:41:17 -0800 (PST) Original-Received: from betli.gmail.com (catv-213-222-160-137.catv.fixed.vodafone.hu. [213.222.160.137]) by smtp.gmail.com with ESMTPSA id cu15-20020a170906ba8f00b00a3e29652a3csm1255491ejd.194.2024.02.18.00.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 00:41:16 -0800 (PST) In-Reply-To: <875xyrged4.fsf@posteo.net> (Philip Kaludercic's message of "Wed, 14 Feb 2024 17:11:35 +0000") Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEUMBwgHAgMFAAGPjY7/ //80MDHq6eqJt3pKAAABr0lEQVQ4jX2UzZKDIAzHqR177q7TPbtx2HMr6guQcrbY9txZ0fd/hA0f onXazcEJ/CD8E4Js8/HS9mwjXtqeMRxHXJkakTEm4b4GPVQW8PU8ov4fQCqeThlF60MBWdo1IXzd 2nEEZE7CEAZLwI0N/gJAhTj7ESQAX4gPgO8lyI+cvgViSVPlNomAj2M9gW40eg7VWY3cATjUcyiO Z+i03cFruGLYoUR7VyU3HihdmCEVhoDN65FXkpbSxkomOzsTQN/gySaodGb9Gdi1oSRXP46gdBWh LcUKJNdeGCWac74GKakmne0aHCFvyqJPYLsCFAVlhRTvGdzMdLHqtgRyUulyXIAH7CYQ3AB0Nody JQhAkq/qtOnbjhxdzYDkXPxlH5y4WdUAeUcX1NVJ6GR7UQEYPGWoAnA36OQNn5lRRp38vHTAp9Br LoTmvlPPDoRCKzpjG1SXT89AaT5l456BamJuMcs+NIOMzJ/s5dI6yUVcrARlruwOebfdv6gunTn4 ww3+QjGBEn5suVyLHoSGvAqREuDLN+iqZ+VcFg+HBbsJUU9+FZthbez9T+bdb+kPv2Ls6ct3hTkA AAAASUVORK5CYII= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280163 Archived-At: --=-=-= Content-Type: text/plain >> Philip Kaludercic writes: >> >>> The idea is to have a command that can be used to open a file or >>> directory using something outside Emacs. >>> >>> I find this useful, but it might be that there are edge-cases that I am >>> not considering that don't pop up on my system. Now I think the attached patch is more inline with the philosophy of browse-url than the previous patches of this thread. However, this patch might not be necessary. You can open a file with C-x C-j W or in the secondary browser with C-x C-j C-u W. This seems cumbersome, but C-x C-j (dired-jump) quickly becomes second nature. And to open the directory of file: C-x C-j C-x C-j C-u W, which once again seems frightening, but can be entered quickly without thinking. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Allow-browse-url-commands-to-invoke-secondary-browse.patch >From a5227603c87ae899a6ccf7e581b80a0f6b816946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= Date: Sun, 18 Feb 2024 09:22:30 +0100 Subject: [PATCH] Allow browse-url commands to invoke secondary browser * lisp/net/browse-url.el (browse-url-of-file) (browse-url-of-buffer): Use 'browse-url-secondary-browser-function' if the new argument 'secondary' is non-nil or when invoked with a prefix arg. --- lisp/net/browse-url.el | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 74740af3bd6..4c4c79a80da 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -728,13 +728,16 @@ browse-url-maybe-new-window ;; Browse current buffer ;;;###autoload -(defun browse-url-of-file (&optional file) +(defun browse-url-of-file (&optional file secondary) "Use a web browser to display FILE. Display the current buffer's file if FILE is nil or if called interactively. Turn the filename into a URL with function `browse-url-file-url'. Pass the URL to a browser using the -`browse-url' function then run `browse-url-of-file-hook'." - (interactive) +`browse-url' function then run `browse-url-of-file-hook'. + +With a prefix argument, or when SECONDARY is non-nil, use +`browse-url-secondary-browser-function' instead." + (interactive (list nil current-prefix-arg)) (or file (setq file (buffer-file-name)) (error "Current buffer has no file")) @@ -748,7 +751,10 @@ browse-url-of-file (not browse-url-temp-file-name)) (setq browse-url-temp-file-name (file-local-copy file) file browse-url-temp-file-name)) - (browse-url (browse-url-file-url file)) + (let ((url (browse-url-file-url file))) + (if secondary + (funcall browse-url-secondary-browser-function url) + (browse-url url))) (run-hooks 'browse-url-of-file-hook)) (defun browse-url--file-name-coding-system () @@ -789,14 +795,17 @@ browse-url-file-url file) ;;;###autoload -(defun browse-url-of-buffer (&optional buffer) +(defun browse-url-of-buffer (&optional buffer secondary) "Use a web browser to display BUFFER. See `browse-url' for details. Display the current buffer if BUFFER is nil. Display only the currently visible part of BUFFER (from a temporary file) if buffer is -narrowed." - (interactive) +narrowed. + +With a prefix argument, or when SECONDARY is non-nil, use +`browse-url-secondary-browser-function' instead." + (interactive (list nil current-prefix-arg)) (save-excursion (and buffer (set-buffer buffer)) (let ((file-name @@ -816,7 +825,7 @@ browse-url-of-buffer nil ".html")))) (setq file-name browse-url-temp-file-name) (write-region (point-min) (point-max) file-name nil 'no-message)) - (browse-url-of-file file-name)))) + (browse-url-of-file file-name secondary)))) (defun browse-url-delete-temp-file (&optional temp-file-name) "Delete `browse-url-temp-file-name' from the file system. -- 2.39.2 --=-=-=--