From 617c9b107ff809bbb78c2a0c3b9320cda5eee335 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 28 Apr 2025 13:35:09 -0400 Subject: [PATCH] (Custom-dirlocals-mode): Let `define-derived-mode` do its job * lisp/cus-edit.el (Custom-dirlocals-mode-map): Rename from `custom-dirlocals-map`. (Custom-dirlocals-menu): Adjust accordingly. (Custom-dirlocals-mode): Let `define-derived-mode` do its job. Use `run-mode-hooks`. (cherry picked from commit a0f26f3eaf1ccde728806003932dc9e44ef07e9d) --- lisp/cus-edit.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 2b76c2b9b19..5b01d4a27c3 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -5966,7 +5966,9 @@ This stores EXP (without evaluating it) as the saved spec for SYMBOL." (defvar-local custom-dirlocals-file-widget nil "Widget that holds the name of the dir-locals file being customized.") -(defvar-keymap custom-dirlocals-map +(define-obsolete-variable-alias 'custom-dirlocals-map + 'Custom-dirlocals-mode-map "31.1") +(defvar-keymap Custom-dirlocals-mode-map :doc "Keymap used in the \"*Customize Dirlocals*\" buffer." :full t :parent widget-keymap @@ -5998,7 +6000,7 @@ This stores EXP (without evaluating it) as the saved spec for SYMBOL." See `custom-commands' for further explanation.") (easy-menu-define - Custom-dirlocals-menu (list custom-dirlocals-map + Custom-dirlocals-menu (list Custom-dirlocals-mode-map custom-dirlocals-field-map) "Menu used in dirlocals customization buffers." (nconc (list "Custom" @@ -6110,14 +6112,8 @@ Moves point into the widget that holds the value." (add-hook 'widget-forward-hook #'custom-dirlocals-maybe-update-cons nil t)) (define-derived-mode Custom-dirlocals-mode nil "Custom dirlocals" - "Major mode for customizing Directory Local Variables in current directory. -Entry to this mode calls the value of `Custom-mode-hook' if its value -is non-nil. - -\\{custom-dirlocals-map}" - (kill-all-local-variables) + "Major mode for customizing Directory Local Variables in current directory." (custom-dirlocals--set-widget-vars) - (setq-local major-mode #'Custom-dirlocals-mode) (setq-local text-conversion-style 'action) (setq-local touch-screen-keyboard-function #'Custom-display-on-screen-keyboard-p) @@ -6129,13 +6125,17 @@ is non-nil. (mapc (lambda (arg) (tool-bar-local-item-from-menu - (nth 1 arg) (nth 4 arg) map custom-dirlocals-map + (nth 1 arg) (nth 4 arg) map Custom-dirlocals-mode-map :label (nth 5 arg))) custom-dirlocals-commands) (setq custom-dirlocals-tool-bar-map map)))) - (use-local-map custom-dirlocals-map) - (run-hooks 'Custom-mode-hook)) + (run-mode-hooks 'Custom-mode-hook)) +;; As discussed in bug#77228, deriving from `Custom-mode' would +;; include all their settings that are not necessary for +;; `customize-dirlocals' and that can break it. +;; FIXME: Introduce a `Custom-base-mode', which could be useful +;; also for `gnus-custom-mode'. (derived-mode-add-parents 'Custom-dirlocals-mode '(Custom-mode)) (defmacro custom-dirlocals-with-buffer (&rest body) -- 2.39.5