Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
keyboard macro question
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Benjamin  
View profile  
 More options Oct 2, 10:05 am
Newsgroups: gnu.emacs.help
From: Benjamin <jben...@gmail.com>
Date: Fri, 2 Oct 2009 07:05:40 -0700 (PDT)
Local: Fri, Oct 2 2009 10:05 am
Subject: keyboard macro question
I use keyboard macros fairly frequently, but I often run into a
situation where I would like to increment a number in the macro, e.g.,
if I start with:

tmp tmp tmp tmp

and I want to end with:
tmp1
tmp2
tmp3
tmp4

I know how to create the macro where it would result in:
tmp1
tmp1
tmp1
tmp1

Is there a way to make the number increment each time the macro is
executed?
Otherwise I am forced to step down through each line and manually put
the numbers in 1, 2, 3, 4, ...
Naturally this is a greatly shortened example for illustration
purposes, and often the incrementing takes place within a longer
statement e.g.,  tmp(:,1) = function(x,y).  My interest here is how to
increment or decrement the number in a more automatic fashion.

I don't mind doing something other than macros, or even external
commands (perl/sed/awk, etc.)
to assist with this.

Thanks,
-Ben


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joost Kremers  
View profile  
 More options Oct 2, 10:15 am
Newsgroups: gnu.emacs.help
From: Joost Kremers <joostkrem...@yahoo.com>
Date: 2 Oct 2009 14:15:20 GMT
Local: Fri, Oct 2 2009 10:15 am
Subject: Re: keyboard macro question

Benjamin wrote:
> I use keyboard macros fairly frequently, but I often run into a
> situation where I would like to increment a number in the macro, e.g.,

you might start by checking out the documentation on keyboard macros:

(info "(emacs) Keyboard Macros")

--
Joost Kremers                                      joostkrem...@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Kastrup  
View profile  
 More options Oct 2, 10:34 am
Newsgroups: gnu.emacs.help
From: David Kastrup <d...@gnu.org>
Date: Fri, 02 Oct 2009 16:34:28 +0200
Local: Fri, Oct 2 2009 10:34 am
Subject: Re: keyboard macro question

C-M-% tmp SPC RET tmp\,(1+ \#) C-q C-j RET

--
David Kastrup


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin S. Miller  
View profile  
 More options Oct 2, 10:50 am
Newsgroups: gnu.emacs.help
From: "Colin S. Miller" <no-spam-thank-...@csmiller.demon.co.uk>
Date: Fri, 02 Oct 2009 15:50:23 +0100
Local: Fri, Oct 2 2009 10:50 am
Subject: Re: keyboard macro question

Benjamin wrote:
> I use keyboard macros fairly frequently, but I often run into a
> situation where I would like to increment a number in the macro, e.g.,
> if I start with:

> tmp tmp tmp tmp

> and I want to end with:
> tmp1
> tmp2
> tmp3
> tmp4

Benjamin,
These functions are useful for this situation
C-u 1 C-x r n a   (number-to-register a)
C-x r i a         (insert-register a)
C-x r + a         (increment-register a)

HTH,
Colin S. Miller


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jbenjam  
View profile  
 More options Oct 2, 10:54 am
Newsgroups: gnu.emacs.help
From: jbenjam <jben...@gmail.com>
Date: Fri, 2 Oct 2009 07:54:25 -0700 (PDT)
Local: Fri, Oct 2 2009 10:54 am
Subject: Re: keyboard macro question
On Oct 2, 10:34 am, David Kastrup <d...@gnu.org> wrote:

> C-M-% tmp SPC RET tmp\,(1+ \#) C-q C-j RET

Thanks David, I knew it was something relatively simple.

Happy Friday,
-Ben


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Harry Putnam  
View profile  
 More options Oct 2, 2:12 pm
Newsgroups: gnu.emacs.help
From: Harry Putnam <rea...@newsguy.com>
Date: Fri, 02 Oct 2009 13:12:29 -0500
Local: Fri, Oct 2 2009 2:12 pm
Subject: Re: keyboard macro question
"Colin S. Miller" <no-spam-thank-...@csmiller.demon.co.uk> writes:

> Benjamin,
> These functions are useful for this situation
> C-u 1 C-x r n a   (number-to-register a)
> C-x r i a         (insert-register a)
> C-x r + a         (increment-register a)

I wondered if you could show an example of how this works in a
macro... when I try, it just continues to insert 1.

To reproduce:
Create macro of:
 C-u 1 C-x r n a
 C-x r i a
 C-x r + a

then walk down this column inserting the macro

str
str
str
str

By running the macro at the end of each line, I get:

str1
str1
str1
str1


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tassilo Horn  
View profile  
 More options Oct 2, 4:15 pm
Newsgroups: gnu.emacs.help
From: Tassilo Horn <tass...@member.fsf.org>
Date: Fri, 02 Oct 2009 22:15:26 +0200
Local: Fri, Oct 2 2009 4:15 pm
Subject: Re: keyboard macro question

Harry Putnam <rea...@newsguy.com> writes:

Hi Harry,

> To reproduce:
> Create macro of:
>  C-u 1 C-x r n a
>  C-x r i a
>  C-x r + a

The first part (setting register a to 1) must not be part of the macro,
but must be done beforehand.  Else, each time the macro executes,
register a will be set to 1, then you insert the 1, and then you
increment it to 2.

So here's how to do it:

  C-u 1 C-x r n a    ;; Set register a to 1
  F3                 ;; Start definition of a macro
  C-x r i a          ;; insert value of register a
  C-x r + a          ;; Increment register a
  F4                 ;; End macro definition

Then any additional F4 will insert 2, 3, 4, 5, 6, ...

Bye,
Tassilo


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Xah Lee  
View profile  
 More options Oct 2, 6:20 pm
Newsgroups: gnu.emacs.help, comp.emacs
From: Xah Lee <xah...@gmail.com>
Date: Fri, 2 Oct 2009 15:20:05 -0700 (PDT)
Local: Fri, Oct 2 2009 6:20 pm
Subject: Re: keyboard macro question
On Oct 2, 7:05 am, Benjamin <jben...@gmail.com> wrote:

This is a frequently asked question in emacs communities.

Different people has different solution. For me, i wrote a function to
do it. I documented it in this page:

• Emacs Lisp Examples
  http://xahlee.org/emacs/elisp_examples.html

The following is excerpt:
------------------------------------
Sometimes, you need to insert a vertical column of sequential integers
into a block of text, like this:

do this x times
do this x times
do this x times
...

where the “x” should be 1, 2, 3, ... The following code does it.

(defun insert-counter-column (n)
  "Insert a sequence of integers vertically.
Example:
do this 1 times
do this 2 times
do this 3 times
...

If there are not enough existing lines after the cursor
when this function is called, it aborts at the last line.

See also: `kill-rectangle' and `string-rectangle'."
  (interactive "nEnter the max integer: ")
  (let ((i 1) colpos)
    (setq colpos (- (point) (point-at-bol)))
    (while (<= i n)
      (insert (number-to-string i))
      (next-line) (beginning-of-line) (forward-char colpos)
      (setq i (1+ i))
      )))

--------------------------------------------------

Note: if you are a perl programer (or python, ruby, etc), you can
easily write a function in your lang and have a emacs wrapper calling
it. So that, you select you text, press a hotkey, and emacs call your
script, feed it the current selection, and return the output replacing
the current text selection.

This might be easier for many people.

• Elisp Wrapper For Perl Scripts
  http://xahlee.org/emacs/elisp_perl_wrapper.html

  Xah
http://xahlee.org/



    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric  
View profile  
 More options Oct 2, 10:04 pm
Newsgroups: gnu.emacs.help
From: Eric <gir...@gmail.com>
Date: Fri, 2 Oct 2009 19:04:06 -0700 (PDT)
Local: Fri, Oct 2 2009 10:04 pm
Subject: Re: keyboard macro question
On Oct 2, 10:05 pm, Benjamin <jben...@gmail.com> wrote:

> I use keyboard macros fairly frequently, but I often run into a
> situation where I would like to increment a number in the macro, e.g.,
> if I start with:

Keyboard Macro Counters! That's what they're there for:

http://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Mac...

Eric


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Combs  
View profile  
 More options Oct 17, 9:46 pm
Newsgroups: gnu.emacs.help, comp.emacs
From: dkco...@panix.com (David Combs)
Date: Sun, 18 Oct 2009 01:46:00 +0000 (UTC)
Subject: Re: keyboard macro question
In article <d9407676-bb83-46a4-9804-0450cc190...@v37g2000prg.googlegroups.com>,
Xah Lee  <xah...@gmail.com> wrote:

Please -- I know you love your nice control-chars your posts
always include, but it sure makes it near IMPOSSIBLE for us
to read, or especially to NICELY save, them.

Suggestion:

Each post you make, DOUBLE it: first part "your way", then
a dashed line or lines, then again, but without that stuff
in it.  Just plain ascii, minus any within-line control-chars.

(Presumably you take the trouble to write your posts, to think
them through, etc, because you want us to READ them, to BENEFIT
from them, perhaps to even SAVE them.  Seems to me that it would
thus be to YOUR benefit to make them as easy as possible to read,
and likewise to save away, maybe even for OTHERS to read (attributed
to you, of course).)

Thanks for at least considering the above.

David


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Xah Lee  
View profile  
 More options Oct 18, 1:40 pm
Newsgroups: gnu.emacs.help, comp.emacs
From: Xah Lee <xah...@gmail.com>
Date: Sun, 18 Oct 2009 10:40:36 -0700 (PDT)
Local: Sun, Oct 18 2009 1:40 pm
Subject: Re: keyboard macro question
On Oct 17, 6:46 pm, dkco...@panix.com (David Combs) wrote:

Hi David,

was it you who wrote me at least twice about this issue in the past in
separate times?

If i didn't recall incorrectly, i never got any reasons what is the
problem.

The "control chars" you mention, are unicode characters, and pretty
standard ones, such as curly quotes and bullets.

I wrote all my posts using just emacs, and they show correctly in just
about all web browsers from groups.google.com. There is no problem in
copy and pasting them, nor can i imagine there any problem in saving
them as file, in any of Windows, Mac, or linux. the encoding used is
utf-8, default in mac, linuxes, and fully supported Windows.

unicode is charset in langs like xml, java... etc.

can you be explicit exactly what is the problem? is it some news
reader that does not support unicode? i haven't tried, but it'd be a
major shame if u telling me emacs+gnus or Mozilla's Thunderbird does
not support unicode out of the box?

  Xah
http://xahlee.org/



    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Combs  
View profile  
 More options Nov 11, 10:12 pm
Newsgroups: gnu.emacs.help, comp.emacs
From: dkco...@panix.com (David Combs)
Date: Thu, 12 Nov 2009 03:12:48 +0000 (UTC)
Local: Wed, Nov 11 2009 10:12 pm
Subject: Re: keyboard macro question
In article <cd68dc3d-ccfa-48a0-bbac-8bc923e38...@u16g2000pru.googlegroups.com>,
Xah Lee  <xah...@gmail.com> wrote:

You're writing for a web-browser?

I don't use a web-browser for newsgroups -- I use "trn4".

And with that, your unicode orwhatever looks pretty bad,
unreadable in some cases.

How about  writing for just  plain old ascii terminals, eg
adm3a or vt-100 --  isn't that the working assumption for
newsgroup text?

David


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lars Enderin  
View profile  
 More options Nov 13, 1:36 pm
Newsgroups: gnu.emacs.help, comp.emacs
From: Lars Enderin <lars.ende...@gmail.com>
Date: Fri, 13 Nov 2009 19:36:01 +0100
Local: Fri, Nov 13 2009 1:36 pm
Subject: Re: keyboard macro question

David Combs wrote:

> You're writing for a web-browser?

Thunderbird is a mail and news client, not a browser, although it can
show HTML-formatted messages.

> I don't use a web-browser for newsgroups -- I use "trn4".

You should upgrade, or accept being left behind,

> And with that, your unicode orwhatever looks pretty bad,
> unreadable in some cases.

Unicode is not necessary in Usenet posts, I'll give you that, but I hope
that you won't insist on 7-bit us-ascii text. That is too US-parochial.
I use ISO-8859-1 (ISO Latin 1) because I need it for my Swedish alphabet
  (a-z plus åäö, mostly), but Thunderbird is capable of showing Unicode
if necessary. Most modern Linuxes, e g Ubuntu, use UTF-8 by default, by
the way.

> How about  writing for just  plain old ascii terminals, eg
> adm3a or vt-100 --  isn't that the working assumption for
> newsgroup text?

That is too limiting.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google