From: Philip Kaludercic <philipk@posteo.net>
To: 69098@debbugs.gnu.org
Subject: bug#69098: [PATCH] Add new command 'browse-url-here'
Date: Tue, 13 Feb 2024 10:09:50 +0000 [thread overview]
Message-ID: <87ttmc7k0h.fsf@posteo.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 228 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Add new command 'browse-url-here' --]
[-- Type: text/x-patch, Size: 1779 bytes --]
From 1f25f653ba35cb2c63a481522ffbf727bc2f5dd3 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Tue, 13 Feb 2024 11:08:09 +0100
Subject: [PATCH] Add new command 'browse-url-here'
* lisp/net/browse-url.el (browse-url-here): Add it.
* etc/NEWS: Document it.
---
etc/NEWS | 4 ++++
lisp/net/browse-url.el | 13 +++++++++++++
2 files changed, 17 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index e7e516d61a1..ea7cd1fc517 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -317,6 +317,10 @@ Previously, it was set to t but this broke remote file name detection.
** Multi-character key echo now ends with a suggestion to use Help.
Customize 'echo-keystrokes-help' to nil to prevent that.
+** New command 'browse-url-here'.
+This command opens the current file or directory using an external tool,
+as defined by 'browse-url-of-file'.
+
\f
* Editing Changes in Emacs 30.1
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index bc2a7db9a8b..abc1e9e5829 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -943,6 +943,19 @@ browse-url-at-point
browse-url-new-window-flag))
(error "No URL found"))))
+(defun browse-url-here (arg)
+ "Open current file or directory with external tools.
+With prefix argument ARG, open the current `default-directory' instead
+of the buffer of the current file."
+ (interactive "P")
+ (let ((browse-url-default-handlers '()))
+ (browse-url-of-file
+ (expand-file-name
+ (or (and arg ".")
+ (and (derived-mode-p 'dired-mode)
+ (dired-get-filename))
+ buffer-file-name ".")))))
+
;;;###autoload
(defun browse-url-with-browser-kind (kind url &optional arg)
"Browse URL with a browser of the given browser KIND.
--
2.43.0
next reply other threads:[~2024-02-13 10:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 10:09 Philip Kaludercic [this message]
2024-02-13 11:57 ` bug#69098: [PATCH] Add new command 'browse-url-here' Felician Nemeth
2024-02-14 17:11 ` Philip Kaludercic
2024-02-18 8:41 ` Felician Nemeth
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=87ttmc7k0h.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=69098@debbugs.gnu.org \
/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.