Function: trashed-browse-url-of-file-internal
trashed-browse-url-of-file-internal is a natively compiled function
defined in trashed.el.
Signature
(trashed-browse-url-of-file-internal FILENAME)
Documentation
Ask a browser to display FILENAME using browse-url-of-file.
If FILENAME's original file extension was modified due to the name collision in Trash directory, restore it first by renaming the trash filename so the browser can display it properly.
Source Code
;; Defined in /nix/store/7ppdacjhnynz276lxxnfw8sdz6r2k6h2-emacs-packages-deps/share/emacs/site-lisp/elpa/trashed-20230811.157/trashed.el
(defun trashed-browse-url-of-file-internal (filename)
"Ask a browser to display FILENAME using `browse-url-of-file'.
If FILENAME's original file extension was modified due to the name collision
in Trash directory, restore it first by renaming the trash filename
so the browser can display it properly."
(let ((name (aref (tabulated-list-get-entry) 3)))
(if (or (file-directory-p filename)
(string= (file-name-extension filename) (file-name-extension name)))
(browse-url-of-file filename)
;; Rename trash file to recover the original filename extension
;; This is only possible when (not (eq system-type 'windows-nt))
(let* ((info-file (trashed-info-file (file-name-nondirectory filename)))
delete-by-moving-to-trash newname)
;; Workaround for info files generated by Emacs bug #37922
(if (not (file-exists-p info-file))
(setq info-file (expand-file-name
(file-name-nondirectory filename)
trashed-info-dir)))
(while (progn
(setq newname (make-temp-file
(expand-file-name (file-name-base name)
trashed-files-dir)
nil (concat "." (file-name-extension name))))
(condition-case nil
(rename-file info-file (trashed-info-file
(file-name-nondirectory
newname))) ;; nil -> exit
(file-already-exists t))) ;; t -> retry
(delete-file newname))
(rename-file filename newname t)
(trashed-tabulated-list-set-id (file-name-nondirectory newname))
(browse-url-of-file newname)))))