Subject: Re: bug#38818: Dired: mention deleting buffers, not just windows

From: Michael Heerdegen <[email-masked]>
Date: Thu, 02 Jan 2020 05:14:15 +0100

Pieter van Oostrum <[email-masked]> writes:

> > Slightly better version:
> >
> > (add-hook
> >  'dired-load-hook
> >  (defun my-dired-load-hook-fun ()
> >    (require 'dired-x)
> >    (define-key dired-mode-map "q" #'kill-current-buffer)))
>
> The documentation of defun says that its result is undefined. So either
> it should not be relied upon, or (if the result is reliably the defined
> function) it should be documented as such.

Indeed: the return value of `defun' even changed recently (from
returning the definition to returning the defined symbol).  Same for
defalias.

I think I'll file another bug report: adding user defined functions to
hooks not only has the common pitfall which is not warned about - the
alternative, using named functions, is also quite inconvenient since
defun's return value is unspecified.  I guess most users currently do it
wrong.  Or do I miss something?

Thanks,

Michael.