Setup indenting for gdict mode.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 23 Mar 2016 17:25:09 +0200
changeset 382 9a596f1366ac
parent 381 1729e4655e4d
child 383 9372e3b5b47e
Setup indenting for gdict mode.
contrib/gadict.el
--- a/contrib/gadict.el	Wed Mar 23 11:29:19 2016 +0200
+++ b/contrib/gadict.el	Wed Mar 23 17:25:09 2016 +0200
@@ -37,6 +37,10 @@
           (font-lock-multiline . t) ))
   (add-hook 'font-lock-extend-region-functions 'gadict-font-lock-extend-region t) )
 
+(defun gadict-setup-syntax ()
+  "Setup gadict characters syntax."
+  (modify-syntax-entry ?' "w"))
+
 (defun gadict-setup-comment ()
   "Setup gadict comment commands."
   (set (make-local-variable 'comment-start)  "#")
@@ -55,9 +59,19 @@
   "Setup gadict page definition."
   (set (make-local-variable 'page-delimiter)  "__$") )
 
-(defun gadict-setup-syntax ()
-  "Setup gadict characters syntax."
-  (modify-syntax-entry ?' "w"))
+(defvar gadict-indent-offset 2
+  "Indent level.")
+
+(defun gadict-indent-line ()
+  "Indent line in gdict mode."
+  (let ( (indent ) )
+    (if (eq (current-indentation) gadict-indent-offset)
+      (indent-line-to 0)
+    (indent-line-to gadict-indent-offset))))
+
+(defun gadict-setup-indent ()
+  "Setup indenting for gdict mode."
+  (set (make-local-variable 'indent-line-function) 'gadict-indent-line))
 
 (defun gadict-mark-article ()
   "Mark current article."
@@ -135,6 +149,7 @@
   (gadict-setup-paragraph)
   (gadict-setup-page)
   (gadict-setup-comment)
+  (gadict-setup-indent)
   (gadict-setup-expansions) )
 
 (provide 'gadict)