Fix cursor point

This commit is contained in:
Andros Fenollosa 2021-01-10 20:50:06 +01:00
parent 7dccf4b928
commit dbd6a655f8

22
burn.el
View File

@ -4,7 +4,7 @@
;; Authors: Erick Navarro <erick@navarro.io>, Andros Fenollosa <andros@fenollosa.email>
;; URL: https://github.com/erickgnavar/burn.el
;; Version: 0.2.0
;; SPDX-License-Identifier: GNU General Public License v3.0 or later
;; SPDX-License Identifier: GNU General Public License v3.0 or later
;;; Commentary:
;; Replace the buffer content with 🔥.
@ -13,23 +13,20 @@
(setf burn--emoji "🔥")
(defun burn--is-exist-emoji ()
(not (null (string-match-p burn--emoji (buffer-string)))))
(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))))))
(= 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 ()
"Replace the backwards character at point with burn--emoji."
(re-search-backward (concat "[^" burn--emoji " \t\n]") 1)
(delete-char 1)
(insert burn--emoji))
(when (re-search-backward (concat "[^ \t\n" burn--emoji "]") nil :noerr)
(replace-match burn--emoji)))
(defun burn--replace-forward-at-point ()
"Replace the forward character at point with burn--emoji."
(re-search-forward (concat "[^" burn--emoji " \t\n]") 1)
(delete-char 1)
(insert burn--emoji))
(when (re-search-forward (concat "[^ \t\n" burn--emoji "]") nil :noerr)
(replace-match burn--emoji)))
(defun burn-code ()
"Replace code with burn--emoji."
@ -39,7 +36,8 @@
(burn--replace-backward-at-point)
(burn--replace-forward-at-point)
)
)
;; Clear burn--emoji
(set-buffer-modified-p ""))
;;; burn.el ends here