]> code.delx.au - dotemacs/blob - text-edit/my-line-editing.el
Massive update!
[dotemacs] / text-edit / my-line-editing.el
1 ;;; -*- lexical-binding: t -*-
2
3 (defun my/copy-line (arg)
4 "Copy the current line into the kill ring. With ARG copies that many lines."
5 (interactive "p")
6 (kill-ring-save (line-beginning-position 1)
7 (line-beginning-position (+ 1 arg)))
8 (message "Copied %d lines" arg))
9
10 (defun my/open-line-above (arg)
11 "Open a new line above point with indentation. With ARG insert that many lines."
12 (interactive "*p")
13 (beginning-of-line)
14 (newline arg)
15 (forward-line (- arg))
16 (indent-for-tab-command))
17
18 (defun my/open-line-below (arg)
19 "Open a new line below point with indentation. With ARG insert that many lines."
20 (interactive "*p")
21 (end-of-line)
22 (newline arg)
23 (indent-for-tab-command))
24
25 (defun my/substitute-line (arg)
26 "Kill the current line and leave point at correct indentation level. With ARG kill that many lines first."
27 (interactive "*P")
28 (beginning-of-line)
29 (if (not (and (null arg) (equal (line-beginning-position) (line-end-position))))
30 (kill-line arg))
31 (if (not (string-equal major-mode "fundamental-mode"))
32 (indent-for-tab-command)))
33
34 (provide 'my-line-editing)