doomemacs/core/lib/defuns-evil.el

80 lines
2.7 KiB
EmacsLisp
Raw Normal View History

2015-06-15 15:05:52 +08:00
;;; defuns-evil.el
;; for ../core-evil.el
;;;###autoload (autoload 'narf:evil-open-folds "defuns-evil" nil t)
(evil-define-command narf/evil-open-folds (count)
"Instead of `evil-open-folds'. Accepts COUNT for dictating fold level."
(interactive "P")
(unless (bound-and-true-p hs-minor-mode)
(hs-minor-mode 1))
(if count (hs-hide-level count) (evil-open-folds)))
;;;###autoload (autoload 'narf:evil-open-folds "defuns-evil" nil t)
(evil-define-command narf/evil-close-folds (count)
"Instead of `evil-close-folds'. Accepts COUNT for dictating fold level."
(interactive "P")
(unless (bound-and-true-p hs-minor-mode)
(hs-minor-mode 1))
(if count (hs-hide-level count) (evil-close-folds)))
2015-10-01 01:49:37 +08:00
;;;###autoload (autoload 'narf-multi-next-line "defuns-evil" nil t)
(evil-define-motion narf-multi-next-line (count)
"Move down 6 lines"
:type line (evil-line-move 6))
;;;###autoload (autoload 'narf-multi-previous-line "defuns-evil" nil t)
(evil-define-motion narf-multi-previous-line (count)
"Move up 6 lines"
:type line (evil-line-move -6))
2015-06-15 15:05:52 +08:00
;;;###autoload
(defun narf/evil-visual-line-state-p ()
"Returns non-nil if in visual-line mode, nil otherwise."
(and (evil-visual-state-p)
(eq (evil-visual-type) 'line)))
;;;###autoload
(defun narf:iedit-restrict-to-region ()
(interactive)
(if (iedit-current-occurrence-string)
(let ((current-prefix-arg '(4)))
(iedit-done)
(call-interactively 'iedit-mode)
(save-excursion (iedit-restrict-region (region-beginning) (region-end)))
(evil-previous-line))
(call-interactively 'evil-ret)))
;;;###autoload
(defun narf*evil-exchange-off ()
(when evil-exchange--overlays
(evil-exchange-cancel)))
;;;###autoload
(defun narf/evil-surround-escaped ()
"Escaped surround characters."
(let* ((char (string (read-char "\\")))
(pair (cond ((string-match "[]})[{(]" char)
(let ((-pair (cdr (assoc (string-to-char char) evil-surround-pairs-alist))))
`(,(car -pair) . ,(cdr -pair))))
(t
`(,char . ,char))))
(format (if (sp-point-in-string) "\\\\%s" "\\%s")))
(cons (format format (car pair))
(format format (cdr pair)))))
;;;###autoload (autoload 'narf/evil-macro-on-all-lines "defuns-evil" nil t)
(evil-define-operator narf/evil-macro-on-all-lines (beg end &optional arg)
"Apply macro to each line. Courtesy of PythonNut/emacs-config"
(evil-with-state
(evil-normal-state)
(goto-char end)
(evil-visual-state)
(goto-char beg)
(evil-ex-normal (region-beginning) (region-end)
(concat "@"
(single-key-description
(read-char "What macro?"))))))
2015-06-15 15:05:52 +08:00
(provide 'defuns-evil)
;;; defuns-evil.el ends here