Subject: bug#78990: closed (Re: bug#78990: 30.1; Show-font breaks `insert-file-contents-literally')

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 19 Jul 2025 08:38:02 +0000

Your bug report

#78990: 30.1; Show-font breaks `insert-file-contents-literally'

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
78990: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78990
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#78990: 30.1; Show-font breaks `insert-file-contents-literally'
From: Eli Zaretskii <[email-masked]>
To: Zhengyi Fu <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked]
Date: Sat, 19 Jul 2025 11:37:03 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Cc: [email-masked], [email-masked]
> From: Zhengyi Fu <[email-masked]>
> Date: Sat, 12 Jul 2025 15:44:03 +0800
> 
> Protesilaos Stavrou <[email-masked]> writes:
> 
> > On 2025-07-11 12:58, Zhengyi Fu wrote:
> >> Protesilaos Stavrou <[email-masked]> writes:
> >> 
> >>> On 2025-07-10 15:27, Zhengyi Fu wrote:
> >>>> Thank you for your fast reply.
> >>> You are welcome!
> >>> 
> >>>> No.  Actually, I don't know how to fix it correctly.
> >>> Okay, no worries! Let's try to do this together. I have not tried
> >>> 'insert-file-contents-literally' before. Please evaluate the following
> >>> function and try again.
> >>> (defun show-font--insert-button ()
> >>>   "Insert `show-font-installed-file-button' at point."
> >>>   (when buffer-file-name
> >>>     (insert
> >>>      (propertize "Cannot preview this font" 'face 'show-font-title)
> >>>      "\n\n"
> >>>      (propertize buffer-file-name 'face 'bold)
> >>>      " is not installed"
> >>>      "\n\n"
> >>>      "Install this font file?"
> >>>      "\n")
> >>>     (goto-char (point-max))
> >>>     (make-text-button (line-beginning-position 0) (line-end-position
> >>>     0) :type 'show-font-installed-file-button)))
> >> After evaluating that fnuction, it doesn't signal errors, but
> >> nothing
> >> gets inserted.
> >
> > I made two changes and bumped the version number. The new package will
> > be available in a few hours. I believe I have fixed the problem. See
> > commits d238f83 and f6239ae in show-font.git.
> 
> It works now!  Thank you very much! 👍

Thanks, I'm therefore closing the bug.

Subject: 30.1; Show-font breaks `insert-file-contents-literally'
From: Zhengyi Fu <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Thu, 10 Jul 2025 20:12:48 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

The package `show-font' adds a file name handler to
`file-name-handler-alist', which causes an error when trying to insert
the raw contents of an TTF file into a buffer with
`insert-file-contents-literally'.

;;;###autoload
(add-to-list 'file-name-handler-alist (cons "\\.\\(ttf\\|otf\\)\\'" #'show-font-handler))

Currently I use the following advice to workaround this behavior, but I
think it's better to fix this either in show-font or in Emacs core.

(define-advice insert-file-contents-literally
    (:around (&rest args) inhibit-show-font)
  (let ((inhibit-file-name-handlers
	 (append '(show-font-handler)
		 (and (eq inhibit-file-name-operation 'insert-file-contents)
		      inhibit-file-name-handlers)))
	(inhibit-file-name-operation 'insert-file-contents))
    (apply args)))