From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/elisp/smie-indentation-example.html | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 devdocs/elisp/smie-indentation-example.html (limited to 'devdocs/elisp/smie-indentation-example.html') diff --git a/devdocs/elisp/smie-indentation-example.html b/devdocs/elisp/smie-indentation-example.html new file mode 100644 index 00000000..91dbad87 --- /dev/null +++ b/devdocs/elisp/smie-indentation-example.html @@ -0,0 +1,45 @@ +

Sample Indentation Rules

Here is an example of an indentation function:

(defun sample-smie-rules (kind token)
+  (pcase (cons kind token)
+    (`(:elem . basic) sample-indent-basic)
+    (`(,_ . ",") (smie-rule-separator kind))
+    (`(:after . ":=") sample-indent-basic)
+    (`(:before . ,(or `"begin" `"(" `"{"))
+     (if (smie-rule-hanging-p) (smie-rule-parent)))
+    (`(:before . "if")
+     (and (not (smie-rule-bolp)) (smie-rule-prev-p "else")
+          (smie-rule-parent)))))
+
+

A few things to note:

+

+ Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc.
Licensed under the GNU GPL license.
+ https://www.gnu.org/software/emacs/manual/html_node/elisp/SMIE-Indentation-Example.html +

+
-- cgit v1.2.3