all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Felician Nemeth <felician.nemeth@gmail.com>
To: Philip Kaludercic <philipk@posteo.net>
Cc: 69098@debbugs.gnu.org
Subject: bug#69098: [PATCH] Add new command 'browse-url-here'
Date: Sun, 18 Feb 2024 09:41:15 +0100	[thread overview]
Message-ID: <87a5nynp04.fsf@betli.tmit.bme.hu> (raw)
In-Reply-To: <875xyrged4.fsf@posteo.net> (Philip Kaludercic's message of "Wed,  14 Feb 2024 17:11:35 +0000")

[-- Attachment #1: Type: text/plain, Size: 772 bytes --]

>> Philip Kaludercic <philipk@posteo.net> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-browse-url-commands-to-invoke-secondary-browse.patch --]
[-- Type: text/x-diff, Size: 3055 bytes --]

From a5227603c87ae899a6ccf7e581b80a0f6b816946 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= <felician.nemeth@gmail.com>
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


  reply	other threads:[~2024-02-18  8:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 10:09 bug#69098: [PATCH] Add new command 'browse-url-here' Philip Kaludercic
2024-02-13 11:57 ` Felician Nemeth
2024-02-14 17:11   ` Philip Kaludercic
2024-02-18  8:41     ` Felician Nemeth [this message]
2024-02-18 12:36       ` Philip Kaludercic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a5nynp04.fsf@betli.tmit.bme.hu \
    --to=felician.nemeth@gmail.com \
    --cc=69098@debbugs.gnu.org \
    --cc=philipk@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.