From: Philip Kaludercic <philipk@posteo.net>
To: Felician Nemeth <felician.nemeth@gmail.com>
Cc: 69098@debbugs.gnu.org
Subject: bug#69098: [PATCH] Add new command 'browse-url-here'
Date: Sun, 18 Feb 2024 12:36:00 +0000 [thread overview]
Message-ID: <87ttm6t0en.fsf@posteo.net> (raw)
In-Reply-To: <87a5nynp04.fsf@betli.tmit.bme.hu> (Felician Nemeth's message of "Sun, 18 Feb 2024 09:41:15 +0100")
Felician Nemeth <felician.nemeth@gmail.com> writes:
>>> 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.
>
> 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))
This would lack the convince feature of being able to also quickly open
the current directory, which is what I used the prefix argument for.
> (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.
--
Philip Kaludercic
prev parent reply other threads:[~2024-02-18 12:36 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
2024-02-18 12:36 ` Philip Kaludercic [this message]
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=87ttm6t0en.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=69098@debbugs.gnu.org \
--cc=felician.nemeth@gmail.com \
/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.