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

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

Re: google-translate


From: Emanuel Berg
Subject: Re: google-translate
Date: Sat, 19 Sep 2015 17:25:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Ian Zimmerman <itz@buug.org> writes:

>> (defun translate (src-lang dst-lang text)
>>   (interactive)
>>   (let ((killed kill-ring))
>>     (google-translate-translate src-lang dst-lang text 'kill-ring)
>>     (let ((translation (string-make-unibyte (current-kill 0))))
>                           ^^^^^^^^^^^^^^^^^^^
> Why do you do that? That may be your problem
> right there.

That was it! The reason I put it there was to get rid
of the properties. I replaced it with
`substring-no-properties' but it seems that isn't
needed either. The reason I thought it was needed is:
put the region around this word: spiderweb - and hit
M-w (`kill-ring-save'). Now evaluate:

    (message "%s" (current-kill 0))

this will show:

    #("spiderweb" 0 9 (fontified t))

now evaluate:

    (message "%s" (substring-no-properties (current-kill 0)))

and get the desired:

    "spiderweb"

however this:

    (progn
      (kill-new "spiderwebs")
      (message "%s" (current-kill 0)) )

also gives no properties! So perhaps it is an
interactive/noninteractive issue as in a string (as
*data*), regardless how it is showed, there aren't
 any properties.

Anyway, thank you. Here is the most recent edition:

    (defun translate (src-lang dst-lang text)
      (interactive)
      (let ((killed kill-ring))
        (google-translate-translate src-lang dst-lang text 'kill-ring)
        (let ((translation (current-kill 0)))
          (setq kill-ring-yank-pointer killed)
          (message "%s: %s" text translation) )))

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

[Prev in Thread] Current Thread [Next in Thread]