help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [solved] Re: To switch state of line not working


From: Jean Louis
Subject: Re: [solved] Re: To switch state of line not working
Date: Tue, 15 Jun 2021 05:11:22 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

This is now looking better in plain text:

(defun rcd-check (&optional check-in check-out)
  "Replace matches of CHECK-IN with CHECK-OUT in a line.

It is useful to toggle [ ] to [✔]"
  (interactive)
  (let* ((start (line-beginning-position))
         (end (line-end-position))
         (line (buffer-substring start end))
         (check-in (or check-in (or rcd-check-in-default "[ ]")))
         (check-out (or check-out (or rcd-check-out-default "[✔]"))))
    (rcd-check-start)
    (save-excursion
      (cond ((string-match (regexp-quote check-in) line) 
             (replace-regexp (regexp-quote check-in) check-out nil start end))
            ((string-match (regexp-quote check-out) line)
             (replace-regexp (regexp-quote check-out) check-in nil start 
end))))))

(defvar rcd-check-in-default "❰    ❱")
(defvar rcd-check-out-default "❰DONE❱")

(defun rcd-check-start ()
  "Insert variable `rcd-check-in-default' at the beginning of line."
  (interactive)
  (let* ((start (line-beginning-position))
         (end (line-end-position))
         (line (buffer-substring start end)))
    (when (and (not (string-match rcd-check-in-default line))
               (not (string-match rcd-check-out-default line)))
      (save-excursion
        (goto-char start)
        (insert rcd-check-in-default " ")))))

Something to be done, yes.

then user invokes key on the line and gets:

❰    ❱ Something to be done, yes.

then again:

❰DONE❱ Something to be done, yes.

then again:

❰    ❱ Something to be done, yes.

To me that looks more visual than just [X]

❰    ❱ Donec a diam lectus. 
❰DONE❱ *Sed sit amet ipsum mauris.* 
❰DONE❱ Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit.
❰    ❱ **Donec et mollis dolor**. 
❰    ❱ Praesent et diam eget libero egestas mattis sit amet vitae augue. 

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]