Subject: Re: bug#6635: mouse-yank-primary/secondary and unicode from other apps.

From: Kevin Rodgers <[email-masked]>
Date: Wed, 14 Jul 2010 23:29:11 -0600

David De La Harpe Golden wrote:
> mouse-yank-primary and mouse-yank-secondary don't like
> inserting non-ascii chars from other apps.
> 
> They need to use the slightly higher-level
> (x-selection-value 'PRIMARY)
> 
> or at least give a 'TEXT arg to their
> (x-get-selection 'PRIMARY 'TEXT),
> 
> so that the proper kinds of selection type are tried
> as e.g. attached.
...
-  (let ((primary (x-get-selection 'PRIMARY)))
+  (let ((primary (x-selection-value 'PRIMARY)))
      (if primary
-        (insert (x-get-selection 'PRIMARY))
+        (insert (x-selection-value 'PRIMARY))
        (error "No primary selection"))))
...
-  (let ((secondary (x-get-selection 'SECONDARY)))
+  (let ((secondary (x-selection-value 'SECONDARY)))
      (if secondary
-        (insert (x-get-selection 'SECONDARY))
+        (insert (x-selection-value 'SECONDARY))
        (error "No secondary selection"))))

Can someone explain why the result of x-get-selection/x-selection-value
is bound to a variable, but instead of referencing the variable in the
insert function call the expression is evaluated again?  I.e. why not
change it to:

  (let ((primary (x-selection-value 'PRIMARY)))
    (if primary
        (insert primary)
      (error "No primary selection"))))
...
  (let ((secondary (x-selection-value 'SECONDARY)))
    (if secondary
        (insert secondary)
      (error "No secondary selection"))))

Thanks,

-- 
Kevin Rodgers
Denver, Colorado, USA