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

* Re: To switch state of line not working
  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:30 ` [solved] " Jean Louis
  1 sibling, 1 reply; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-15  1:07 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

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

name: "start" -> "beg" for nice align with "end".

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

second if - ditto, also here use `when' instead.

> (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"!

Also try `buffer-substring-no-properties' if the above
doesn't help.

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: To switch state of line not working
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Jean Louis @ 2021-06-15  1:16 UTC (permalink / raw)
  To: help-gnu-emacs

* 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/



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

* [solved] Re: To switch state of line not working
  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:30 ` Jean Louis
  2021-06-15  1:45   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-06-15  1:45   ` Jean Louis
  1 sibling, 2 replies; 23+ messages in thread
From: Jean Louis @ 2021-06-15  1:30 UTC (permalink / raw)
  To: Help GNU Emacs

Now it works... (づ。◕‿‿◕。)づ

(defun rcd-check ()
  (interactive)
  (let* ((start (line-beginning-position))
	 (end (line-end-position))
	 (line (buffer-substring start end))
	 (check-in "[ ]")
	 (check-out "[✔]")
	 (check-in (list (regexp-quote check-in) check-in))
	 (check-in-there (string-match (car check-in) line))
	 (check-out (list (regexp-quote check-out) check-out))
	 (check-out-there (string-match (cadr check-out) line)))
    (cond ((not (null check-in-there)) (replace-regexp (car check-in) (cadr check-out) nil start end))
	  ((not (null check-out-there)) (replace-regexp (car check-out) (cadr check-in) nil start end))
	  (t (message-box "Oh no! Could not replace without check box!" check-out)))))

 [ ] something

-- 
Jean

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

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



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

* Re: To switch state of line not working
  2021-06-15  1:16   ` Jean Louis
@ 2021-06-15  1:31     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-15  1:31 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> Combining it is not working.

Example?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: [solved] Re: To switch state of line not working
  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  1:45   ` Jean Louis
  1 sibling, 2 replies; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-15  1:45 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> Now it works... (づ。◕‿‿◕。)づ
>
> (defun rcd-check ()
>   (interactive)
>   (let* ((start (line-beginning-position))
> 	 (end (line-end-position))
> 	 (line (buffer-substring start end))
> 	 (check-in "[ ]")
> 	 (check-out "[✔]")
> 	 (check-in (list (regexp-quote check-in) check-in))
> 	 (check-in-there (string-match (car check-in) line))
> 	 (check-out (list (regexp-quote check-out) check-out))
> 	 (check-out-there (string-match (cadr check-out) line)))
>     (cond ((not (null check-in-there)) (replace-regexp (car check-in) (cadr check-out) nil start end))
> 	  ((not (null check-out-there)) (replace-regexp (car check-out) (cadr check-in) nil start end))
> 	  (t (message-box "Oh no! Could not replace without check box!" check-out)))))
>
>  [ ] something

Uhm, not null something?

(not (null t))   ; t
(not (null nil)) ; nil

And

`replace-regexp' -> `re-search-forward', `replace-match'

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: [solved] Re: To switch state of line not working
  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:45   ` Jean Louis
  2021-06-15  2:22     ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 23+ messages in thread
From: Jean Louis @ 2021-06-15  1:45 UTC (permalink / raw)
  To: Help GNU Emacs

Shorter version:
n
(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 "[ ]"))
	 (check-out (or check-out "[✔]")))
    (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)))))

1. [✔] Something
2. [✔] Done
3. [ ] To be done

(defun rcd-highlight-list (list)
  "Uses LIST to highlight strings in buffer."
  (hi-lock-mode)
  (let* ((list (delete "" list))
	(highlights hi-lock-face-defaults))
    (while list
      (highlight-regexp (regexp-quote (pop list)) (pop highlights)))))

(rcd-highlight-list '("[ ]" "[✔]"))

-- 
Jean

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

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



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

* Re: [solved] Re: To switch state of line not working
  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
  1 sibling, 0 replies; 23+ messages in thread
From: Jean Louis @ 2021-06-15  1:48 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-06-15 04:47]:
> Jean Louis wrote:
> 
> > Now it works... (づ。◕‿‿◕。)づ
> >
> > (defun rcd-check ()
> >   (interactive)
> >   (let* ((start (line-beginning-position))
> > 	 (end (line-end-position))
> > 	 (line (buffer-substring start end))
> > 	 (check-in "[ ]")
> > 	 (check-out "[✔]")
> > 	 (check-in (list (regexp-quote check-in) check-in))
> > 	 (check-in-there (string-match (car check-in) line))
> > 	 (check-out (list (regexp-quote check-out) check-out))
> > 	 (check-out-there (string-match (cadr check-out) line)))
> >     (cond ((not (null check-in-there)) (replace-regexp (car check-in) (cadr check-out) nil start end))
> > 	  ((not (null check-out-there)) (replace-regexp (car check-out) (cadr check-in) nil start end))
> > 	  (t (message-box "Oh no! Could not replace without check box!" check-out)))))
> >
> >  [ ] something
> 
> Uhm, not null something?
> 
> (not (null t))   ; t
> (not (null nil)) ; nil
> 
> And
> 
> `replace-regexp' -> `re-search-forward', `replace-match'

It's solved...


-- 
Jean

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

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



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

* Re: [solved] Re: To switch state of line not working
  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
  1 sibling, 1 reply; 23+ messages in thread
From: Jean Louis @ 2021-06-15  1:48 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-06-15 04:47]:
> Uhm, not null something?
> 
> (not (null t))   ; t
> (not (null nil)) ; nil

You don't know what is desperation...

-- 
Jean

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

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



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

* Re: [solved] Re: To switch state of line not working
  2021-06-15  1:48     ` Jean Louis
@ 2021-06-15  2:00       ` Jean Louis
  2021-06-15  2:11         ` Jean Louis
  0 siblings, 1 reply; 23+ messages in thread
From: Jean Louis @ 2021-06-15  2:00 UTC (permalink / raw)
  To: help-gnu-emacs

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/



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

* Re: [solved] Re: To switch state of line not working
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Jean Louis @ 2021-06-15  2:11 UTC (permalink / raw)
  To: help-gnu-emacs

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/



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

* Re: [solved] Re: To switch state of line not working
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-15  2:22 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> (defun rcd-highlight-list (list)
>  "Uses LIST to highlight strings in buffer."
>  (hi-lock-mode)
>  (let* ((list (delete "" list))

That looks like a function ... list -> lst or better yet
express in other terms as everything in Lisp is a list,
even Lisp.

> (while list
>   (highlight-regexp (regexp-quote (pop list)) (pop highlights)))))

(require 'cl-lib)
(cl-loop for dig in '(1 2 3)
         for str in '("aaa" "bbb" "see")
         do (message "%d: %s" dig str) )

1: aaa
2: bbb
3: see

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: [solved] Re: To switch state of line not working
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Jean Louis @ 2021-06-15  2:25 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-06-15 05:23]:
> Jean Louis wrote:
> 
> > (defun rcd-highlight-list (list)
> >  "Uses LIST to highlight strings in buffer."
> >  (hi-lock-mode)
> >  (let* ((list (delete "" list))
> 
> That looks like a function ... list -> lst or better yet
> express in other terms as everything in Lisp is a list,
> even Lisp.
> 
> > (while list
> >   (highlight-regexp (regexp-quote (pop list)) (pop highlights)))))
> 
> (require 'cl-lib)
> (cl-loop for dig in '(1 2 3)
>          for str in '("aaa" "bbb" "see")
>          do (message "%d: %s" dig str) )
> 
> 1: aaa
> 2: bbb
> 3: see

I don't use `cl-lib' ᗒ ͟ʖᗕ (almost)


-- 
Jean

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

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



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

* Re: [solved] Re: To switch state of line not working
  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  2:42             ` Jean Louis
  0 siblings, 2 replies; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-15  2:34 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> (or check-in  (or rcd-check-in-default  "[ ]"))
> (or check-out (or rcd-check-out-default "[✔]"))

(or nil nil 1) ; 1

> (when (and (not ...
>            (not ...

Hm, "and not", that rings a bell, is that "nor"?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: [solved] Re: To switch state of line not working
  2021-06-15  2:25       ` Jean Louis
@ 2021-06-15  2:37         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-15  2:37 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>> (require 'cl-lib)
>> (cl-loop for dig in '(1 2 3)
>>          for str in '("aaa" "bbb" "see")
>>          do (message "%d: %s" dig str) )
>> 
>> 1: aaa
>> 2: bbb
>> 3: see
>
> I don't use `cl-lib'

Do it today, in a different way.

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: [solved] Re: To switch state of line not working
  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  2:42             ` Jean Louis
  1 sibling, 1 reply; 23+ messages in thread
From: Jean Louis @ 2021-06-15  2:38 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 478 bytes --]

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-06-15 05:35]:
> Jean Louis wrote:
> 
> > (or check-in  (or rcd-check-in-default  "[ ]"))
> > (or check-out (or rcd-check-out-default "[✔]"))
> 
> (or nil nil 1) ; 1

While you mind boggle, I am playing breakout with my tasks...


-- 
Jean

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

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

[-- Attachment #2: 2021-06-15-05:36:31.png --]
[-- Type: image/png, Size: 68558 bytes --]

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

* Re: [solved] Re: To switch state of line not working
  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  2:42             ` Jean Louis
  2021-06-15  2:57               ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 23+ messages in thread
From: Jean Louis @ 2021-06-15  2:42 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-06-15 05:35]:
> 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...

> > (when (and (not ...
> >            (not ...
> 
> Hm, "and not", that rings a bell, is that "nor"?

Actually, that had to be notty.

-- 
Jean

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

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



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

* Re: [solved] Re: To switch state of line not working
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-15  2:57 UTC (permalink / raw)
  To: help-gnu-emacs

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.

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: [solved] Re: To switch state of line not working
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Jean Louis @ 2021-06-15  3:02 UTC (permalink / raw)
  To: help-gnu-emacs

* 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/



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

* Re: [solved] Re: To switch state of line not working
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-15  3:02 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>> (or nil nil 1) ; 1
>
> While you mind boggle, I am playing breakout with my
> tasks...

I'm glad to have been of service improving the quality of your
software. But maybe you should think of upgrading your
hardware as well?

  https://dataswamp.org/~incal/pimgs/tar.png

Just think, then you can do more resource-intense computing -
for example observational astronomy - over here, we are
currently studying an interesting phenomenon, the so-called
"double star"...

  https://dataswamp.org/~incal/pimgs/double-star.png

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: [solved] Re: To switch state of line not working
  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
  0 siblings, 1 reply; 23+ messages in thread
From: Jean Louis @ 2021-06-15  3:05 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-06-15 06:03]:
> Jean Louis wrote:
> 
> >> (or nil nil 1) ; 1
> >
> > While you mind boggle, I am playing breakout with my
> > tasks...
> 
> I'm glad to have been of service improving the quality of your
> software. But maybe you should think of upgrading your
> hardware as well?
> 
>   https://dataswamp.org/~incal/pimgs/tar.png
> 
> Just think, then you can do more resource-intense computing -
> for example observational astronomy - over here, we are
> currently studying an interesting phenomenon, the so-called
> "double star"...
> 
>   https://dataswamp.org/~incal/pimgs/double-star.png

I like resource-intense computing... (◍•ᴗ•◍)

-- 
Jean

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

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



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

* Re: [solved] Re: To switch state of line not working
  2021-06-15  3:02                 ` Jean Louis
@ 2021-06-15  3:09                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-15  3:09 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

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

Erase and rewind, cause I'll be changing my mind...

https://www.youtube.com/watch?v=6WOYnv59Bi8

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: [solved] Re: To switch state of line not working
  2021-06-15  3:05                 ` Jean Louis
@ 2021-06-15  3:12                   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-15  3:12 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>>>> (or nil nil 1) ; 1
>>>
>>> While you mind boggle, I am playing breakout with my
>>> tasks...
>> 
>> I'm glad to have been of service improving the quality of
>> your software. But maybe you should think of upgrading your
>> hardware as well?
>> 
>>   https://dataswamp.org/~incal/pimgs/tar.png
>> 
>> Just think, then you can do more resource-intense computing
>> - for example observational astronomy - over here, we are
>> currently studying an interesting phenomenon, the so-called
>> "double star"...
>> 
>>   https://dataswamp.org/~incal/pimgs/double-star.png
>
> I like resource-intense computing... (◍•ᴗ•◍)

The sky is the limit :)

-- 
underground experts united
https://dataswamp.org/~incal




^ 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.