Wei-Wei Guo | 1 Jul 03:12 2010
Picon

Re: Is there any way to append a EasyPG encrypted file?

Hi Alex,

>>
>> I use GnuPG key to encrypt my 'remember' file, but EasyPG does not support
>> appending file.
>> Is there any way to append an encrypted file?
>
> Not without decoding and re-encoding the file.
>

I find the following lines in the epa-file.el:

(defun epa-file-write-region (start end file &optional append visit lockname
				    mustbenew)
   (if append
       (error "Can't append to the file"))
   ...

It seems easypg disable the ability intentionally. I don't know how to solve...

> I suppose you could come up with some sort of scheme that would
> result in a text file with a series of ASCII armored GPG blocks that can be
> decoded and concatenated together when read.
>

I don't understand what to do. Could you say something more?

Best wishes,
Wei-Wei

(Continue reading)

Seweryn Kokot | 1 Jul 15:55 2010
Picon

How modify numbers in a region by a multiplier?

Hi,

I would like to modify numbers in a region/buffer by a given multiplier.

Imagine that I have some numbers

33.444 3333 4433.4443 3344 .34234

and I want them multiplied for example by 0.1

to receive

3.3444 333.3 443.34443 334.4 .034234

I tried with this function I wrote, but it doesn't work properly.
Any idea why?

(defun my-multiply-numbers-in-region-or-buffer (multiplier)
  (interactive "nGive multiplier: ")
  (let (beg end object)
	(if (use-region-p)
        (progn
          (setq object "region")
          (setq beg (region-beginning))
          (setq end (region-end)))
      (setq object "buffer")
      (setq beg (point-min))
      (setq end (point-max)))
	(goto-char beg)
	(while (re-search-forward "\\([0-9]*\\.?[0-9]*\\)" end t)
(Continue reading)

Juanma Barranquero | 1 Jul 16:16 2010
Picon

Re: How modify numbers in a region by a multiplier?

On Thu, Jul 1, 2010 at 15:55, Seweryn Kokot <sewkokot <at> gmail.com> wrote:

> Imagine that I have some numbers
>
> 33.444 3333 4433.4443 3344 .34234
>
> and I want them multiplied for example by 0.1
>
> to receive
>
> 3.3444 333.3 443.34443 334.4 .034234

Interactively, you can try with some variation of

M-x replace-regexp \([0-9.]+\) <RET> \,(/ (string-to-number \1) 10.0) <RET>

    Juanma

Seweryn Kokot | 1 Jul 16:31 2010
Picon

Re: How modify numbers in a region by a multiplier?

Juanma Barranquero <lekktu <at> gmail.com> writes:

> Interactively, you can try with some variation of
> 
> M-x replace-regexp \([0-9.]+\) <RET> \,(/ (string-to-number \1) 10.0) <RET>

Thank you it works! But why my function does not work since re-search-forward 
and replace-match is recommended in lisp functions?

Dan Davison | 1 Jul 17:01 2010
Picon
Picon

Re: How modify numbers in a region by a multiplier?

Juanma Barranquero <lekktu <at> gmail.com> writes:

> On Thu, Jul 1, 2010 at 15:55, Seweryn Kokot <sewkokot <at> gmail.com> wrote:
>
>> Imagine that I have some numbers
>>
>> 33.444 3333 4433.4443 3344 .34234
>>
>> and I want them multiplied for example by 0.1
>>
>> to receive
>>
>> 3.3444 333.3 443.34443 334.4 .034234

Here are three solutions using Org-mode.

* Using the Org spreadsheet
http://orgmode.org/org.html#The-spreadsheet
http://orgmode.org/worg/org-tutorials/org-spreadsheet-intro.php

Leave second column blank; issue C-u C-c C-c with point in the table 

|    33.444 |    3.3444 |
|      3333 |     333.3 |
| 4433.4443 | 443.34443 |
|      3344 |     334.4 |
|   0.34234 |  0.034234 |
#+tblfm: $2=$1*0.1

* Using Org-babel
(Continue reading)

Juanma Barranquero | 1 Jul 17:56 2010
Picon

Re: How modify numbers in a region by a multiplier?

On Thu, Jul 1, 2010 at 16:31, Seweryn Kokot <sewkokot <at> gmail.com> wrote:

> But why my function does not work since re-search-forward
> and replace-match is recommended in lisp functions?

The regexp you use to match the numbers

  "\\([0-9]*\\.?[0-9]*\\)"

matches also the empty string, so after 33.444 it matches on "" and
generates .000, and then matches again on "" and generates another
.000, etc.

I just used "\\([0-9.]+\\)", which is less precise (it'll match
"1..2", ".", ".3.", etc.), but for quick-and-dirty jobs is enough.
You'll have to fix your regexp, or move point one character forward if
you matched the empty string.

    Juanma

Qiang Guo | 1 Jul 18:54 2010
Picon

Re: How modify numbers in a region by a multiplier?

At Thu, 1 Jul 2010 13:55:11 +0000 (UTC),
Seweryn Kokot wrote:
> 
> Hi,
> 
> I would like to modify numbers in a region/buffer by a given multiplier.
> 
> Imagine that I have some numbers
> 
> 33.444 3333 4433.4443 3344 .34234
> 
> and I want them multiplied for example by 0.1
> 
> to receive
> 
> 3.3444 333.3 443.34443 334.4 .034234
> 
> I tried with this function I wrote, but it doesn't work properly.
> Any idea why?
> 
> (defun my-multiply-numbers-in-region-or-buffer (multiplier)
>   (interactive "nGive multiplier: ")
>   (let (beg end object)
> 	(if (use-region-p)
>         (progn
>           (setq object "region")
>           (setq beg (region-beginning))
>           (setq end (region-end)))
>       (setq object "buffer")
>       (setq beg (point-min))
(Continue reading)

Seweryn Kokot | 1 Jul 22:10 2010
Picon

Re: How modify numbers in a region by a multiplier?

Indeed, your regexp used with my function works too. So as you wrote, for my
purpose it's more than enough :-)

Juanma Barranquero | 1 Jul 22:16 2010
Picon

Re: How modify numbers in a region by a multiplier?

On Thu, Jul 1, 2010 at 22:10, Seweryn Kokot <sewkokot <at> gmail.com> wrote:

> Indeed, your regexp used with my function works too. So as you wrote, for my
> purpose it's more than enough :-)

Qiang Guo is right, though, in pointing that you're using a fixed
`end' but the buffer or region length is potentially changing with
every replace.

    Juanma

Seweryn Kokot | 1 Jul 22:16 2010
Picon

Re: How modify numbers in a region by a multiplier?

Dan Davison <davison <at> stats.ox.ac.uk> writes:

> Here are three solutions using Org-mode.
> 
> * Using the Org spreadsheet
> http://orgmode.org/org.html#The-spreadsheet
> http://orgmode.org/worg/org-tutorials/org-spreadsheet-intro.php
> 
> Leave second column blank; issue C-u C-c C-c with point in the table 
> 
> |    33.444 |    3.3444 |
> |      3333 |     333.3 |
> | 4433.4443 | 443.34443 |
> |      3344 |     334.4 |
> |   0.34234 |  0.034234 |
> #+tblfm: $2=$1*0.1
> 
> * Using Org-babel...
> ** Using emacs lisp...
> ** Using R...

Thank you for help, however my purpose writing this function was to make it more
easy to type many tedious floating point numbers. So I thought it would be
better to write integers and then multiply them by 0.001 or whatever. In this
way I could never type "." in numbers and after the work done just use this
function to do it for me.


Gmane