fix(lib): doom/set-indent-width on Emacs >=30
A built-in `editorconfig` package was added in Emacs 30, with a somewhat different API from the other package of the same name. Fix: #8072
This commit is contained in:
parent
d34770407c
commit
66a2972ebf
2 changed files with 11 additions and 2 deletions
|
@ -368,7 +368,15 @@ editorconfig or dtrt-indent installed."
|
||||||
(setq-local standard-indent width)
|
(setq-local standard-indent width)
|
||||||
(when (boundp 'evil-shift-width)
|
(when (boundp 'evil-shift-width)
|
||||||
(setq evil-shift-width width))
|
(setq evil-shift-width width))
|
||||||
(cond ((require 'editorconfig nil t)
|
;; REVIEW: Only use `editorconfig' once we drop 29.x support.
|
||||||
|
(cond ((let ((load-path (get 'load-path 'initial-value)))
|
||||||
|
;; A built-in `editorconfig' package was added in Emacs 30.x, but
|
||||||
|
;; with a different API. Since it's built in, prefer it over the
|
||||||
|
;; upstream one, but we still need to adapt:
|
||||||
|
(require 'editorconfig nil t))
|
||||||
|
(pcase-dolist (`(,var . ,val) (editorconfig--default-indent-size-function width))
|
||||||
|
(set (make-local-variable var) val)))
|
||||||
|
((require 'editorconfig nil t)
|
||||||
(let (editorconfig-lisp-use-default-indent)
|
(let (editorconfig-lisp-use-default-indent)
|
||||||
(editorconfig-set-indentation nil width)))
|
(editorconfig-set-indentation nil width)))
|
||||||
((require 'dtrt-indent nil t)
|
((require 'dtrt-indent nil t)
|
||||||
|
@ -376,7 +384,7 @@ editorconfig or dtrt-indent installed."
|
||||||
(dolist (var (ensure-list vars))
|
(dolist (var (ensure-list vars))
|
||||||
(doom-log "Updated %s = %d" var width)
|
(doom-log "Updated %s = %d" var width)
|
||||||
(set var width)))))
|
(set var width)))))
|
||||||
(message "Changed indentation to %d" width))
|
(message "Changed buffer's indent-size to %d" width))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
;;; tools/editorconfig/config.el -*- lexical-binding: t; -*-
|
;;; tools/editorconfig/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; TODO: Adapt to built-in `editorconfig' in Emacs 30+
|
||||||
;; Handles whitespace (tabs/spaces) settings externally. This way projects can
|
;; Handles whitespace (tabs/spaces) settings externally. This way projects can
|
||||||
;; specify their own formatting rules.
|
;; specify their own formatting rules.
|
||||||
(use-package! editorconfig
|
(use-package! editorconfig
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue