|
From: | Jean Louis |
Subject: | To switch state of line not working |
Date: | Tue, 15 Jun 2021 03:07:27 +0300 |
1. [ ] Something to do 2. [ ] More to do 3. [✔] And more 4. [✔] Even more. This function below is supposed to switch from [✔] to [ ] when cursor is on the line but it is not working. It is switching only from [ ] to [✔]. Does somebody sees why? (defun rcd-check (&optional check-in check-out) (interactive) (let* ((start (line-beginning-position)) (end (line-end-position)) (line (buffer-substring start end)) (check-in (or check-in (regexp-quote "[ ]"))) (check-out (or check-out (regexp-quote "[✔]")))) (if (string-match check-in line) (progn (replace-line check-in check-out)) (if (string-match check-out line) (progn (replace-line check-out check-in)))))) (defun replace-line (from to) (let* ((start (line-beginning-position)) (end (line-end-position)) (line (buffer-substring start end))) (save-excursion (replace-string from to nil start end))))
[Prev in Thread] | Current Thread | [Next in Thread] |