Package: emacs;
Reported by: Milen Hristov <milen <at> andreshko.com>
Date: Wed, 18 Jun 2025 21:42:01 UTC
Severity: normal
Found in version 30.1
To reply to this bug, email your comments to 78830 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-gnu-emacs <at> gnu.org
:bug#78830
; Package emacs
.
(Wed, 18 Jun 2025 21:42:02 GMT) Full text and rfc822 format available.Milen Hristov <milen <at> andreshko.com>
:bug-gnu-emacs <at> gnu.org
.
(Wed, 18 Jun 2025 21:42:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Milen Hristov <milen <at> andreshko.com> To: bug-gnu-emacs <at> gnu.org Subject: 30.1; M- browse-url-of-buffer doesn't work second time in a row Date: Wed, 18 Jun 2025 14:40:49 +0300
X-Debbugs-Cc: --text follows this line-- I’m editing pure HTML file over TRAMP. I want to preview it locally and I’m using M- browser-url-of-buffer. The command works flawlessly the first time and it opens the default browser (Safari in my case). I see that Emacs created a local temp file which the browser renders. When I try to invoke the command second time, after I have done changes to the HTML file (saved or not, the behaviour is the same) - Emacs invokes Mac OS native “Connect to server” menu, which tries automatically to connect to the remote server, where the actual file is. Expected behaviour is to make another temporary file with the new changes in the buffer and show it locally in the browser or if it needs to fetch the file from the remote, then use tramp, not MacOS “Connect to server" When I restart the buffer and try again M- browse-url-of-buffer, it works again as expected. However every next time it shows the above described behaviour. In short, "M- browse-url-of-buffer" always works the first time it is invoked for a buffer, but not after that. In GNU Emacs 30.1 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.65 Version 12.7.6 (Build 21H1320)) of 2025-02-24 built on armbob.lan Windowing system distributor 'Apple', version 10.3.2575 System Description: macOS 15.5 Configured using: 'configure --with-ns '--enable-locallisppath=/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp' --with-modules 'CFLAGS=-DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT' --with-x-toolkit=no' Configured features: ACL GLIB GMP GNUTLS JPEG LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB Important settings: value of $LANG: en locale-coding-system: utf-8-unix Major mode: Web Minor modes in effect: envrc-global-mode: t global-undo-tree-mode: t undo-tree-mode: t global-corfu-mode: t corfu-mode: t all-the-icons-completion-mode: t marginalia-mode: t override-global-mode: t vertico-mode: t mood-line-mode: t delete-selection-mode: t global-whitespace-mode: t whitespace-mode: t pixel-scroll-precision-mode: t global-display-line-numbers-mode: t display-line-numbers-mode: t global-so-long-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t minibuffer-regexp-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t hs-minor-mode: t Load-path shadows: /Users/milen/.emacs.d/elpa/which-key-20240620.2145/which-key hides /Applications/Emacs.app/Contents/Resources/lisp/which-key /Users/milen/.emacs.d/elpa/transient-20250609.1609/transient hides /Applications/Emacs.app/Contents/Resources/lisp/transient /Users/milen/.emacs.d/elpa/bind-key-20230203.2004/bind-key hides /Applications/Emacs.app/Contents/Resources/lisp/bind-key /Users/milen/.emacs.d/elpa/eglot-1.18/eglot hides /Applications/Emacs.app/Contents/Resources/lisp/progmodes/eglot Features: (shadow sort flyspell ispell mail-extr emacsbug message yank-media rfc822 mml mml-sec epa epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums quail eww url-queue shr pixel-fill kinsoku url-file svg xml dom puny mm-url gnus nnheader gnus-util mail-utils range wid-edit mm-util mail-prsvr help-fns radix-tree cl-print eglot external-completion jsonrpc xref ert ewoc debug backtrace filenotify imenu mood-line-segment-checker flymake warnings python consult vc-hg vc-bzr mood-line-segment-vc vc-git vc-dispatcher tramp-cmds vertico-directory vertico-sort tramp-cache time-stamp tramp-sh project envrc inheritenv diff-mode track-changes undo-tree diff queue casual-dired casual-dired-settings dired-aux casual-dired-version casual-dired-sort-by casual-dired-utils casual-dired-variables elint checkdoc lisp-mnt casual-lib casual-lib-version transient image-dired image-dired-tags image-dired-external image-dired-util image-mode exif wdired dired-x dired dired-loaddefs highlight-indentation hideshow web-mode advice derived toc-org org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src sh-script smie treesit executable ob-comint org-pcomplete org-list org-footnote org-faces org-entities noutline outline org-version ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold org-fold-core org-keys oc org-loaddefs thingatpt cal-menu calendar cal-loaddefs org-compat org-macs vterm bookmark pp face-remap compile text-property-search color term ehelp find-func vterm-module term/xterm xterm corfu all-the-icons-completion marginalia orderless edmacro kmacro use-package-bind-key bind-key easy-mmode vertico compat mood-line all-the-icons all-the-icons-faces data-material data-weathericons data-octicons data-fileicons data-faicons data-alltheicons dracula-theme use-package-ensure tramp trampver tramp-integration files-x tramp-message tramp-compat xdg shell pcomplete comint ansi-osc parse-time iso8601 time-date format-spec ansi-color tramp-loaddefs exec-path-from-shell cl-extra help-mode use-package-core finder-inf delsel disp-table whitespace pixel-scroll cua-base ring display-line-numbers so-long all-the-icons-completion-autoloads all-the-icons-autoloads anaphora-autoloads async-autoloads better-defaults-autoloads ca65-mode-autoloads casual-dired-autoloads casual-lib-autoloads corfu-autoloads deferred-autoloads devdocs-autoloads dired-hacks-utils-autoloads dracula-theme-autoloads eglot-autoloads elfeed-autoloads embark-consult-autoloads consult-autoloads embark-autoloads envrc-autoloads erc-terminal-notifier-autoloads exec-path-from-shell-autoloads flycheck-autoloads forth-mode-autoloads frame-local-autoloads hideshow-org-autoloads highlight-indent-guides-autoloads highlight-indentation-autoloads inheritenv-autoloads json-mode-autoloads rx json-snatcher-autoloads language-id-autoloads magit-autoloads pcase magit-section-autoloads llama-autoloads marginalia-autoloads markdown-mode-autoloads mathjax-autoloads mood-line-autoloads multiple-cursors-autoloads nerd-icons-corfu-autoloads nerd-icons-autoloads orderless-autoloads pkg-info-autoloads epl-autoloads polymode-autoloads posframe-autoloads python-mode-autoloads request-autoloads shrink-path-autoloads f-autoloads dash-autoloads s-autoloads spinner-autoloads toc-org-autoloads transient-autoloads tree-sitter-autoloads tsc-autoloads undo-tree-autoloads queue-autoloads unicode-fonts-autoloads ucs-utils-autoloads font-utils-autoloads persistent-soft-autoloads list-utils-autoloads pcache-autoloads validate-html-autoloads vertico-autoloads vscode-icon-autoloads vterm-autoloads web-completion-data-autoloads websocket-autoloads wfnames-autoloads which-key-autoloads info with-editor-autoloads yasnippet-autoloads package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs icons password-cache json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads kqueue cocoa ns multi-tty make-network-process emacs) Memory information: ((conses 16 2899022 838266) (symbols 48 66576 8) (strings 32 354672 42841) (string-bytes 1 6266242) (vectors 16 68170) (vector-slots 8 1425779 995357) (floats 8 962 9122) (intervals 56 104036 1815) (buffers 992 23))
bug-gnu-emacs <at> gnu.org
:bug#78830
; Package emacs
.
(Thu, 19 Jun 2025 06:02:02 GMT) Full text and rfc822 format available.Message #8 received at 78830 <at> debbugs.gnu.org (full text, mbox):
From: Eli Zaretskii <eliz <at> gnu.org> To: Milen Hristov <milen <at> andreshko.com> Cc: 78830 <at> debbugs.gnu.org Subject: Re: bug#78830: 30.1; M- browse-url-of-buffer doesn't work second time in a row Date: Thu, 19 Jun 2025 09:01:31 +0300
> Date: Wed, 18 Jun 2025 14:40:49 +0300 > From: Milen Hristov via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> > > X-Debbugs-Cc: > --text follows this line-- > > I’m editing pure HTML file over TRAMP. I want to preview it locally and I’m using M- browser-url-of-buffer. The command works flawlessly the first time and it opens the default browser (Safari in my case). I see that Emacs created a local temp file which the browser renders. > > When I try to invoke the command second time, after I have done changes to the HTML file (saved or not, the behaviour is the same) - Emacs invokes Mac OS native “Connect to server” menu, which tries automatically to connect to the remote server, where the actual file is. > Expected behaviour is to make another temporary file with the new changes in the buffer and show it locally in the browser or if it needs to fetch the file from the remote, then use tramp, not MacOS “Connect to server" > > When I restart the buffer and try again M- browse-url-of-buffer, it works again as expected. However every next time it shows the above described behaviour. > > In short, "M- browse-url-of-buffer" always works the first time it is invoked for a buffer, but not after that. I seem to be unable to reproduce this problem, perhaps because I'm not on macOS. Could you perhaps step with Edebug through browse-url-of-file (which is called from browse-url-of-buffer) on the second invocation, and see what goes wrong there and why? I suspect this part could be relevant: (when (and (file-remote-p file) (not browse-url-temp-file-name)) (setq browse-url-temp-file-name (file-local-copy file) file browse-url-temp-file-name)) (browse-url (browse-url-file-url file)) perhaps because browse-url-temp-file-name is non-nil the second time? But I don't know how the macOS "Connect to server" menu is invoked; can you clarify that?
bug-gnu-emacs <at> gnu.org
:bug#78830
; Package emacs
.
(Thu, 19 Jun 2025 07:10:02 GMT) Full text and rfc822 format available.Message #11 received at 78830 <at> debbugs.gnu.org (full text, mbox):
From: Eli Zaretskii <eliz <at> gnu.org> To: Milen Hristov <milen <at> andreshko.com> Cc: 78830 <at> debbugs.gnu.org Subject: Re: bug#78830: 30.1; M- browse-url-of-buffer doesn't work second time in a row Date: Thu, 19 Jun 2025 10:09:11 +0300
[Please use Reply All to reply, to keep our bug tracker CC'ed.] > From: Milen Hristov <milen <at> andreshko.com> > Date: Thu, 19 Jun 2025 09:37:32 +0300 > > > > > On 19 Jun 2025, at 9:01, Eli Zaretskii <eliz <at> gnu.org> wrote: > > > >> Date: Wed, 18 Jun 2025 14:40:49 +0300 > >> From: Milen Hristov via "Bug reports for GNU Emacs, > >> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> > >> > >> X-Debbugs-Cc: > >> --text follows this line-- > >> > >> I’m editing pure HTML file over TRAMP. I want to preview it locally and I’m using M- browser-url-of-buffer. The command works flawlessly the first time and it opens the default browser (Safari in my case). I see that Emacs created a local temp file which the browser renders. > >> > >> When I try to invoke the command second time, after I have done changes to the HTML file (saved or not, the behaviour is the same) - Emacs invokes Mac OS native “Connect to server” menu, which tries automatically to connect to the remote server, where the actual file is. > >> Expected behaviour is to make another temporary file with the new changes in the buffer and show it locally in the browser or if it needs to fetch the file from the remote, then use tramp, not MacOS “Connect to server" > >> > >> When I restart the buffer and try again M- browse-url-of-buffer, it works again as expected. However every next time it shows the above described behaviour. > >> > >> In short, "M- browse-url-of-buffer" always works the first time it is invoked for a buffer, but not after that. > > > > I seem to be unable to reproduce this problem, perhaps because I'm not > > on macOS. Could you perhaps step with Edebug through > > browse-url-of-file (which is called from browse-url-of-buffer) on the > > second invocation, and see what goes wrong there and why? > > > > I suspect this part could be relevant: > > > > (when (and (file-remote-p file) > > (not browse-url-temp-file-name)) > > (setq browse-url-temp-file-name (file-local-copy file) > > file browse-url-temp-file-name)) > > (browse-url (browse-url-file-url file)) > > > > perhaps because browse-url-temp-file-name is non-nil the second time? > > But I don't know how the macOS "Connect to server" menu is invoked; > > can you clarify that? > > > I stepped through it and it seems the MacOS dialog window is triggered on line 822 of browse-url.el: > > (setq file-name browse-url-temp-file-name) > (write-region (point-min) (point-max) file-name nil 'no-message)) > (browse-url-of-file file-name)))) > > more specifically here: (browse-url-of-file file-name) Thanks, that was my guess. I asked you to step through the code of browse-url-of-file itself, for that reason. (Let me know if you need help with using Edebug to step into function calls like this.) The code snippet I show is from browse-url-of-file, and it specifically tests whether the file is remote or not, so I think something is wrong in that logic.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.