Guest User

Untitled

a guest
Feb 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.68 KB | None | 0 0
  1. (defun duplicate-start-of-line-or-region ()
  2.   (interactive)
  3.   (if mark-active
  4.       (duplicate-region)
  5.     (duplicate-start-of-line)))
  6.  
  7. (defun duplicate-start-of-line ()
  8.   (let ((text (buffer-substring (point)
  9.                                 (progn (beginning-of-line) (point)))))
  10.     (if (eq (progn (end-of-line) (point)) (point-max))
  11.         (newline)
  12.       (forward-line))
  13.     (push-mark)
  14.     (insert text)
  15.     (open-line 1)))
  16.  
  17. (defun duplicate-region ()
  18.   (let* ((end (region-end))
  19.          (text (buffer-substring (region-beginning)
  20.                                  end)))
  21.     (goto-char end)
  22.     (insert text)
  23.     (push-mark end)
  24.     (setq deactivate-mark nil)
  25.     (exchange-point-and-mark)))
Add Comment
Please, Sign In to add comment