Subject: Re: bug#55149: 29.0.50; Commit f30625943e broke magit/with-editor

From: Tassilo Horn <[email-masked]>
Date: Thu, 28 Apr 2022 06:47:50 +0200

"M. Ian Graham" <[email-masked]> writes:

>> With stock-emacs when doing "emacsclient foo.txt", it just prints
>> "Waiting for Emacs..." but finishes immediately.
>
> Hi, quick clarification on this: As far as I can tell from my own
> observations, all emacsclient breakage here is a downstream
> side-effect of magit/with-editor's advice calls somehow getting messed
> up.

Oh, you are right.  But I was able to extract (at least one of) the
problematic with-editor advice(s) which cause the breakage.

Save the below as bug-recipe.el:

--8<---------------cut here---------------start------------->8---
(advice-add 'server-visit-files :after
            #'server-visit-files--with-editor-file-name-history-exclude)

(defun server-visit-files--with-editor-file-name-history-exclude
    (files _proc &optional _nowait)
  (pcase-dolist (`(,file . ,_) files)
    (when (cl-find-if (lambda (regexp)
                        (string-match-p regexp file))
                      '("don't care"))
      (setq file-name-history (delete file file-name-history)))))

(server-start)
--8<---------------cut here---------------end--------------->8---

Then start emacs as "emacs -Q -l bug-recipe.el" and you'll be able to
perform my "stock emacs" recipe, i.e.,

  emacsclient foo.txt => finishes immediately
  emacsclient -c foo.txt => doesn't display the foo.txt buffer

Bye,
Tassilo