unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xavier Maillard <xma@gnu.org>
To: Marc Tfardy <m-t-o___CUT__IT@web.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Quick math calc on any buffer
Date: Tue, 24 Feb 2009 16:25:07 +0100	[thread overview]
Message-ID: <200902241525.n1OFP7mP015275@zogzog.maillard.mobi> (raw)
In-Reply-To: message from Marc Tfardy on Sun, 22 Feb 2009 18:16:51 +0100

Hi,

   > (defun my-calc-result (beg end)
   >   (interactive "r")
   >   (insert " = " (calc-eval (buffer-substring beg end))))

   Great! Much more elegant than my last attempt:

   (defun my-calc-result2 (beg end)
      (interactive "r")
      (insert " = " (number-to-string (apply 'eval (math-read-exprs 
   (buffer-substring beg end))))))

This works partially and insert the result in the wrong place if
you mark the region in the inverse order -i.e beg is end and end
is beg.

Regards,
	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org




             reply	other threads:[~2009-02-24 15:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-24 15:25 Xavier Maillard [this message]
     [not found] <mailman.1378.1235234577.31690.help-gnu-emacs@gnu.org>
2009-02-21 19:08 ` Quick math calc on any buffer B. T. Raven
2009-02-21 19:50   ` Thierry Volpiatto
2009-02-21 22:53 ` Marc Tfardy
2009-02-21 23:37   ` Richard Riley
2009-02-22 12:45 ` Scott Frazer
2009-02-22 14:30   ` Rodrigo Lazo
2009-02-22 17:16   ` Marc Tfardy
2009-02-24 23:20   ` Chetan
2009-02-24 23:29     ` Marc Tfardy
2009-02-25  0:22       ` Chetan
  -- strict thread matches above, loose matches on Subject: below --
2009-02-21 16:42 Rodrigo Lazo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200902241525.n1OFP7mP015275@zogzog.maillard.mobi \
    --to=xma@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    --cc=m-t-o___CUT__IT@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).