Created
September 13, 2012 13:41
-
-
Save jplindstrom/3714364 to your computer and use it in GitHub Desktop.
A "defun" Emacs Evil text object
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
;; Define a "defun" Emacs Evil text object | |
(defun jpl-line-before-end-of-defun (&optional arg) | |
(interactive) | |
(end-of-defun arg) | |
(previous-line)) | |
(defun jpl-line-after-beginning-of-defun (&optional arg) | |
(interactive) | |
(beginning-of-defun arg) | |
(next-line)) | |
(evil-define-text-object evil-inner-defun (count &optional beg end type) | |
"Select inner defun. | |
This is a gross simplification, assuming the inner part is one | |
line within the outer part. Maybe find the next sexp and go with | |
that? Maybe there's something in the syntax table alerady for | |
this." | |
(evil-inner-object-range count beg end type | |
#'jpl-line-before-end-of-defun | |
#'jpl-line-after-beginning-of-defun | |
)) | |
(define-key evil-inner-text-objects-map "d" 'evil-inner-defun) | |
(evil-define-text-object evil-defun (count &optional beg end type) | |
"Select around defun." | |
(evil-an-object-range count beg end type | |
#'end-of-defun | |
#'beginning-of-defun)) | |
(define-key evil-outer-text-objects-map "d" 'evil-defun) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment