Skip to content

Commit

Permalink
tweak evil text object to select path/url
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Bin committed Jan 6, 2016
1 parent 9536042 commit 4af8d70
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lisp/init-evil.el
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,19 @@
;;
;; tweak evil-filepath-is-nonname to re-define a path
(defun evil-filepath-is-separator-char (ch)
"Check ascii table"
(let (rlt)
(if (or (= ch 47)
(= ch 92))
"Check ascii table that CH is slash characters.
If the character before and after CH is space or tab, CH is NOT slash"
(let (rlt prefix-ch postfix-ch)
(when (and (> (point) (point-min)) (< (point) (point-max)))
(save-excursion
(backward-char)
(setq prefix-ch (following-char)))
(save-excursion
(forward-char)
(setq postfix-ch (following-char))))
(message "prefix-ch=%s postfix-ch=%s" prefix-ch postfix-ch)
(if (and (not (or (= prefix-ch 32) (= postfix-ch 32)))
(or (= ch 47) (= ch 92)) )
(setq rlt t))
rlt))

Expand Down Expand Up @@ -128,15 +137,15 @@
(evil-filepath-calculate-path b e)))

(defun evil-filepath-search-forward-char (fn &optional backward)
(let (found rlt (limit (if backward (point-min) (point-max))) out)
(let (found rlt (limit (if backward (point-min) (point-max))) out-of-loop)
(save-excursion
(while (not out)
(while (not out-of-loop)
;; for the char, exit
(if (setq found (apply fn (list (following-char))))
(setq out t)
(setq out-of-loop t)
;; reach the limit, exit
(if (= (point) limit)
(setq out t)
(setq out-of-loop t)
;; keep moving
(if backward (backward-char) (forward-char)))))
(if found (setq rlt (point))))
Expand Down

0 comments on commit 4af8d70

Please sign in to comment.