all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* To switch state of line not working
@ 2021-06-15  0:07 Jean Louis
  2021-06-15  1:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-06-15  1:30 ` [solved] " Jean Louis
  0 siblings, 2 replies; 23+ messages in thread
From: Jean Louis @ 2021-06-15  0:07 UTC (permalink / raw)
  To: Help GNU Emacs

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))))



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-06-15  3:12 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-15  0:07 To switch state of line not working Jean Louis
2021-06-15  1:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-15  1:16   ` Jean Louis
2021-06-15  1:31     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-15  1:30 ` [solved] " Jean Louis
2021-06-15  1:45   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-15  1:48     ` Jean Louis
2021-06-15  1:48     ` Jean Louis
2021-06-15  2:00       ` Jean Louis
2021-06-15  2:11         ` Jean Louis
2021-06-15  2:34           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-15  2:38             ` Jean Louis
2021-06-15  3:02               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-15  3:05                 ` Jean Louis
2021-06-15  3:12                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-15  2:42             ` Jean Louis
2021-06-15  2:57               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-15  3:02                 ` Jean Louis
2021-06-15  3:09                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-15  1:45   ` Jean Louis
2021-06-15  2:22     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-15  2:25       ` Jean Louis
2021-06-15  2:37         ` Emanuel Berg via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.