unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Evaluating a variable under point?
@ 2010-06-30 14:33 Elena
       [not found] ` <877hlgtwhb.fsf@fh-trier.de>
  0 siblings, 1 reply; 3+ messages in thread
From: Elena @ 2010-06-30 14:33 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I'm trying to write an interactive function which evaluates variable
at point, unless region is active. Currently it looks like this:

(defun smart-eval ()
	(interactive)
	(if mark-active
		(eval-region)
		(case (char-syntax  (char-after))
		  ((?w ?_)
		   (eval-expression (string (thing-at-point 'symbol))))
		  (t
		   (message "Nothing to evaluate.")))))

However, I'm not getting results. What's wrong?

Thanks.


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

* Re: Evaluating a variable under point?
       [not found] ` <877hlgtwhb.fsf@fh-trier.de>
@ 2010-06-30 15:07   ` Elena
  2010-06-30 19:18     ` Andreas Politz
  0 siblings, 1 reply; 3+ messages in thread
From: Elena @ 2010-06-30 15:07 UTC (permalink / raw)
  To: help-gnu-emacs

On 30 Giu, 14:40, Andreas Politz <poli...@fh-trier.de> wrote:
> Maybe you want to write
>
> (eval (intern (thing-at-point ...

Thanks Andreas.

I get the behavior I expect when I evaluate the following into
*scratch*:

 		   (message (eval (intern "mark-active")))

However:

		   (message (eval (intern (thing-at-point 'symbol))))

does not work when point is over an occurrence of "mark-active" into a
buffer.




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

* Re: Evaluating a variable under point?
  2010-06-30 15:07   ` Elena
@ 2010-06-30 19:18     ` Andreas Politz
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Politz @ 2010-06-30 19:18 UTC (permalink / raw)
  To: help-gnu-emacs

Elena <egarrulo@gmail.com> writes:

> On 30 Giu, 14:40, Andreas Politz <poli...@fh-trier.de> wrote:
>> Maybe you want to write
>>
>> (eval (intern (thing-at-point ...
>
> Thanks Andreas.
>
> I get the behavior I expect when I evaluate the following into
> *scratch*:
>
>  		   (message (eval (intern "mark-active")))
>
> However:
>
> 		   (message (eval (intern (thing-at-point 'symbol))))
>
> does not work when point is over an occurrence of "mark-active" into a
> buffer.

I think the observed difference comes from different methods of
evaluation.  Anyway, you should use a format-string
(message "%s" expr)
.  Read the documentation of `message'.

-ap


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

end of thread, other threads:[~2010-06-30 19:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-30 14:33 Evaluating a variable under point? Elena
     [not found] ` <877hlgtwhb.fsf@fh-trier.de>
2010-06-30 15:07   ` Elena
2010-06-30 19:18     ` Andreas Politz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).