diff options
| author | Michael Albinus | 2025-07-10 17:25:56 +0200 |
|---|---|---|
| committer | Michael Albinus | 2025-07-10 17:25:56 +0200 |
| commit | 9f82300bb049c716d59575eaee29262e38c5e8d2 (patch) | |
| tree | 4d34ce95dcf0b1cc130eb7db823eb31fe5dd0c37 | |
| parent | 18ff84df0cdeddf01a5199893180da4f5c1732af (diff) | |
| download | emacs-9f82300bb049c716d59575eaee29262e38c5e8d2.tar.gz emacs-9f82300bb049c716d59575eaee29262e38c5e8d2.zip | |
Fix handling of `browse-url-temp-file-name'
* lisp/net/browse-url.el (browse-url--temp-file-setup):
Add `browse-url-delete-temp-file' to `write-file-functions'.
(browse-url-of-file, browse-url-delete-temp-file): Fix handling of
`browse-url-temp-file-name'. (Bug#78830)
| -rw-r--r-- | lisp/net/browse-url.el | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 96b4baaa615..63ed7283949 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el | |||
| @@ -737,6 +737,7 @@ instead." | |||
| 737 | (defmacro browse-url--temp-file-setup (&rest body) | 737 | (defmacro browse-url--temp-file-setup (&rest body) |
| 738 | (declare (indent defun)) | 738 | (declare (indent defun)) |
| 739 | `(progn | 739 | `(progn |
| 740 | (add-hook 'write-file-functions #'browse-url-delete-temp-file nil t) | ||
| 740 | (add-hook 'kill-buffer-hook #'browse-url-delete-temp-file nil t) | 741 | (add-hook 'kill-buffer-hook #'browse-url-delete-temp-file nil t) |
| 741 | (with-file-modes #o600 | 742 | (with-file-modes #o600 |
| 742 | ,@body))) | 743 | ,@body))) |
| @@ -758,11 +759,11 @@ interactively. Turn the filename into a URL with function | |||
| 758 | (cond ((not (buffer-modified-p))) | 759 | (cond ((not (buffer-modified-p))) |
| 759 | (browse-url-save-file (save-buffer)) | 760 | (browse-url-save-file (save-buffer)) |
| 760 | (t (message "%s modified since last save" file)))))) | 761 | (t (message "%s modified since last save" file)))))) |
| 761 | (when (and (file-remote-p file) | 762 | (when (file-remote-p file) |
| 762 | (not browse-url-temp-file-name)) | ||
| 763 | (browse-url--temp-file-setup | 763 | (browse-url--temp-file-setup |
| 764 | (setq browse-url-temp-file-name (file-local-copy file) | 764 | (unless browse-url-temp-file-name |
| 765 | file browse-url-temp-file-name))) | 765 | (setq browse-url-temp-file-name (file-local-copy file))) |
| 766 | (setq file browse-url-temp-file-name))) | ||
| 766 | (browse-url (browse-url-file-url file)) | 767 | (browse-url (browse-url-file-url file)) |
| 767 | (run-hooks 'browse-url-of-file-hook)) | 768 | (run-hooks 'browse-url-of-file-hook)) |
| 768 | 769 | ||
| @@ -839,7 +840,8 @@ narrowed." | |||
| 839 | (declare (advertised-calling-convention () "31.1")) | 840 | (declare (advertised-calling-convention () "31.1")) |
| 840 | (let ((file-name (or temp-file-name browse-url-temp-file-name))) | 841 | (let ((file-name (or temp-file-name browse-url-temp-file-name))) |
| 841 | (if (and file-name (file-exists-p file-name)) | 842 | (if (and file-name (file-exists-p file-name)) |
| 842 | (delete-file file-name)))) | 843 | (delete-file file-name)) |
| 844 | (unless temp-file-name (setq browse-url-temp-file-name nil)))) | ||
| 843 | 845 | ||
| 844 | (declare-function dired-get-filename "dired" | 846 | (declare-function dired-get-filename "dired" |
| 845 | (&optional localp no-error-if-not-filep)) | 847 | (&optional localp no-error-if-not-filep)) |