From 7557a1cf1e537313b73a3efa94cdb8a6154e4a76 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Tue, 29 Mar 2016 13:34:39 +0100 Subject: [PATCH] Switch from move-text to move-dup package This allows me to remove the custom method for duplicating line, as move-dup comes with a nice implementation. --- core/siren-core.el | 22 ---------------------- modules/siren-global-keybindings.el | 3 --- modules/siren-text-manipulation.el | 8 +++++--- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/core/siren-core.el b/core/siren-core.el index 8d9d960..29b43a0 100644 --- a/core/siren-core.el +++ b/core/siren-core.el @@ -42,28 +42,6 @@ Position the cursor at it's beginning, according to the current mode." (interactive) (other-window -1)) -(defun siren-duplicate-current-line-or-region (arg) - "Duplicates the current line or region ARG times. -If there's no region, the current line will be duplicated. However, if -there's a region, all lines that region covers will be duplicated. - -Borrowed from: http://tuxicity.se/emacs/elisp/2010/03/11/duplicate-current-line-or-region-in-emacs.html" - (interactive "p") - (let (beg end (origin (point))) - (if (and mark-active (> (point) (mark))) - (exchange-point-and-mark)) - (setq beg (line-beginning-position)) - (if mark-active - (exchange-point-and-mark)) - (setq end (line-end-position)) - (let ((region (buffer-substring-no-properties beg end))) - (dotimes (i arg) - (goto-char end) - (newline) - (insert region) - (setq end (point))) - (goto-char (+ origin (* (length region) arg) arg))))) - (defun siren-toggle-hiding (column) "Toggle hiding/showing blocks via hs-mode. diff --git a/modules/siren-global-keybindings.el b/modules/siren-global-keybindings.el index fc02ae1..01e128c 100644 --- a/modules/siren-global-keybindings.el +++ b/modules/siren-global-keybindings.el @@ -15,9 +15,6 @@ ;; Evaluate buffer (global-set-key (kbd "C-c C-e") 'eval-buffer) -;; Duplicate line -(global-set-key (kbd "C-x C-d") 'siren-duplicate-current-line-or-region) - ;; Window switching (global-set-key (kbd "C-x i") 'siren-other-window-reverse) (global-set-key (kbd "C-x C-o") 'other-window) diff --git a/modules/siren-text-manipulation.el b/modules/siren-text-manipulation.el index 2eb4b95..61cf932 100644 --- a/modules/siren-text-manipulation.el +++ b/modules/siren-text-manipulation.el @@ -7,7 +7,7 @@ ;;; Code: -(siren-require-packages '(move-text expand-region)) +(siren-require-packages '(move-dup expand-region)) (require 'move-text) (require 'expand-region) @@ -46,8 +46,10 @@ A place is considered `tab-width' character columns." (siren-shift-right (* -1 (or arg 1)))) ;; Keybindings -(define-key global-map (kbd "M-p") 'move-text-up) -(define-key global-map (kbd "M-n") 'move-text-down) +(global-set-key (kbd "M-p") 'md/move-lines-up) +(global-set-key (kbd "M-n") 'md/move-lines-down) +(global-set-key (kbd "C-x C-d") 'md/duplicate-up) +;; (global-set-key (kbd "C-x C-d") 'md/duplicate-down) (global-set-key (kbd "C-c [") 'siren-shift-left) (global-set-key (kbd "C-c ]") 'siren-shift-right)