Subject: Re: bug#13780: 24.2; Making find-file-hook customizable seems to cause troublle

From: Stefan Kangas <[email-masked]>
Date: Wed, 28 Oct 2020 01:52:42 -0700

Stefan Monnier <[email-masked]> writes:

>>> So until Custom ...blabla... I think it's better to use defcustom for
>>> hooks very sparingly, i.e. only for those hook we can reasonably
>>> expect will only be modified by the user's customization.
>> So do you think the existing customization ability for find-file-hook
>> should be removed? Or at least some kind of warning attached?
>
> Yes,

So how about the attached?
From d504f7a02ff1adcee60b9569e6a161d50e7e37c7 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Wed, 28 Oct 2020 09:51:05 +0100
Subject: [PATCH] Don't allow customizing find-file-hook

* lisp/files.el (find-file-hook): Make into defvar.  (Bug#13780)
---
 lisp/files.el | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index fdf758ad92..3d3dece691 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -498,15 +498,11 @@ find-file-not-found-functions
 ;;;(put 'find-file-hook 'permanent-local t)
 ;; I found some external files still using the obsolete form in 2018.
 (define-obsolete-variable-alias 'find-file-hooks 'find-file-hook "22.1")
-(defcustom find-file-hook nil
+(defvar find-file-hook nil
   "List of functions to be called after a buffer is loaded from a file.
 The buffer's local variables (if any) will have been processed before the
 functions are called.  This includes directory-local variables, if any,
-for the file's directory."
-  :group 'find-file
-  :type 'hook
-  :options '(auto-insert)
-  :version "22.1")
+for the file's directory.")
 
 ;; I found some external files still using the obsolete form in 2018.
 (define-obsolete-variable-alias 'write-file-hooks 'write-file-functions "22.1")
-- 
2.28.0