Update search

This commit is contained in:
Andros Fenollosa 2021-01-10 20:08:22 +01:00
parent 95100f4051
commit 7dccf4b928

18
burn.el
View File

@ -14,30 +14,32 @@
(setf burn--emoji "🔥") (setf burn--emoji "🔥")
(defun burn--is-exist-emoji () (defun burn--is-exist-emoji ()
(goto-char 1) (not (null (string-match-p burn--emoji (buffer-string)))))
(search-forward burn--emoji)
(equal (point) 1)) (defun burn--is-empty ()
(= 0 (length (replace-regexp-in-string (concat "\\`[ \t\n" burn--emoji "]*") "" (replace-regexp-in-string (concat "[ \t\n" burn--emoji "]*\\'") "" (buffer-string))))))
(defun burn--replace-backward-at-point () (defun burn--replace-backward-at-point ()
"Replace the backwards character at point with burn--emoji." "Replace the backwards character at point with burn--emoji."
(re-search-backward (concat "[^" burn--emoji "]") 1) (re-search-backward (concat "[^" burn--emoji " \t\n]") 1)
(delete-char 1) (delete-char 1)
(insert burn--emoji)) (insert burn--emoji))
(defun burn--replace-forward-at-point () (defun burn--replace-forward-at-point ()
"Replace the forward character at point with burn--emoji." "Replace the forward character at point with burn--emoji."
(re-search-forward (concat "[^" burn--emoji "]") 1) (re-search-forward (concat "[^" burn--emoji " \t\n]") 1)
(delete-char 1) (delete-char 1)
(insert burn--emoji)) (insert burn--emoji))
(defun burn-code () (defun burn-code ()
"Replace code with burn--emoji." "Replace code with burn--emoji."
(interactive) (interactive)
(while burn--is-exist-emoji (while (not (burn--is-empty))
(sit-for 1.05) (sit-for 0.5)
(burn--replace-backward-at-point) (burn--replace-backward-at-point)
(burn--replace-forward-at-point) (burn--replace-forward-at-point)
)) )
)
;;; burn.el ends here ;;; burn.el ends here