mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Handle /assets and /content file names in `android-browse-url'
* lisp/net/browse-url.el (android-browse-url): New function. * lisp/term/android-win.el (android-browse-url-internal): Update function declaration. * src/androidselect.c (Fandroid_browse_url): Rename to... (Fandroid_browse_url_internal): ... this. (syms_of_androidselect): Adjust to match.
This commit is contained in:
parent
377e4212e9
commit
783a511d1e
3 changed files with 58 additions and 8 deletions
|
|
@ -479,6 +479,50 @@ the UTF-8 coding system."
|
|||
;; Return the concatenation of both these values.
|
||||
(concat locale-base locale-modifier)))
|
||||
|
||||
|
||||
;; Miscellaneous functions.
|
||||
|
||||
(declare-function android-browse-url-internal "androidselect.c")
|
||||
|
||||
(defun android-browse-url (url &optional send)
|
||||
"Open URL in an external application.
|
||||
|
||||
URL should be a URL-encoded URL with a scheme specified unless
|
||||
SEND is non-nil. Signal an error upon failure.
|
||||
|
||||
If SEND is nil, start a program that is able to display the URL,
|
||||
such as a web browser. Otherwise, try to share URL using
|
||||
programs such as email clients.
|
||||
|
||||
If URL is a file URI, convert it into a `content' address
|
||||
accessible to other programs."
|
||||
(when-let* ((uri (url-generic-parse-url url))
|
||||
(filename (url-filename uri))
|
||||
;; If `uri' is a file URI and the file resides in /content
|
||||
;; or /assets, copy it to a temporary file before
|
||||
;; providing it to other programs.
|
||||
(replacement-url (and (string-match-p
|
||||
"/\\(content\\|assets\\)[/$]"
|
||||
filename)
|
||||
(prog1 t
|
||||
(copy-file
|
||||
filename
|
||||
(setq filename
|
||||
(make-temp-file
|
||||
"local"
|
||||
nil
|
||||
(let ((extension
|
||||
(file-name-extension
|
||||
filename)))
|
||||
(if extension
|
||||
(concat "."
|
||||
extension)
|
||||
nil))))
|
||||
t))
|
||||
(concat "file://" filename))))
|
||||
(setq url replacement-url))
|
||||
(android-browse-url-internal url send))
|
||||
|
||||
|
||||
(provide 'android-win)
|
||||
;; android-win.el ends here.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue