Subject: bug#77228: [PATCH] ; * lisp/cus-edit.el (custom-dirlocals-with-buffer): Use Custom-mode

From: Mauro Aranda <[email-masked]>
Date: Fri, 4 Apr 2025 07:49:55 -0300

[ Resending ]

Elijah Gabe Pérez <[email-masked]> writes:

 > Mauro Aranda <[email-masked]> writes:
 >
 >  Elijah Gabe Pérez <[email-masked]> writes:
 >
 >  Tags: patch
 >
 >  Little patch for make customize-dirlocals use Custom-mode instead
 >  fundamental-mode, Mostly intended for make this inherit and use
 >  Custom-mode-hook.
 >
 >  I have tested it and at the moment it does not cause problems with the
 >  configuration made.
 >
 >  Yes, I don't anticipate any real problems, but just using Custom-mode is
 >  almost entirely redundant since some of the settings that it performs
 >  are not relevant, and others get clobbered right away.
 >
 >  Overriden:
 >  custom-mode-map, tool-bar-map, revert-buffer-function.
 >
 >  Not relevant:
 >  custom–invocation-options, custom–hidden-state, custom-options,
 >  custom-local-buffer, widget-edit-functions.
 >
 >  Redundant:
 >  custom–initialize-widget-variables.
 >
 >  That just leaves us with the text-conversion-style and
 >  touch-screen-keyboard-function settings, which my guess is that they
 >  should've been added to custom-dirlocals-with-buffer too, and of course,
 >  running Custom-mode-hook.
 >
 >  So I think it'd be better either to derive from Custom-mode, or find a
 >  way to avoid the redundant settings.
 >
 > But making it derived won't include Custom-mode options anyway?

Yes, but we could arrange for Custom-mode to set the right values, I
think. Although maybe it's not worth it.

 > I made it a major mode but not derived from it.
 > I've included the Custom-mode options that are useful (as you pointed)
 > and run Custom-mode-hook.

Anyway, I'm OK with this. Maybe we can use derived-mode-add-parents to
be clear that we consider Custom-mode a parent of this new mode. Some
comments below:

 > * lisp/cus-edit.el (Custom-dirlocals-mode): New major mode.
 > (custom-dirlocals-with-buffer): Move stuffs to
 > `Custom-dirlocals-mode'.

"stuff".

 > +(define-derived-mode Custom-dirlocals-mode nil "Custom dirlocals"
 > +  "Major mode for Customize Directory Local Variables in the current 
directory."

Please mention that it runs Custom-mode-hook too.

Let's see if somebody else has an opinion. I'm on a trip for the
weekend, so it won't be until next week that I can install this.