<commit_before>;;; emacs/electric/autoload.el -*- lexical-binding: t; -*-

;;;###autodef
(defun set-electric! (modes &rest plist)
  "Declare :words (list of strings) or :chars (lists of chars) in MODES that
trigger electric indentation."
  (declare (indent 1))
  (unless plist
    (signal 'wrong-number-of-arguments
            (list '(:char :words) plist)))
  (cl-destructuring-bind (&key chars words) plist
    (dolist (mode (doom-enlist modes))
      (let ((fn (intern (format "+electric|init-%s" mode))))
        (fset fn
              (lambda ()
                (electric-indent-local-mode +1)
                (if chars (setq electric-indent-chars chars))
                (if words (setq +electric-indent-words words))))
        (add-hook (intern (format "%s-hook" mode)) fn)))))

;; FIXME obsolete :electric
;;;###autoload
(def-setting! :electric (modes &rest plist)
  :obsolete set-electric!
  `(set-electric! ,modes ,@plist))
<commit_msg>Add unset capability to set-electric!<commit_after>;;; emacs/electric/autoload.el -*- lexical-binding: t; -*-

;;;###autodef
(defun set-electric! (modes &rest plist)
  "Declare :words (list of strings) or :chars (lists of chars) in MODES that
trigger electric indentation."
  (declare (indent 1))
  (dolist (mode (doom-enlist modes))
    (let ((hook (intern (format "%s-hook" mode)))
          (fn   (intern (format "+electric|init-%s" mode))))
      (cond ((null (car-safe plist))
             (remove-hook hook fn)
             (unintern fn nil))
            ((fset fn
                   (lambda ()
                     (cl-destructuring-bind (&key chars words) plist
                       (electric-indent-local-mode +1)
                       (if chars (setq electric-indent-chars chars))
                       (if words (setq +electric-indent-words words)))))
             (add-hook hook fn))))))

;; FIXME obsolete :electric
;;;###autoload
(def-setting! :electric (modes &rest plist)
  :obsolete set-electric!
  `(set-electric! ,modes ,@plist))

{'fraction_non_alphanumeric': 0.15557778889444723, 'fraction_numerical': 0.002001000500250125, 'mean_word_length': 2.5650623885918002, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2744592', 'n_tokens_mistral': 669, 'n_tokens_neox': 616, 'n_words': 182}