all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#69098: [PATCH] Add new command 'browse-url-here'
@ 2024-02-13 10:09 Philip Kaludercic
  2024-02-13 11:57 ` Felician Nemeth
  0 siblings, 1 reply; 5+ messages in thread
From: Philip Kaludercic @ 2024-02-13 10:09 UTC (permalink / raw)
  To: 69098

[-- 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-18 12:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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.