-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encapsulates multiple cursors functionality in a layer
- Loading branch information
Showing
7 changed files
with
85 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
;; -*- lexical-binding: t -*- | ||
;; | ||
;;; config.el --- Spacemacs Multiple Cursors Layer packages File | ||
;; | ||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors | ||
;; | ||
;; Author: Codruț Constantin Gușoi <codrut.gusoi@gmail.com> | ||
;; URL: https://github.com/syl20bnr/spacemacs | ||
;; | ||
;; This file is not part of GNU Emacs. | ||
;; | ||
;;; License: GPLv3 | ||
|
||
(defvar multiple-cursors-backend 'evil-mc | ||
"The package used as the backend for multiple cursors functionality.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
;; -*- lexical-binding: t -*- | ||
;; | ||
;;; funcs.el --- Spacemacs Multiple Cursors Layer packages File | ||
;; | ||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors | ||
;; | ||
;; Author: Codruț Constantin Gușoi <codrut.gusoi@gmail.com> | ||
;; URL: https://github.com/syl20bnr/spacemacs | ||
;; | ||
;; This file is not part of GNU Emacs. | ||
;; | ||
;;; License: GPLv3 | ||
|
||
(defun spacemacs//paste-transient-state-p () | ||
"Return non-nil if the paste transient state is enabled." | ||
(and dotspacemacs-enable-paste-transient-state | ||
(or (not (fboundp 'evil-mc-get-cursor-count)) | ||
(eq (evil-mc-get-cursor-count) 1)))) | ||
|
||
(defun spacemacs/evil-mc-paste-after (&optional count register) | ||
"Disable paste transient state if there is more than 1 cursor." | ||
(interactive "p") | ||
(setq this-command 'evil-paste-after) | ||
(if (spacemacs//paste-transient-state-p) | ||
(spacemacs/paste-transient-state/evil-paste-after) | ||
(evil-paste-after count (or register evil-this-register)))) | ||
|
||
(defun spacemacs/evil-mc-paste-before (&optional count register) | ||
"Disable paste transient state if there is more than 1 cursor." | ||
(interactive "p") | ||
(setq this-command 'evil-paste-before) | ||
(if (spacemacs//paste-transient-state-p) | ||
(spacemacs/paste-transient-state/evil-paste-before) | ||
(evil-paste-before count (or register evil-this-register)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
;; -*- lexical-binding: t -*- | ||
;; | ||
;;; packages.el --- Spacemacs Multiple Cursors Layer packages File | ||
;; | ||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors | ||
;; | ||
;; Author: Codruț Constantin Gușoi <codrut.gusoi@gmail.com> | ||
;; URL: https://github.com/syl20bnr/spacemacs | ||
;; | ||
;; This file is not part of GNU Emacs. | ||
;; | ||
;;; License: GPLv3 | ||
|
||
(setq multiple-cursors-packages | ||
'(evil-mc | ||
)) | ||
|
||
(defun multiple-cursors/init-evil-mc () | ||
(use-package evil-mc | ||
:config | ||
(progn | ||
(setq evil-mc-one-cursor-show-mode-line-text nil) | ||
(when (or (spacemacs/system-is-mac) (spacemacs/system-is-mswindows)) | ||
(setq evil-mc-enable-bar-cursor nil)) | ||
|
||
;; evil-mc is not compatible with the paste transient state | ||
(define-key evil-normal-state-map "p" 'spacemacs/evil-mc-paste-after) | ||
(define-key evil-normal-state-map "P" 'spacemacs/evil-mc-paste-before) | ||
|
||
(dolist (state-map `(,evil-normal-state-map ,evil-insert-state-map)) | ||
(dolist (keybinding `((,(kbd "C-M-j") . evil-mc-make-cursor-move-next-line) | ||
(,(kbd "C-M-k") . evil-mc-make-cursor-move-prev-line))) | ||
(define-key state-map (car keybinding) (cdr keybinding)))) | ||
|
||
(global-evil-mc-mode 1)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters