[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 10/35: Add moving lines/region using M-up or M-down. Issue #266
From: |
Matthew Fidler |
Subject: |
[elpa] 10/35: Add moving lines/region using M-up or M-down. Issue #266 |
Date: |
Fri, 11 Jul 2014 22:33:22 +0000 |
mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.
commit cc31671b06a1710045a979cd976d1218ed7ff4c8
Author: Matthew L. Fidler <address@hidden>
Date: Mon Jul 7 09:57:24 2014 -0500
Add moving lines/region using M-up or M-down. Issue #266
---
ergoemacs-functions.el | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
ergoemacs-themes.el | 9 +++++++--
2 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/ergoemacs-functions.el b/ergoemacs-functions.el
index 1e23f62..93bff61 100644
--- a/ergoemacs-functions.el
+++ b/ergoemacs-functions.el
@@ -4,7 +4,7 @@
;; Maintainer: Matthew L. Fidler
;; Authors: Xah Lee, Matthew Fidler, Drew Adams, Ting-Yu Lin, David
-;; Capello, Nikolaj Schumacher
+;; Capello, Nikolaj Schumacher, Andy Stewart
;; Keywords: convenience
;; ErgoEmacs is free software: you can redistribute it and/or modify
@@ -2199,6 +2199,51 @@ See also `ergoemacs-lookup-word-on-internet'."
(let ((apropos-do-all nil))
(apropos-variable regexp)))
+(defun ergoemacs-move-text-internal (arg)
+ "Move region (transient-mark-mode active) or current line."
+ ;; From Andy Stewart, who signed the gnu emacs license since he has
+ ;; components within gnu emacs.
+ ;; See `http://www.emacswiki.org/emacs/basic-edit-toolkit.el'
+ (let ((remember-point (point)))
+ ;; Can't get correct effect of `transpose-lines'
+ ;; when `point-max' is not at beginning of line
+ ;; So fix this bug.
+ (goto-char (point-max))
+ (if (not (bolp)) (newline)) ;add newline to fix
+ (goto-char remember-point)
+ ;; logic code start
+ (cond ((and mark-active transient-mark-mode)
+ (if (> (point) (mark))
+ (exchange-point-and-mark))
+ (let ((column (current-column))
+ (text (delete-and-extract-region (point) (mark))))
+ (forward-line arg)
+ (move-to-column column t)
+ (set-mark (point))
+ (insert text)
+ (exchange-point-and-mark)
+ (setq deactivate-mark nil)))
+ (t
+ (let ((column (current-column)))
+ (beginning-of-line)
+ (when (or (> arg 0) (not (bobp)))
+ (forward-line 1)
+ (when (or (< arg 0) (not (eobp)))
+ (transpose-lines arg))
+ (forward-line -1))
+ (move-to-column column t))))))
+
+(defun ergoemacs-move-text-up (arg)
+ "Move region (transient-mark-mode active) or current line ARG lines up."
+ (interactive "*p")
+ (ergoemacs-move-text-internal (- arg)))
+
+(defun ergoemacs-move-text-down (arg)
+ "Move region (transient-mar-mode active) or current line (ARG lines) down."
+ (interactive "*p")
+ (ergoemacs-move-text-internal arg))
+
+
(defvar ergoemacs-shortcut-keys)
(defvar ergoemacs-no-shortcut-keys)
(defvar ergoemacs-read-input-keys)
diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el
index b0f61f3..f6e9254 100644
--- a/ergoemacs-themes.el
+++ b/ergoemacs-themes.el
@@ -580,6 +580,11 @@
(define-key eshell-mode-map (kbd "M-h") 'eshell-bol)
(define-key comint-mode-map (kbd "M-H") 'comint-bol))
+(ergoemacs-theme-component move-and-transpose-lines ()
+ "Move Current line/selection down or up with Alt+up or Alt+down"
+ (global-set-key [\M-up] 'ergoemacs-move-text-up)
+ (global-set-key [\M-down] 'ergoemacs-move-text-down))
+
(ergoemacs-theme-component move-page ()
"Move by Page"
(global-unset-key (kbd "M-v"))
@@ -1103,7 +1108,7 @@
("Function Keys" (fn-keys f2-edit))
("Remaps" (ido-remaps helm-remaps multiple-cursors-remaps))
("Extreme ErgoEmacs" (guru no-backspace
ergoemacs-banish-shift))
- ("Standard Keys" (standard-fixed fixed-bold-italic quit))
+ ("Standard Keys" (standard-fixed fixed-bold-italic quit
move-and-transpose-lines))
("Keys during Key Sequence" (f2-edit apps-swap
backspace-del-seq))))
(ergoemacs-theme reduction ()
@@ -1144,7 +1149,7 @@
apps-swap
save-options-on-exit)
:optional-off '(guru no-backspace search-reg
- ergoemacs-banish-shift)
+ ergoemacs-banish-shift move-and-transpose-lines)
:options-menu '(("Menu/Apps Key" (apps apps-apps apps-punctuation))
("Function Keys" (fn-keys f2-edit))
("Remaps" (ido-remaps helm-remaps multiple-cursors-remaps))
- [elpa] branch externals/ergoemacs-mode updated (88f1373 -> 7a30c03), Matthew Fidler, 2014/07/11
- [elpa] 02/35: Add Open Directory, Matthew Fidler, 2014/07/11
- [elpa] 03/35: Fix #267, Matthew Fidler, 2014/07/11
- [elpa] 04/35: Add ~/.emacs and describe using elpa instead of melpa, Matthew Fidler, 2014/07/11
- [elpa] 05/35: Fix Typo in web.org, Matthew Fidler, 2014/07/11
- [elpa] 08/35: Fix Issue #268, Matthew Fidler, 2014/07/11
- [elpa] 06/35: Fix the differences between elpa and manual setup, Matthew Fidler, 2014/07/11
- [elpa] 01/35: Fix key lookup for menus. isearch <-> text search Issue #265., Matthew Fidler, 2014/07/11
- [elpa] 07/35: Reverse the directions, Matthew Fidler, 2014/07/11
- [elpa] 10/35: Add moving lines/region using M-up or M-down. Issue #266,
Matthew Fidler <=
- [elpa] 13/35: Misc code cleanup, Matthew Fidler, 2014/07/11
- [elpa] 11/35: Change order to Fix #265 again, Matthew Fidler, 2014/07/11
- [elpa] 12/35: Possibly Fix Issue #269, Matthew Fidler, 2014/07/11
- [elpa] 14/35: Another attempt to fix Issue #269, Matthew Fidler, 2014/07/11
- [elpa] 20/35: Make Open Last Closed show Ctl+Shift+T, Matthew Fidler, 2014/07/11
- [elpa] 16/35: Add open last closed to recentf menu, Matthew Fidler, 2014/07/11
- [elpa] 19/35: More accessible printer setup (Issue #236 and #235), Matthew Fidler, 2014/07/11
- [elpa] 17/35: Add Scroll up/down command for other window, Matthew Fidler, 2014/07/11
- [elpa] 09/35: Change startup messages, Matthew Fidler, 2014/07/11
- [elpa] 21/35: Add load path to batch byte compile, Matthew Fidler, 2014/07/11