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

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

Re: copy-region-to-variable


From: Joakim Hove
Subject: Re: copy-region-to-variable
Date: Wed, 04 Feb 2004 14:14:57 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

"hans nieuwenhuizen" <address@hidden> writes:

> None of the almost 2000 built-in functions of emacs 21.2 seems to copy part
> of the buffer ( region ) into a variable.
>
> You need that e.g. if you have to enlarge the double in the region by a
> factor of
> say 3.456 .

If you just mean the text content of the buffer you can use

(buffer-substring p1 p2)

or

(buffer-substring-no-properties p1 p2) 

which return the buffer-content between p1 and p2.

HTH Joakim

Untested:
---------

(defun enlarge-double (p1 p2)
  (interactive "r")
  (let  ((new-number    (* 3.456 (string-to-number  
(buffer-substring-no-properties p1 p2)))))
     (kill-region p1 p2)
     (goto-char p1)
     (insert (format "%s" new-number))))   
         

-- 
  /--------------------------------------------------------------------\
 / Joakim Hove  / address@hidden  /  (55 5) 84076       |                 \
 | Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
 | CMU                                                | 5231 Paradis    |
 \ Thormøhlensgt.55, 5020 Bergen.                     | 55 91 28 18     /
  \--------------------------------------------------------------------/


reply via email to

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