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

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

Re: To switch state of line not working


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

* Emanuel Berg via Users list for the GNU Emacs text editor 
<help-gnu-emacs@gnu.org> [2021-06-15 04:08]:
> name: "start" -> "beg" for nice align with "end".

Aaaah.

> first `if' - no need for `progn'.

Of course, it is there for debugging temporarily.

> > (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))))
> 
> `replace-string' should be `search-forward' and
> `replace-match'.
> 
> And you are not using "line"!

Sure, it is frantic attempt to make it work.

(defun replace-line (from to)
  (let* ((start (line-beginning-position))
         (end (line-end-position)))
    (save-excursion
      (replace-string from to nil start end))))

[ ]   M-: (replace-line "[ ]" "[X]") works well
[ ]   M-: (replace-line "[ ]" "[✔]") works well
[✔]   M-: (replace-line "[✔]" "[ ]") works well

Combining it is not working.

Do you have solution? Not hair style please.

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