]> code.delx.au - dotemacs/commitdiff
improve my/substitute-line
authorJames Bunton <jamesbunton@delx.net.au>
Thu, 28 Jul 2016 11:53:58 +0000 (21:53 +1000)
committerJames Bunton <jamesbunton@delx.net.au>
Thu, 28 Jul 2016 13:43:13 +0000 (23:43 +1000)
lisp/my-defuns.el

index 1e1a6303e23764ea80c64608d3ed79b39f5a3490..d9de53ac31ea3f45493f7866b214c40a14da7e84 100644 (file)
 
 (defun my/substitute-line (arg)
   "Kill the current line and leave point at correct indentation level. With ARG kill that many lines first."
-  (interactive "*p")
+  (interactive "*P")
   (beginning-of-line)
-  (kill-line arg)
-  (indent-for-tab-command))
+  (if (not (and (null arg) (equal (line-beginning-position) (line-end-position))))
+      (kill-line arg))
+  (if (not (string-equal major-mode "fundamental-mode"))
+      (indent-for-tab-command)))
 
 (defun my/yank (arg)
   "If the text to be yanked has a newline then move to beginning of line before yanking. Otherwise same as normal `yank'."