Can use mc/reverse-regions w/o region or cursors

- will flip sexp at point with the one below it
This commit is contained in:
Magnar Sveen
2013-02-11 07:29:17 +01:00
parent 16add89d29
commit 641eb680ca
5 changed files with 34 additions and 20 deletions

View File

@@ -58,7 +58,7 @@
(defun mc--replace-region-strings-1 ()
(interactive)
(delete-region (region-beginning) (region-end))
(insert (car mc--strings-to-replace))
(save-excursion (insert (car mc--strings-to-replace)))
(setq mc--strings-to-replace (cdr mc--strings-to-replace)))
(defun mc--replace-region-strings ()
@@ -68,18 +68,23 @@
;;;###autoload
(defun mc/reverse-regions ()
(interactive)
(if (not (use-region-p))
(message "Mark regions to reverse first.")
(if (not multiple-cursors-mode)
(progn
(mc/mark-next-lines 1)
(mc/reverse-regions)
(multiple-cursors-mode 0))
(unless (use-region-p)
(mc/execute-command-for-all-cursors 'mark-sexp))
(setq mc--strings-to-replace (nreverse (mc--ordered-region-strings)))
(mc--replace-region-strings)))
;;;###autoload
(defun mc/sort-regions ()
(interactive)
(if (not (use-region-p))
(message "Mark regions to sort first.")
(setq mc--strings-to-replace (sort (mc--ordered-region-strings) 'string<))
(mc--replace-region-strings)))
(unless (use-region-p)
(mc/execute-command-for-all-cursors 'mark-sexp))
(setq mc--strings-to-replace (sort (mc--ordered-region-strings) 'string<))
(mc--replace-region-strings))
(provide 'mc-separate-operations)
;;; mc-separate-operations.el ends here