diff options
| author | Elías Gabriel Pérez | 2025-03-23 21:26:26 -0600 |
|---|---|---|
| committer | Eli Zaretskii | 2025-04-24 15:02:15 +0300 |
| commit | 6414ed0d1166b0f24515ce92bb6db2c3d718a96a (patch) | |
| tree | 1996b25b1d930d499c1b70633baec43b9793314a | |
| parent | 4b7816fc804813287e75544f8d016be6eca08873 (diff) | |
| download | emacs-6414ed0d1166b0f24515ce92bb6db2c3d718a96a.tar.gz emacs-6414ed0d1166b0f24515ce92bb6db2c3d718a96a.zip | |
Create major mode for `customize-dirlocals` (bug#77228)
* lisp/cus-edit.el (Custom-dirlocals-mode): New major mode.
(custom-dirlocals-with-buffer): Move settings to
`Custom-dirlocals-mode'.
| -rw-r--r-- | lisp/cus-edit.el | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index b260ea5fe95..fc05f8ebc7c 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el | |||
| @@ -6062,31 +6062,47 @@ Moves point into the widget that holds the value." | |||
| 6062 | (custom--initialize-widget-variables) | 6062 | (custom--initialize-widget-variables) |
| 6063 | (add-hook 'widget-forward-hook #'custom-dirlocals-maybe-update-cons nil t)) | 6063 | (add-hook 'widget-forward-hook #'custom-dirlocals-maybe-update-cons nil t)) |
| 6064 | 6064 | ||
| 6065 | (define-derived-mode Custom-dirlocals-mode nil "Custom dirlocals" | ||
| 6066 | "Major mode for customize Directory Local Variables in the current directory. | ||
| 6067 | Entry to this mode calls the value of `Custom-mode-hook' if that value | ||
| 6068 | is non-nil. | ||
| 6069 | |||
| 6070 | \\{custom-dirlocals-map}" | ||
| 6071 | (kill-all-local-variables) | ||
| 6072 | (custom-dirlocals--set-widget-vars) | ||
| 6073 | (setq-local major-mode #'Custom-dirlocals-mode) | ||
| 6074 | (setq-local text-conversion-style 'action) | ||
| 6075 | (setq-local touch-screen-keyboard-function | ||
| 6076 | #'Custom-display-on-screen-keyboard-p) | ||
| 6077 | (setq-local revert-buffer-function #'Custom-dirlocals-revert-buffer) | ||
| 6078 | (setq-local tool-bar-map | ||
| 6079 | (or custom-dirlocals-tool-bar-map | ||
| 6080 | ;; Set up `custom-dirlocals-tool-bar-map'. | ||
| 6081 | (let ((map (make-sparse-keymap))) | ||
| 6082 | (mapc | ||
| 6083 | (lambda (arg) | ||
| 6084 | (tool-bar-local-item-from-menu | ||
| 6085 | (nth 1 arg) (nth 4 arg) map custom-dirlocals-map | ||
| 6086 | :label (nth 5 arg))) | ||
| 6087 | custom-dirlocals-commands) | ||
| 6088 | (setq custom-dirlocals-tool-bar-map map)))) | ||
| 6089 | (use-local-map custom-dirlocals-map) | ||
| 6090 | (run-hooks 'Custom-mode-hook)) | ||
| 6091 | |||
| 6092 | (derived-mode-add-parents 'Custom-dirlocals-mode '(Custom-mode)) | ||
| 6093 | |||
| 6065 | (defmacro custom-dirlocals-with-buffer (&rest body) | 6094 | (defmacro custom-dirlocals-with-buffer (&rest body) |
| 6066 | "Arrange to execute BODY in a \"*Customize Dirlocals*\" buffer." | 6095 | "Arrange to execute BODY in a \"*Customize Dirlocals*\" buffer." |
| 6067 | ;; We don't use `custom-buffer-create' because the settings here | 6096 | ;; We don't use `custom-buffer-create' because the settings here |
| 6068 | ;; don't go into the `custom-file'. | 6097 | ;; don't go into the `custom-file'. |
| 6069 | `(progn | 6098 | `(progn |
| 6070 | (switch-to-buffer "*Customize Dirlocals*") | 6099 | (switch-to-buffer "*Customize Dirlocals*") |
| 6071 | (kill-all-local-variables) | 6100 | |
| 6072 | (let ((inhibit-read-only t)) | 6101 | (let ((inhibit-read-only t)) |
| 6073 | (erase-buffer)) | 6102 | (erase-buffer)) |
| 6074 | (remove-overlays) | 6103 | (remove-overlays) |
| 6075 | (custom-dirlocals--set-widget-vars) | 6104 | (Custom-dirlocals-mode) |
| 6076 | ,@body | 6105 | ,@body |
| 6077 | (setq-local tool-bar-map | ||
| 6078 | (or custom-dirlocals-tool-bar-map | ||
| 6079 | ;; Set up `custom-dirlocals-tool-bar-map'. | ||
| 6080 | (let ((map (make-sparse-keymap))) | ||
| 6081 | (mapc | ||
| 6082 | (lambda (arg) | ||
| 6083 | (tool-bar-local-item-from-menu | ||
| 6084 | (nth 1 arg) (nth 4 arg) map custom-dirlocals-map | ||
| 6085 | :label (nth 5 arg))) | ||
| 6086 | custom-dirlocals-commands) | ||
| 6087 | (setq custom-dirlocals-tool-bar-map map)))) | ||
| 6088 | (setq-local revert-buffer-function #'Custom-dirlocals-revert-buffer) | ||
| 6089 | (use-local-map custom-dirlocals-map) | ||
| 6090 | (widget-setup))) | 6106 | (widget-setup))) |
| 6091 | 6107 | ||
| 6092 | (defun custom-dirlocals-get-options () | 6108 | (defun custom-dirlocals-get-options () |