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

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

[elpa] externals/dts-mode acc7e07 1/4: don't move the point when indenti


From: Stefan Monnier
Subject: [elpa] externals/dts-mode acc7e07 1/4: don't move the point when indenting
Date: Sat, 27 Mar 2021 13:58:26 -0400 (EDT)

branch: externals/dts-mode
commit acc7e079a11c2aba71db88d2e8f1abf6dc3eebef
Author: jpkotta <jpkotta@gmail.com>
Commit: GitHub <noreply@github.com>

    don't move the point when indenting
    
    if the line is not empty and the point is in the text, keep the point at 
the same place in the text
    otherwise (line is only indentation or point is in the indentation), move 
to the end of indentation
---
 dts-mode.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dts-mode.el b/dts-mode.el
index 2ee2f44..86023a7 100644
--- a/dts-mode.el
+++ b/dts-mode.el
@@ -89,7 +89,10 @@
 (defun dts-indent-line ()
   (interactive)
   (let ((indent (dts--calculate-indentation)))
-    (indent-line-to (* indent tab-width))))
+    (save-excursion
+      (indent-line-to (* indent tab-width)))
+    (when (or (bolp) (looking-back "^[[:space:]]+"))
+      (beginning-of-line-text))))
 
 (defalias 'dts-parent-mode
   (if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))



reply via email to

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