emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] scratch/editorconfig-cc ca7aeff4b3 159/351: Add variable to dis


From: Stefan Monnier
Subject: [nongnu] scratch/editorconfig-cc ca7aeff4b3 159/351: Add variable to disable indent_size when conditions are met for lisp
Date: Thu, 13 Jun 2024 18:38:49 -0400 (EDT)

branch: scratch/editorconfig-cc
commit ca7aeff4b38bcb028d3529d8e3902cc0374d3611
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Add variable to disable indent_size when conditions are met for lisp
---
 editorconfig.el | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/editorconfig.el b/editorconfig.el
index a2cd19746c..5564d18a34 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -232,6 +232,16 @@ Set by `editorconfig-apply' and nil if that is not invoked 
in
 current buffer yet.")
 (make-variable-buffer-local 'editorconfig-properties-hash)
 
+(defvar editorconfig-lisp-use-default-indent nil
+  "Selectively ignore the value of indent_sizefor Lisp files.
+Prevents `lisp-indent-offset' from being set selectively.
+
+nil - `lisp-indent-offset' is always set normally.
+t   - `lisp-indent-offset' is never set normally
+       (always use default indent for lisps).
+number - `lisp-indent-offset' is not set only if indent_size is
+         equal to this number.  For example, if this is set to 2,
+         `lisp-indent-offset'will not be set only if indent_size is 2.")
 
 (defun editorconfig-string-integer-p (string)
   "Return non-nil if STRING represents integer."
@@ -246,6 +256,19 @@ current buffer yet.")
   "Set `latex-mode' indent size to SIZE."
   )
 
+(defun editorconfig--should-set (size symbol)
+  "Determines if editorconfig should set SYMBOL using SIZE."
+  (if (eq symbol 'lisp-indent-offset)
+      (cond
+       ((eql nil editorconfig-lisp-use-default-indent)
+        t)
+       ((eql t editorconfig-lisp-use-default-indent)
+        nil)
+       ((numberp editorconfig-lisp-use-default-indent)
+        (not (eql size editorconfig-lisp-use-default-indent)))
+       (t t))
+    t))
+
 (defun editorconfig-set-indentation (style &optional size tab_width)
   "Set indentation type from STYLE, SIZE and TAB_WIDTH."
   (if (editorconfig-string-integer-p size)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]