Subject: bug#54271: 28.0.91; browse-url-of-dired-file fails with wrong type argument error

From: Gustavo Barros <[email-masked]>
Date: Sun, 06 Mar 2022 08:54:27 -0300

Hi All,

I've been trying out the pre-release and met an issue with 
`browse-url-of-dired-file'.

Whenever I try to use it, I get the error "url-file: Wrong type 
argument: number-or-marker-p, nil".

As far as I can tell, the issue is not related with file/mime type. 
I've tried it with files I'd expect would be opened with an external 
application and with Emacs: .png, .jpg, .odt, but also .org, .tex. All 
with the same results.

However, as far as I can tell, the issue arises for file names with no 
ascii characters.  If the file name is well behaved, it works as 
expected.  But as soon as, e.g. an accented letter is part of it, the 
issue is triggered.

To reproduce, start with `emacs -Q'. Create a file named 
"~/test/áçãü.org", open `dired', and navigate to that file, and hit "W" 
(`browse-url-of-dired-file') on it.  You should get the mentioned error 
"url-file: Wrong type argument: number-or-marker-p, nil".

The backtrace is:

#+begin_example
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p 
nil)
  url-file-asynch-callback(nil nil nil 
  "/home/gustavo/test/\303\203\302\241\303\203\302\247\303\203\302\243\303\203\302\274.org" 
  #<buffer  *url-file*> #f(compiled-function (&rest args) #<bytecode 
  0xa8380fab2697cef>) (nil))
  url-file(#s(url :type "file" :user nil :password nil :host "" 
  :portspec nil :filename 
  "/home/gustavo/test/%C3%83%C2%A1%C3%83%C2%A7%C3%83%..." :target nil 
  :attributes nil :fullness t :silent nil :use-cookies t :asynchronous 
  nil) #f(compiled-function (&rest args) #<bytecode 0xa8380fab2697cef>) 
  (nil))
  url-retrieve-internal("file:///home/gustavo/test/Ã¡Ã§Ã£Ã¼.org" 
  #f(compiled-function (&rest args) #<bytecode 0xa8380fab2697cef>) (nil) 
  nil nil)
  url-retrieve("file:///home/gustavo/test/Ã¡Ã§Ã£Ã¼.org" 
  #f(compiled-function (&rest args) #<bytecode 0xa8380fab2697cef>) nil 
  nil nil)
  url-retrieve-synchronously("file:///home/gustavo/test/Ã¡Ã§Ã£Ã¼.org")
  url-insert-file-contents("file:///home/gustavo/test/Ã¡Ã§Ã£Ã¼.org" t 
  nil nil nil)
  apply(url-insert-file-contents 
  ("file:///home/gustavo/test/Ã¡Ã§Ã£Ã¼.org" t nil nil nil))
  url-file-handler(insert-file-contents 
  "file:///home/gustavo/test/Ã¡Ã§Ã£Ã¼.org" t nil nil nil)
  insert-file-contents("file:///home/gustavo/test/Ã¡Ã§Ã£Ã¼.org" t)
  find-file-noselect-1(#<buffer Ã¡Ã§Ã£Ã¼.org> 
  "file:///home/gustavo/test/Ã¡Ã§Ã£Ã¼.org" nil nil "~/test/Ã¡Ã§Ã£Ã¼.org" 
  nil)
  find-file-noselect("file:///home/gustavo/test/\303\241\303\247\303\243\303\274.org" 
  nil nil nil)
  find-file-other-window("file:///home/gustavo/test/\303\241\303\247\303\243\303\274.org")
  browse-url-emacs("file:///home/gustavo/test/\303\241\303\247\303\243\303\274.org" 
  nil)
  browse-url("file:///home/gustavo/test/\303\241\303\247\303\243\303\274.org")
  browse-url-of-file("/home/gustavo/test/áçãü.org")
  browse-url-of-dired-file()
  funcall-interactively(browse-url-of-dired-file)
  command-execute(browse-url-of-dired-file)
#+end_example

Since I use this functionality somewhat regularly, and hadn't met it 
with 27.2, as far as I can tell this is a regression since then.

Best regards,
Gustavo.

In GNU Emacs 28.0.91 (build 2, x86_64-pc-linux-gnu, GTK+ Version 
3.24.20, cairo version 1.16.0)
 of 2022-03-04 built on gusbrs-laptop
Windowing system distributor 'The X.Org Foundation', version 
11.0.12013000
System Description: Linux Mint 20.3

Configured using:
 'configure --with-mailutils --with-xwidgets --with-modules
 --with-native-compilation'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: pt_BR.UTF-8
  value of $LC_NUMERIC: pt_BR.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Dired by name

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
derived epg rfc6068 epg-config gnus-util rmail rmail-loaddefs
text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mail-utils time-date help-fns radix-tree cl-extra cl-print debug
backtrace help-mode find-func mm-util mail-prsvr url-cache url-auth
url-file url-dired url-handlers browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map seq byte-opt gv bytecomp byte-compile
cconv url-vars mailcap cus-start cus-load dired-aux cl-loaddefs cl-lib
dired dired-loaddefs iso-transl tooltip eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd 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 cl-generic 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 simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads xwidget-internal dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 113226 6824)
 (symbols 48 8669 0)
 (strings 32 32041 1780)
 (string-bytes 1 920017)
 (vectors 16 16783)
 (vector-slots 8 347621 13344)
 (floats 8 35 40)
 (intervals 56 857 0)
 (buffers 992 17))