Add iu/au text-object for urls #2484
This commit is contained in:
parent
595524c30e
commit
1575300ad4
2 changed files with 31 additions and 0 deletions
|
@ -11,3 +11,33 @@
|
|||
(cl-destructuring-bind (beg . end)
|
||||
(bounds-of-thing-at-point 'defun)
|
||||
(evil-range beg end type)))
|
||||
|
||||
;;;###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)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue