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:00:27 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

Little better...

(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 "[✔]"))))
    (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 "(✽)")

- (✽) Something done
- ( ) Not done
- (✽) 

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