Message: 3
Date: Wed, 03 May 2006 11:35:30 +0200
From: Mathias Dahl <brakjoller@gmail.com>
Subject: Re: Execute as a command a yanked text
To: help-gnu-emacs@gnu.org
Message-ID: <ubquftpr1.fsf@gmail.com>
Content-Type: text/plain; charset=us-ascii
Stefan Horomnea <stefan@softexperience.ro> writes:
Hello,
Do you have any idea how to execute a text that was previously killed ?
I mean, I have a function named insert-html-table.
This code works:
(command-execute 'insert-html-table)
This code doesn't work:
(command-execute (car kill-ring-yank-pointer))
*and I have previously killed "insert-html-table"
and, this also works (insert (car kill-ring-yank-pointer)) - and
inserts the text: "insert-html-table".
The problem seems to be that (car kill-ring-yank-pointer) returns a
*string*, not a symbol which `command-execute' needs. Maybe this
works (untested):
(command-execute (make-symbol (car kill-ring-yank-pointer)))
Try it.
------------------------------
Message: 4
Date: Wed, 03 May 2006 11:56:19 +0200
From: David Kastrup <dak@gnu.org>
Subject: Re: Execute as a command a yanked text
To: help-gnu-emacs@gnu.org
Message-ID: <85mzdzo2ik.fsf@lola.goethe.zz>
Content-Type: text/plain; charset=us-ascii
Mathias Dahl <brakjoller@gmail.com> writes:
The problem seems to be that (car kill-ring-yank-pointer) returns a
*string*, not a symbol which `command-execute' needs. Maybe this
works (untested):
(command-execute (make-symbol (car kill-ring-yank-pointer)))
Won't work because make-symbol returns an uninterned symbol (which has
the print name "insert-html-table", but not the meaning of the
previously interned symbol with the same name):
make-symbol is a built-in function in `C source code'.
(make-symbol NAME)
Return a newly allocated uninterned symbol whose name is NAME.
Its value and function definition are void, and its property list
is nil.
Instead you need to use intern:
intern is a built-in function in `C source code'.
(intern STRING &optional OBARRAY)
Return the canonical symbol whose name is STRING.
If there is none, one is created by this function and returned.
A second optional argument specifies the obarray to use;
it defaults to the value of `obarray'.