all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Copying a list for insertion
@ 2022-10-21 14:16 Heime via Users list for the GNU Emacs text editor
  2022-10-21 14:35 ` Manuel Giraud
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2022-10-21 14:16 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I am printing a list named "cunex" in the messages buffer. I would also like to store what is printed so I can insert
the contents somewhere else, without having to go to the "*Messages*" buffer to copy it.

(message "%s" cunex)

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

* Re: Copying a list for insertion
  2022-10-21 14:16 Copying a list for insertion Heime via Users list for the GNU Emacs text editor
@ 2022-10-21 14:35 ` Manuel Giraud
  2022-10-21 15:03   ` Heime
  2022-10-21 15:46 ` Teemu Likonen
  2022-10-21 15:57 ` Jean Louis
  2 siblings, 1 reply; 24+ messages in thread
From: Manuel Giraud @ 2022-10-21 14:35 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor; +Cc: Heime

Maybe:
(insert (format "%s" cunex))

But it also depends on what you're trying to do.
-- 
Manuel Giraud



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

* Re: Copying a list for insertion
  2022-10-21 14:35 ` Manuel Giraud
@ 2022-10-21 15:03   ` Heime
  0 siblings, 0 replies; 24+ messages in thread
From: Heime @ 2022-10-21 15:03 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Friday, October 21st, 2022 at 2:35 PM, Manuel Giraud <manuel@ledu-giraud.fr> wrote:


> Maybe:
> (insert (format "%s" cunex))
> 
> But it also depends on what you're trying to do.
> --
> Manuel Giraud

I am not planning to actually insert it immediately, but keep in the copy ring, 
so I can insert it with a middle mouse click when appropriate.



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

* Re: Copying a list for insertion
  2022-10-21 14:16 Copying a list for insertion Heime via Users list for the GNU Emacs text editor
  2022-10-21 14:35 ` Manuel Giraud
@ 2022-10-21 15:46 ` Teemu Likonen
  2022-10-21 15:57 ` Jean Louis
  2 siblings, 0 replies; 24+ messages in thread
From: Teemu Likonen @ 2022-10-21 15:46 UTC (permalink / raw)
  To: Heime, Heime via Users list for the GNU Emacs text editor

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

* 2022-10-21 14:16:36+0000, Heime via Users list for the wrote:

> I am printing a list named "cunex" in the messages buffer. I would
> also like to store what is printed so I can insert the contents
> somewhere else, without having to go to the "*Messages*" buffer to
> copy it.
>
> (message "%s" cunex)

    (defvar my-store)
    (setq my-store (format "%S" cunex)) % or: "%s"
    (message "%s" cunex)


-- 
/// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/
// OpenPGP: 6965F03973F0D4CA22B9410F0F2CAE0E07608462

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

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

* Re: Copying a list for insertion
  2022-10-21 14:16 Copying a list for insertion Heime via Users list for the GNU Emacs text editor
  2022-10-21 14:35 ` Manuel Giraud
  2022-10-21 15:46 ` Teemu Likonen
@ 2022-10-21 15:57 ` Jean Louis
  2022-10-21 16:12   ` Heime
  2 siblings, 1 reply; 24+ messages in thread
From: Jean Louis @ 2022-10-21 15:57 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

* Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-10-21 17:18]:
> I am printing a list named "cunex" in the messages buffer. I would also like to store what is printed so I can insert
> the contents somewhere else, without having to go to the "*Messages*" buffer to copy it.
> 
> (message "%s" cunex)

I use this function:

(defun rcd-kill-new (kill)
  (cond ((stringp kill) (progn 
			  (kill-new kill)
			  (rcd-message "Killed: %s" kill)))
	 (t (rcd-message "😧 WARNING: Nothing to kill."))))

You may change `rcd-message' to message.

If you wish to kill the list, then you need to do something like:

(kill-new (prin1-to-string '(1 2 3 "My" "List" 10 20))) ⇒ t

Then you do C-y:

(1 2 3 "My" "List" 10 20)


-- 
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] 24+ messages in thread

* Re: Copying a list for insertion
  2022-10-21 15:57 ` Jean Louis
@ 2022-10-21 16:12   ` Heime
  2022-10-21 17:26     ` Heime
  2022-10-21 19:26     ` Heime
  0 siblings, 2 replies; 24+ messages in thread
From: Heime @ 2022-10-21 16:12 UTC (permalink / raw)
  To: Jean Louis; +Cc: Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Friday, October 21st, 2022 at 3:57 PM, Jean Louis <bugs@gnu.support> wrote:


> * Heime via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org [2022-10-21 17:18]:
> 
> > I am printing a list named "cunex" in the messages buffer. I would also like to store what is printed so I can insert
> > the contents somewhere else, without having to go to the "Messages" buffer to copy it.
> > 
> > (message "%s" cunex)
> 
> 
> I use this function:
> 
> (defun rcd-kill-new (kill)
> (cond ((stringp kill) (progn
> (kill-new kill)
> (rcd-message "Killed: %s" kill)))
> (t (rcd-message "😧 WARNING: Nothing to kill."))))
> 
> You may change `rcd-message' to message.
> 
> If you wish to kill the list, then you need to do something like:
> 
> (kill-new (prin1-to-string '(1 2 3 "My" "List" 10 20))) ⇒ t
> 
> Then you do C-y:
> 
> (1 2 3 "My" "List" 10 20)

Have done so, but doing M-w does not insert the string.



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

* Re: Copying a list for insertion
  2022-10-21 16:12   ` Heime
@ 2022-10-21 17:26     ` Heime
  2022-10-21 17:32       ` Jean Louis
  2022-10-21 19:26     ` Heime
  1 sibling, 1 reply; 24+ messages in thread
From: Heime @ 2022-10-21 17:26 UTC (permalink / raw)
  To: Jean Louis; +Cc: Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Friday, October 21st, 2022 at 4:12 PM, Heime <heimeborgia@protonmail.com> wrote:


> ------- Original Message -------
> On Friday, October 21st, 2022 at 3:57 PM, Jean Louis bugs@gnu.support wrote:
> 
> 
> 
> > * Heime via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org [2022-10-21 17:18]:
> > 
> > > I am printing a list named "cunex" in the messages buffer. I would also like to store what is printed so I can insert
> > > the contents somewhere else, without having to go to the "Messages" buffer to copy it.
> > > 
> > > (message "%s" cunex)
> > 
> > I use this function:
> > 
> > (defun rcd-kill-new (kill)
> > (cond ((stringp kill) (progn
> > (kill-new kill)
> > (rcd-message "Killed: %s" kill)))
> > (t (rcd-message "😧 WARNING: Nothing to kill."))))
> > 
> > You may change `rcd-message' to message.
> > 
> > If you wish to kill the list, then you need to do something like:
> > 
> > (kill-new (prin1-to-string '(1 2 3 "My" "List" 10 20))) ⇒ t
> > 
> > Then you do C-y:
> > 
> > (1 2 3 "My" "List" 10 20)
> 
> 
> Have done so, but doing M-w does not insert the string.

prin1-to-string inserts double quotes.  Because my list is composed of string
items only, I want to exclude tho double quotes on each list entry.








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

* Re: Copying a list for insertion
  2022-10-21 17:26     ` Heime
@ 2022-10-21 17:32       ` Jean Louis
  0 siblings, 0 replies; 24+ messages in thread
From: Jean Louis @ 2022-10-21 17:32 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

* Heime <heimeborgia@protonmail.com> [2022-10-21 20:26]:
> > Have done so, but doing M-w does not insert the string.
> 
> prin1-to-string inserts double quotes.  Because my list is composed of string
> items only, I want to exclude tho double quotes on each list entry.

M-w is to kill, C-y is to yank

So you wish to have list like '("Hello" "There") and to get '(Hello
There)?

(kill-new (format "%s" '("Hello" "There")))

(Hello There)


-- 
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] 24+ messages in thread

* Re: Copying a list for insertion
  2022-10-21 16:12   ` Heime
  2022-10-21 17:26     ` Heime
@ 2022-10-21 19:26     ` Heime
  2022-10-21 20:32       ` Jean Louis
  2022-10-21 22:00       ` Heime
  1 sibling, 2 replies; 24+ messages in thread
From: Heime @ 2022-10-21 19:26 UTC (permalink / raw)
  To: Heime; +Cc: Jean Louis, Heime via Users list for the GNU Emacs text editor


------- Original Message -------
On Friday, October 21st, 2022 at 4:12 PM, Heime <heimeborgia@protonmail.com> wrote:


> ------- Original Message -------
> On Friday, October 21st, 2022 at 3:57 PM, Jean Louis bugs@gnu.support wrote:
> 
> 
> 
> > * Heime via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org [2022-10-21 17:18]:
> > 
> > > I am printing a list named "cunex" in the messages buffer. I would also like to store what is printed so I can insert
> > > the contents somewhere else, without having to go to the "Messages" buffer to copy it.
> > > 
> > > (message "%s" cunex)
> > 
> > I use this function:
> > 
> > (defun rcd-kill-new (kill)
> > (cond ((stringp kill) (progn
> > (kill-new kill)
> > (rcd-message "Killed: %s" kill)))
> > (t (rcd-message "😧 WARNING: Nothing to kill."))))
> > 
> > You may change `rcd-message' to message.
> > 
> > If you wish to kill the list, then you need to do something like:
> > 
> > (kill-new (prin1-to-string '(1 2 3 "My" "List" 10 20))) ⇒ t
> > 
> > Then you do C-y:
> > 
> > (1 2 3 "My" "List" 10 20)

Have wrongly assumed that "kill-new" would pass the string for use to 
"mouse-yank-primary".  Any idea how to pass the string for mouse yank
and keyboard yank with "M-w" ?






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

* Re: Copying a list for insertion
  2022-10-21 19:26     ` Heime
@ 2022-10-21 20:32       ` Jean Louis
  2022-10-21 22:00       ` Heime
  1 sibling, 0 replies; 24+ messages in thread
From: Jean Louis @ 2022-10-21 20:32 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

* Heime <heimeborgia@protonmail.com> [2022-10-21 22:27]:
> Have wrongly assumed that "kill-new" would pass the string for use to 
> "mouse-yank-primary".  Any idea how to pass the string for mouse yank
> and keyboard yank with "M-w" ?

Enable select-enable-primary

Then using kill-new will make that.


-- 
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] 24+ messages in thread

* Re: Copying a list for insertion
  2022-10-21 19:26     ` Heime
  2022-10-21 20:32       ` Jean Louis
@ 2022-10-21 22:00       ` Heime
  2022-10-22  0:28         ` Jean Louis
  1 sibling, 1 reply; 24+ messages in thread
From: Heime @ 2022-10-21 22:00 UTC (permalink / raw)
  To: Heime; +Cc: Jean Louis, Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Friday, October 21st, 2022 at 7:26 PM, Heime <heimeborgia@protonmail.com> wrote:


> ------- Original Message -------
> On Friday, October 21st, 2022 at 4:12 PM, Heime heimeborgia@protonmail.com wrote:
> 
> 
> 
> > ------- Original Message -------
> > On Friday, October 21st, 2022 at 3:57 PM, Jean Louis bugs@gnu.support wrote:
> > 
> > > * Heime via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org [2022-10-21 17:18]:
> > > 
> > > > I am printing a list named "cunex" in the messages buffer. I would also like to store what is printed so I can insert
> > > > the contents somewhere else, without having to go to the "Messages" buffer to copy it.
> > > > 
> > > > (message "%s" cunex)
> > > 
> > > I use this function:
> > > 
> > > (defun rcd-kill-new (kill)
> > > (cond ((stringp kill) (progn
> > > (kill-new kill)
> > > (rcd-message "Killed: %s" kill)))
> > > (t (rcd-message "😧 WARNING: Nothing to kill."))))
> > > 
> > > You may change `rcd-message' to message.
> > > 
> > > If you wish to kill the list, then you need to do something like:
> > > 
> > > (kill-new (prin1-to-string '(1 2 3 "My" "List" 10 20))) ⇒ t
> > > 
> > > Then you do C-y:
> > > 
> > > (1 2 3 "My" "List" 10 20)

Any reason why you use "progn" in the "stringp" condition?



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

* Re: Copying a list for insertion
  2022-10-21 22:00       ` Heime
@ 2022-10-22  0:28         ` Jean Louis
  2022-10-22  0:48           ` Emanuel Berg
                             ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Jean Louis @ 2022-10-22  0:28 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

* Heime <heimeborgia@protonmail.com> [2022-10-22 02:06]:
> Any reason why you use "progn" in the "stringp" condition?

(defun rcd-kill-new (kill)
  (cond ((stringp kill) (progn 
			  (kill-new kill)
			  (rcd-message "Killed: %s" kill)))
	 (t (rcd-message "😧 WARNING: Nothing to kill."))))

I use it to enclose two functions in one body of functions as `cond'
does not allow me to use 2 functions for one condition without
enclosing.

-- 
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] 24+ messages in thread

* Re: Copying a list for insertion
  2022-10-22  0:28         ` Jean Louis
@ 2022-10-22  0:48           ` Emanuel Berg
  2022-10-22 11:23             ` Jean Louis
  2022-10-22  1:02           ` Heime
  2022-10-22  1:04           ` Emanuel Berg
  2 siblings, 1 reply; 24+ messages in thread
From: Emanuel Berg @ 2022-10-22  0:48 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>> Any reason why you use "progn" in the "stringp" condition?
>
> (defun rcd-kill-new (kill)
>   (cond ((stringp kill) (progn 
> 			  (kill-new kill)
> 			  (rcd-message "Killed: %s" kill)))
> 	 (t (rcd-message "😧 WARNING: Nothing to kill."))))
>
> I use it to enclose two functions in one body of functions
> as `cond' does not allow me to use 2 functions for one
> condition without enclosing.

(if (not (stringp str)) ... )

You can also do

  (let ((str (format "%s" data))) ...)

But as you know there is already `kill-new' ... `advice-add',
maybe that happens all the time tho so you don't want that?
I guess you'll find out. There is `advice-remove'.

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




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

* Re: Copying a list for insertion
  2022-10-22  0:28         ` Jean Louis
  2022-10-22  0:48           ` Emanuel Berg
@ 2022-10-22  1:02           ` Heime
  2022-10-22  1:20             ` Emanuel Berg
  2022-10-22  6:43             ` Jean Louis
  2022-10-22  1:04           ` Emanuel Berg
  2 siblings, 2 replies; 24+ messages in thread
From: Heime @ 2022-10-22  1:02 UTC (permalink / raw)
  To: Jean Louis; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

------- Original Message -------
On Saturday, October 22nd, 2022 at 12:28 AM, Jean Louis <bugs@gnu.support> wrote:


> * Heime heimeborgia@protonmail.com [2022-10-22 02:06]:
> 
> > Any reason why you use "progn" in the "stringp" condition?
> 
> 
> (defun rcd-kill-new (kill)
> (cond ((stringp kill) (progn
> (kill-new kill)
> (rcd-message "Killed: %s" kill)))
> (t (rcd-message "😧 WARNING: Nothing to kill."))))
> 
> I use it to enclose two functions in one body of functions as `cond'
> does not allow me to use 2 functions for one condition without
> enclosing.

"cond" allows multiple body-forms in one clause.  Thusly no need for "progn".





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

* Re: Copying a list for insertion
  2022-10-22  0:28         ` Jean Louis
  2022-10-22  0:48           ` Emanuel Berg
  2022-10-22  1:02           ` Heime
@ 2022-10-22  1:04           ` Emanuel Berg
  2022-10-22 11:34             ` Jean Louis
  2 siblings, 1 reply; 24+ messages in thread
From: Emanuel Berg @ 2022-10-22  1:04 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> (defun rcd-kill-new (kill)
>   (cond ((stringp kill) (progn 
> 			  (kill-new kill)
> 			  (rcd-message "Killed: %s" kill)))
> 	 (t (rcd-message "😧 WARNING: Nothing to kill."))))

;; (advice-add    #'kill-new :after (lambda (&rest str) (message "%s" str)))
;; (advice-remove #'kill-new        (lambda (&rest str) (message "%s" str)))

But it doesn't make sense since you see it before you kill it
anyway ...

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




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

* Re: Copying a list for insertion
  2022-10-22  1:02           ` Heime
@ 2022-10-22  1:20             ` Emanuel Berg
  2022-10-22  6:43             ` Jean Louis
  1 sibling, 0 replies; 24+ messages in thread
From: Emanuel Berg @ 2022-10-22  1:20 UTC (permalink / raw)
  To: help-gnu-emacs

Heime wrote:

>> I use it to enclose two functions in one body of functions
>> as `cond' does not allow me to use 2 functions for one
>> condition without enclosing.
>
> "cond" allows multiple body-forms in one clause. Thusly no
> need for "progn".

Nor for `cond' ...

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




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

* Re: Copying a list for insertion
  2022-10-22  1:02           ` Heime
  2022-10-22  1:20             ` Emanuel Berg
@ 2022-10-22  6:43             ` Jean Louis
  2022-10-22  6:52               ` Heime
  2022-10-22  7:07               ` tomas
  1 sibling, 2 replies; 24+ messages in thread
From: Jean Louis @ 2022-10-22  6:43 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

* Heime <heimeborgia@protonmail.com> [2022-10-22 04:03]:
> > * Heime heimeborgia@protonmail.com [2022-10-22 02:06]:
> > 
> > > Any reason why you use "progn" in the "stringp" condition?
> > 
> > 
> > (defun rcd-kill-new (kill)
> > (cond ((stringp kill) (progn
> > (kill-new kill)
> > (rcd-message "Killed: %s" kill)))
> > (t (rcd-message "😧 WARNING: Nothing to kill."))))
> > 
> > I use it to enclose two functions in one body of functions as `cond'
> > does not allow me to use 2 functions for one condition without
> > enclosing.
> 
> "cond" allows multiple body-forms in one clause.  Thusly no need for "progn".

Show me how please. I do not understand it.

-- 
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] 24+ messages in thread

* Re: Copying a list for insertion
  2022-10-22  6:43             ` Jean Louis
@ 2022-10-22  6:52               ` Heime
  2022-10-22 10:09                 ` Jean Louis
  2022-10-22  7:07               ` tomas
  1 sibling, 1 reply; 24+ messages in thread
From: Heime @ 2022-10-22  6:52 UTC (permalink / raw)
  To: Jean Louis; +Cc: Heime via Users list for the GNU Emacs text editor

------- Original Message -------
On Saturday, October 22nd, 2022 at 6:43 AM, Jean Louis <bugs@gnu.support> wrote:


> * Heime heimeborgia@protonmail.com [2022-10-22 04:03]:
> 
> > > * Heime heimeborgia@protonmail.com [2022-10-22 02:06]:
> > > 
> > > > Any reason why you use "progn" in the "stringp" condition?
> > > 
> > > (defun rcd-kill-new (kill)
> > > (cond ((stringp kill) (progn
> > > (kill-new kill)
> > > (rcd-message "Killed: %s" kill)))
> > > (t (rcd-message "😧 WARNING: Nothing to kill."))))
> > > 
> > > I use it to enclose two functions in one body of functions as `cond'
> > > does not allow me to use 2 functions for one condition without
> > > enclosing.
> > 
> > "cond" allows multiple body-forms in one clause. Thusly no need for "progn".
> 
> 
> Show me how please. I do not understand it.

(defun rcd-kill-new (kill)

(cond ((stringp kill)

      (kill-new kill)
      (rcd-message "Killed: %s" kill))

(t (rcd-message "😧 WARNING: Nothing to kill."))))



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

* Re: Copying a list for insertion
  2022-10-22  6:43             ` Jean Louis
  2022-10-22  6:52               ` Heime
@ 2022-10-22  7:07               ` tomas
  1 sibling, 0 replies; 24+ messages in thread
From: tomas @ 2022-10-22  7:07 UTC (permalink / raw)
  To: help-gnu-emacs

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

On Sat, Oct 22, 2022 at 09:43:31AM +0300, Jean Louis wrote:
> * Heime <heimeborgia@protonmail.com> [2022-10-22 04:03]:

[...]

> > "cond" allows multiple body-forms in one clause.  Thusly no need for "progn".
> 
> Show me how please. I do not understand it.

Heime is right:

  (defun do-something (arg)
    (cond
     ((eq arg 'this)
      (message "yes, this")
      (message "did I say this?")
      (message "yes, I said"))
     ((eq arg 'that)
      (message "what was that?")
      (message "this example gets boring"))
     (t
      (message "what?"))))
  
  (do-something 'this)

Besides, the doco says that a clause returns its last espression's
value, so it does behave like many little progn.

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: Copying a list for insertion
  2022-10-22  6:52               ` Heime
@ 2022-10-22 10:09                 ` Jean Louis
  0 siblings, 0 replies; 24+ messages in thread
From: Jean Louis @ 2022-10-22 10:09 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

* Heime <heimeborgia@protonmail.com> [2022-10-22 10:30]:
> > Show me how please. I do not understand it.

> (defun rcd-kill-new (kill)
> 
> (cond ((stringp kill)
> 
>       (kill-new kill)
>       (rcd-message "Killed: %s" kill))
> 
> (t (rcd-message "😧 WARNING: Nothing to kill."))))

I had no idea that it works that way, alright, thanks.

-- 
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] 24+ messages in thread

* Re: Copying a list for insertion
  2022-10-22  0:48           ` Emanuel Berg
@ 2022-10-22 11:23             ` Jean Louis
  2022-10-24 20:58               ` Emanuel Berg
  0 siblings, 1 reply; 24+ messages in thread
From: Jean Louis @ 2022-10-22 11:23 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <incal@dataswamp.org> [2022-10-22 14:08]:
> Jean Louis wrote:
> 
> >> Any reason why you use "progn" in the "stringp" condition?
> >
> > (defun rcd-kill-new (kill)
> >   (cond ((stringp kill) (progn 
> > 			  (kill-new kill)
> > 			  (rcd-message "Killed: %s" kill)))
> > 	 (t (rcd-message "😧 WARNING: Nothing to kill."))))
> >
> > I use it to enclose two functions in one body of functions
> > as `cond' does not allow me to use 2 functions for one
> > condition without enclosing.
> 
> (if (not (stringp str)) ... )

`cond' gives me better overview and I often expand conditions in
future. Long term, `cond' is more flexible then `if'.

> You can also do
> 
>   (let ((str (format "%s" data))) ...)
> 
> But as you know there is already `kill-new' ... `advice-add',
> maybe that happens all the time tho so you don't want that?
> I guess you'll find out. There is `advice-remove'.

Aha, well, I can't use `message' as it does not give me specific
control over my messages. By changing all occurences of `message' to
my specific messaging function, I can then decide what to do with
those messages, for example, I can see them in separate buffer. They
also go in main message buffer, but I like having my separate
buffer. Then I can also choose different buffers for different
purposes, having the actual on the fly log for messages that is
specific to some package or program.

My messaging buffer looks like this:

2022-10-22-14:07:02 RCD DB: updated table `usersdefaults', column `usersdefaults_numberoflatestentries', ID: 1
2022-10-22-14:07:04 Fetching list of people
2022-10-22-14:07:04 Total of 1000 people
2022-10-22-14:08:14 RCD DB: updated table `people', column `people_hyobjects1', ID: 363293

I could as well direct my messages to file for later examination. But
if they are all mixed in one main *Messages* buffer, that is not
enough useful.

-- 
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] 24+ messages in thread

* Re: Copying a list for insertion
  2022-10-22  1:04           ` Emanuel Berg
@ 2022-10-22 11:34             ` Jean Louis
  2022-10-24 20:57               ` Emanuel Berg
  0 siblings, 1 reply; 24+ messages in thread
From: Jean Louis @ 2022-10-22 11:34 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <incal@dataswamp.org> [2022-10-22 14:17]:
> Jean Louis wrote:
> 
> > (defun rcd-kill-new (kill)
> >   (cond ((stringp kill) (progn 
> > 			  (kill-new kill)
> > 			  (rcd-message "Killed: %s" kill)))
> > 	 (t (rcd-message "😧 WARNING: Nothing to kill."))))
> 
> ;; (advice-add    #'kill-new :after (lambda (&rest str) (message "%s" str)))
> ;; (advice-remove #'kill-new        (lambda (&rest str) (message "%s" str)))

WYMINWYS - What you mean is not what you see.

Purpose of my function `rcd-kill-new' is not to send message what was
killed, but in general to be able to intercept information and
eventually record it, track it, or generate statistics out of it,
which in turn gives information how to shorten workflows or which new
functions to make. Imagine many programming lines, without direct
`kill-new' function and much of killing activity. Inspection of what
was killed leads to improvements.

-- 
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] 24+ messages in thread

* Re: Copying a list for insertion
  2022-10-22 11:34             ` Jean Louis
@ 2022-10-24 20:57               ` Emanuel Berg
  0 siblings, 0 replies; 24+ messages in thread
From: Emanuel Berg @ 2022-10-24 20:57 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> Inspection of what was killed leads to improvements.

Sure, "Look guys, this time it worked!"

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




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

* Re: Copying a list for insertion
  2022-10-22 11:23             ` Jean Louis
@ 2022-10-24 20:58               ` Emanuel Berg
  0 siblings, 0 replies; 24+ messages in thread
From: Emanuel Berg @ 2022-10-24 20:58 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> Aha, well, I can't use `message' as it does not give me
> specific control over my messages.

The word on the street is that messaging is an underpowered
area of Emacs ...

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




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

end of thread, other threads:[~2022-10-24 20:58 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-21 14:16 Copying a list for insertion Heime via Users list for the GNU Emacs text editor
2022-10-21 14:35 ` Manuel Giraud
2022-10-21 15:03   ` Heime
2022-10-21 15:46 ` Teemu Likonen
2022-10-21 15:57 ` Jean Louis
2022-10-21 16:12   ` Heime
2022-10-21 17:26     ` Heime
2022-10-21 17:32       ` Jean Louis
2022-10-21 19:26     ` Heime
2022-10-21 20:32       ` Jean Louis
2022-10-21 22:00       ` Heime
2022-10-22  0:28         ` Jean Louis
2022-10-22  0:48           ` Emanuel Berg
2022-10-22 11:23             ` Jean Louis
2022-10-24 20:58               ` Emanuel Berg
2022-10-22  1:02           ` Heime
2022-10-22  1:20             ` Emanuel Berg
2022-10-22  6:43             ` Jean Louis
2022-10-22  6:52               ` Heime
2022-10-22 10:09                 ` Jean Louis
2022-10-22  7:07               ` tomas
2022-10-22  1:04           ` Emanuel Berg
2022-10-22 11:34             ` Jean Louis
2022-10-24 20:57               ` Emanuel Berg

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.