2019-10-26 00:37:12 -04:00
|
|
|
|
;;; editor/evil/autoload/textobjects.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
2019-10-28 02:09:05 -04:00
|
|
|
|
;;;###autoload (autoload '+evil:whole-buffer-txtobj "editor/evil/autoload/textobjects" nil nil)
|
2019-11-23 00:52:36 -05:00
|
|
|
|
(evil-define-text-object +evil:whole-buffer-txtobj (count &optional _beg _end type)
|
2019-10-26 00:37:12 -04:00
|
|
|
|
"Text object to select the whole buffer."
|
|
|
|
|
(evil-range (point-min) (point-max) type))
|
|
|
|
|
|
|
|
|
|
;;;###autoload (autoload '+evil:defun-txtobj "editor/evil/autoload/textobjects" nil nil)
|
2019-11-23 00:52:36 -05:00
|
|
|
|
(evil-define-text-object +evil:defun-txtobj (count &optional _beg _end type)
|
2020-03-23 18:13:45 +01:00
|
|
|
|
"Text object to select the top-level Lisp form or function definition at
|
|
|
|
|
point."
|
2019-10-26 00:37:12 -04:00
|
|
|
|
(cl-destructuring-bind (beg . end)
|
|
|
|
|
(bounds-of-thing-at-point 'defun)
|
|
|
|
|
(evil-range beg end type)))
|
2020-02-04 13:58:43 -05:00
|
|
|
|
|
|
|
|
|
;;;###autoload (autoload '+evil:inner-url-txtobj "editor/evil/autoload/textobjects" nil nil)
|
|
|
|
|
(evil-define-text-object +evil:inner-url-txtobj (count &optional _beg _end type)
|
|
|
|
|
"Text object to select the inner url at point.
|
|
|
|
|
|
|
|
|
|
This excludes the protocol and querystring."
|
|
|
|
|
(cl-destructuring-bind (beg . end)
|
|
|
|
|
(bounds-of-thing-at-point 'url)
|
|
|
|
|
(evil-range
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(re-search-forward "://" end t))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char end)
|
|
|
|
|
(- (if-let (pos (re-search-backward "[?#]" beg t))
|
|
|
|
|
pos
|
|
|
|
|
end)
|
|
|
|
|
(if (evil-visual-state-p)
|
|
|
|
|
1
|
|
|
|
|
0)))
|
|
|
|
|
type)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload (autoload '+evil:outer-url-txtobj "editor/evil/autoload/textobjects" nil nil)
|
|
|
|
|
(evil-define-text-object +evil:outer-url-txtobj (count &optional _beg _end type)
|
|
|
|
|
"Text object to select the whole url at point."
|
|
|
|
|
(cl-destructuring-bind (beg . end)
|
|
|
|
|
(bounds-of-thing-at-point 'url)
|
|
|
|
|
(evil-range
|
|
|
|
|
beg (- end (if (evil-visual-state-p) 1 0))
|
|
|
|
|
type)))
|
2020-10-27 23:18:06 -04:00
|
|
|
|
|
|
|
|
|
;;;###autoload (autoload '+evil:inner-any-quote "editor/evil/autoload/textobjects" nil nil)
|
|
|
|
|
(evil-define-text-object +evil:inner-any-quote (count &optional beg end type)
|
|
|
|
|
"Select the closest inner quote."
|
2021-05-30 12:18:57 -04:00
|
|
|
|
(require 'evil-textobj-anyblock)
|
2020-10-27 23:18:06 -04:00
|
|
|
|
(let ((evil-textobj-anyblock-blocks
|
|
|
|
|
'(("'" . "'")
|
|
|
|
|
("\"" . "\"")
|
|
|
|
|
("`" . "`")
|
2020-10-28 08:41:33 +01:00
|
|
|
|
("‘" . "’")
|
2020-10-27 23:18:06 -04:00
|
|
|
|
("“" . "”"))))
|
|
|
|
|
(evil-textobj-anyblock-inner-block count beg end type)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload (autoload '+evil:outer-any-quote "editor/evil/autoload/textobjects" nil nil)
|
|
|
|
|
(evil-define-text-object +evil:outer-any-quote (count &optional beg end type)
|
|
|
|
|
"Select the closest outer quote."
|
2021-05-30 12:18:57 -04:00
|
|
|
|
(require 'evil-textobj-anyblock)
|
2020-10-27 23:18:06 -04:00
|
|
|
|
(let ((evil-textobj-anyblock-blocks
|
|
|
|
|
'(("'" . "'")
|
|
|
|
|
("\"" . "\"")
|
|
|
|
|
("`" . "`")
|
2020-10-28 08:41:33 +01:00
|
|
|
|
("‘" . "’")
|
2020-10-27 23:18:06 -04:00
|
|
|
|
("“" . "”"))))
|
|
|
|
|
(evil-textobj-anyblock-a-block count beg end type)))
|