unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: help-gnu-emacs@gnu.org
Subject: Re: [solved] Re: To switch state of line not working
Date: Tue, 15 Jun 2021 06:02:06 +0300	[thread overview]
Message-ID: <YMgYLmxPM5w3BjqB@protected.localdomain> (raw)
In-Reply-To: <87mtrr25sf.fsf@zoho.eu>

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-06-15 05:58]:
> Jean Louis wrote:
> 
> >> > (or check-in  (or rcd-check-in-default  "[ ]"))
> >> > (or check-out (or rcd-check-out-default "[✔]"))
> >> 
> >> (or nil nil 1) ; 1
> >
> > Yes, why not, maybe the optional check-in, maybe the global
> > one, if none is there the hard coded one...
> 
> Yes, that made/makes sense, but no need to nest `or', I mean.

"n'or" any more, no or any more...

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

(defun rcd-check ()
  "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)))
    (rcd-check-start)
    (save-excursion
      (cond ((string-match (regexp-quote rcd-check-in) line) 
	     (replace-regexp (regexp-quote rcd-check-in) rcd-check-out nil start end))
	    ((string-match (regexp-quote rcd-check-out) line)
	     (replace-regexp (regexp-quote rcd-check-out) rcd-check-in nil start end))))))

(defun rcd-check-start ()
  "Insert variable `rcd-check-in' 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 line))
	       (not (string-match rcd-check-out line)))
      (save-excursion
	(goto-char start)
	(insert rcd-check-in " "))
      (when (= start end)
	(goto-char (line-end-position))))))

-- 
Jean

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

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



  reply	other threads:[~2021-06-15  3:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YMgYLmxPM5w3BjqB@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).