Mohsen Owzar | 6 Jul 2006 09:12
Picon

Question about writing a macro in XEMACS


Dear all,

I do not know if I'm writing this question to the correct address or not?
If not please let me know to where I have to write next time, if I have
questions belonging to XEMACS, because I'm new in this group.

And now my question:
I use often the macro feature in XEMACS. If I want to do some actions with
some replacements (e.g. "abc" with "cde") in a text file, I do it once and
save it in a macro and rerun it by using the "excecute-last-kbd-macro" line
by line through the whole file.
If the replacements are always the same, my macro works fine. But if I
want to replace the sting "abc" with "cde1", "cde2", "cde3" ..., which means
that each time the replacement is increased by a certain value, in this case
one, how can I write my macro to achieve this replacement by using the command
"excecute-last-kbd-macro"?

Best regards
Mohsen Owzar

matthew.miner | 7 Jul 2006 17:35
Favicon

Re: Question about writing a macro in XEMACS

Try something like this (I recorded it from emacs, but should be same).

Command: last-kbd-macro
Key: none

Macro:

C-s               ;; isearch-forward
abc               ;; self-insert-command * 3
RET               ;; newline
3*DEL             ;; c-electric-backspace
cde               ;; self-insert-command * 3
C-x r i                 ;; insert-register
q                 ;; self-insert-command
C-x r +                 ;; increment-register
q                 ;; self-insert-command

I also set F4 to last keyboard macro (I exec macros way too often for the
default c-x,e to be a good choice).
In the example above, I used "register q" as the number register.

You have to init register q, such as to zero. You can use: `C-x r n q'.

abc abc abc
changes to
cde1 cde2 cde3

                                                                           
             Mohsen Owzar                                                  
             <mohsen.owzar <at> phi                                             
             lips.com>                                                  To 
             Sent by:                  xemacs-news <at> xemacs.org              
             xemacs-news-bounc                                          cc 
             es <at> xemacs.org                                                 
                                                                   Subject 
                                       Question about writing a macro in   
             07/07/2006 09:24          XEMACS                              
             AM                                                            

Dear all,

I do not know if I'm writing this question to the correct address or not?
If not please let me know to where I have to write next time, if I have
questions belonging to XEMACS, because I'm new in this group.

And now my question:
I use often the macro feature in XEMACS. If I want to do some actions with
some replacements (e.g. "abc" with "cde") in a text file, I do it once and
save it in a macro and rerun it by using the "excecute-last-kbd-macro" line

by line through the whole file.
If the replacements are always the same, my macro works fine. But if I
want to replace the sting "abc" with "cde1", "cde2", "cde3" ..., which
means
that each time the replacement is increased by a certain value, in this
case
one, how can I write my macro to achieve this replacement by using the
command
"excecute-last-kbd-macro"?

Best regards
Mohsen Owzar

===================================
Mohsen Owzar
Design Engineer
Business Line Cordless & MultiMedia

Philips AG, Binzstrasse 44
CH-8045 Zürich
TEL: +41 44 465 12 68
FAX: +41 44 465 18 05
E-mail: mohsen.owzar <at> philips.com

Stephen J. Turnbull | 7 Jul 2006 17:26
Picon
Favicon

Re: Question about writing a macro in XEMACS

>>>>> "Mohsen" == Mohsen Owzar <mohsen.owzar <at> philips.com> writes:

    Mohsen> If not please let me know to where I have to write next
    Mohsen> time, if I have questions belonging to XEMACS, because I'm
    Mohsen> new in this group.

xemacs-news is going to be decommissioned in a few days; you should
post directly to the comp.emacs.xemacs newsgroup.  You can access it
through Google Groups, etc, if you don't have a news feed.

    Mohsen> each time the replacement is increased by a certain value,
    Mohsen> in this case one, how can I write my macro to achieve this
    Mohsen> replacement by using the command
    Mohsen> "excecute-last-kbd-macro"?

Currently, you can't.  It's possible to query the user, by using C-x q
while recording.  Then the user would enter the correct number.
However, to increment and insert automatically, you must write Lisp
code.

I believe GNU Emacs has a feature for doing this kind of thing (at
least they discussed it) but it hasn't been ported to XEmacs yet.

--

-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.


Gmane