2016-05-17 01:01:41 +00:00
|
|
|
|
;;; funcs.el --- Spacemacs Evil Layer functions File
|
|
|
|
|
;;
|
2017-01-06 03:51:13 +00:00
|
|
|
|
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
|
2016-05-17 01:01:41 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
|
;;
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
;;
|
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
2016-06-13 14:10:14 +00:00
|
|
|
|
(defvar spacemacs--evil-iedit-insert-states-default nil
|
|
|
|
|
"Default value of the list of additional states enabled in \
|
|
|
|
|
`evil-iedit-insert-state'.")
|
|
|
|
|
|
|
|
|
|
(defvar spacemacs--evil-iedit-insert-states-hybrid nil
|
|
|
|
|
"List of additional states enabled in `evil-iedit-insert-state' when
|
|
|
|
|
`hybrid-mode' is active.")
|
|
|
|
|
|
2016-05-17 01:01:41 +00:00
|
|
|
|
(defun spacemacs//enable-hs-minor-mode ()
|
|
|
|
|
"Enable hs-minor-mode for code folding."
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(hs-minor-mode)
|
|
|
|
|
(spacemacs|hide-lighter hs-minor-mode)))
|
2016-06-13 14:10:14 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs//iedit-insert-state-hybrid (style)
|
|
|
|
|
"If STYLE is hybrid, update `evil-iedit-insert-state' definition to enable
|
|
|
|
|
`evil-hybrid-state' instead of `evil-insert-state'.
|
|
|
|
|
Otherwise, revert to the default behavior (i.e. enable `evil-insert-state')."
|
|
|
|
|
;; Populate variables on the first invocation.
|
|
|
|
|
(unless spacemacs--evil-iedit-insert-states-default
|
|
|
|
|
(setq spacemacs--evil-iedit-insert-states-default
|
|
|
|
|
(evil-get-property evil-state-properties 'iedit-insert :enable))
|
|
|
|
|
(setq spacemacs--evil-iedit-insert-states-hybrid
|
|
|
|
|
(mapcar (lambda (item)
|
|
|
|
|
(if (eq item 'insert) 'hybrid item))
|
|
|
|
|
spacemacs--evil-iedit-insert-states-default)))
|
|
|
|
|
(let ((states (if (eq style 'hybrid)
|
|
|
|
|
spacemacs--evil-iedit-insert-states-hybrid
|
|
|
|
|
spacemacs--evil-iedit-insert-states-default)))
|
|
|
|
|
(evil-put-property 'evil-state-properties 'iedit-insert
|
|
|
|
|
:enable states)))
|
2016-07-13 14:16:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; evil-search-highlight-persist
|
|
|
|
|
|
|
|
|
|
(defun spacemacs/evil-search-clear-highlight ()
|
|
|
|
|
"Clear evil-search or evil-ex-search persistent highlights."
|
|
|
|
|
(interactive)
|
2017-08-16 14:41:40 +00:00
|
|
|
|
(evil-search-highlight-persist-remove-all) ; `C-s' highlights
|
|
|
|
|
(evil-ex-nohighlight)) ; `/' highlights
|
2016-07-13 14:16:11 +00:00
|
|
|
|
|
|
|
|
|
(defun spacemacs//adaptive-evil-highlight-persist-face ()
|
|
|
|
|
(set-face-attribute 'evil-search-highlight-persist-highlight-face nil
|
|
|
|
|
:inherit 'lazy-highlight
|
|
|
|
|
:background nil
|
|
|
|
|
:foreground nil))
|
2016-09-30 12:42:32 +00:00
|
|
|
|
|
2016-10-11 23:54:37 +00:00
|
|
|
|
(defun spacemacs/linum-relative-toggle ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (not (bound-and-true-p linum-relative-mode))
|
|
|
|
|
(linum-mode))
|
|
|
|
|
(linum-relative-toggle))
|
|
|
|
|
|
2016-09-30 12:42:32 +00:00
|
|
|
|
|
|
|
|
|
;; vi-tilde-fringe
|
|
|
|
|
|
|
|
|
|
(defun spacemacs/disable-vi-tilde-fringe ()
|
|
|
|
|
"Disable `vi-tilde-fringe' in the current buffer."
|
|
|
|
|
(vi-tilde-fringe-mode -1))
|
|
|
|
|
|
|
|
|
|
(defun spacemacs/disable-vi-tilde-fringe-read-only ()
|
|
|
|
|
"Disable `vi-tilde-fringe' in the current buffer if it is read only."
|
|
|
|
|
(when buffer-read-only
|
|
|
|
|
(spacemacs/disable-vi-tilde-fringe)))
|
2017-04-10 03:22:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; multiple-cursors
|
|
|
|
|
|
2017-04-11 03:40:14 +00:00
|
|
|
|
(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))))
|
|
|
|
|
|
2017-06-03 07:08:01 +00:00
|
|
|
|
(defun spacemacs/evil-mc-paste-after (&optional count register)
|
2017-06-11 02:32:46 +00:00
|
|
|
|
"Disable paste transient state if there is more than 1 cursor."
|
2017-04-10 03:22:12 +00:00
|
|
|
|
(interactive "p")
|
2017-06-11 02:32:46 +00:00
|
|
|
|
(setq this-command 'evil-paste-after)
|
2017-04-11 03:40:14 +00:00
|
|
|
|
(if (spacemacs//paste-transient-state-p)
|
2017-04-10 03:22:12 +00:00
|
|
|
|
(spacemacs/paste-transient-state/evil-paste-after)
|
2017-06-03 07:08:01 +00:00
|
|
|
|
(evil-paste-after count (or register evil-this-register))))
|
2017-04-10 03:22:12 +00:00
|
|
|
|
|
2017-06-03 07:08:01 +00:00
|
|
|
|
(defun spacemacs/evil-mc-paste-before (&optional count register)
|
2017-06-11 02:32:46 +00:00
|
|
|
|
"Disable paste transient state if there is more than 1 cursor."
|
2017-04-10 03:22:12 +00:00
|
|
|
|
(interactive "p")
|
2017-06-11 02:32:46 +00:00
|
|
|
|
(setq this-command 'evil-paste-before)
|
2017-04-11 03:40:14 +00:00
|
|
|
|
(if (spacemacs//paste-transient-state-p)
|
2017-04-10 03:22:12 +00:00
|
|
|
|
(spacemacs/paste-transient-state/evil-paste-before)
|
2017-06-03 07:08:01 +00:00
|
|
|
|
(evil-paste-before count (or register evil-this-register))))
|