Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Help defining a macro
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
  3 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
 
Fred Krogh  
View profile  
 More options Jul 9 2012, 10:03 am
Newsgroups: comp.emacs
From: Fred Krogh <fkr...@mathalacarte.com>
Date: Mon, 09 Jul 2012 07:03:54 -0700
Local: Mon, Jul 9 2012 10:03 am
Subject: Help defining a macro
I'm tired of typing: <alt cntrl s>\Wxy\W
to search for a variable with name xy, where xy is some input.
I'd like a macro set up so I could type <cntrl c><cntrl s>xy<enter>
to do this.  Better still if after doing this <cntrl>s would do the same
search.  A similar macro starting with <cntrl c><cntrl r>xy<enter> to do
the same search backward would also be nice, but instructions to do the
first should enable me to do that.
Thanks for any help.

 
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.
Pascal J. Bourguignon  
View profile  
 More options Jul 9 2012, 10:33 am
Newsgroups: comp.emacs
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Mon, 09 Jul 2012 16:33:36 +0200
Local: Mon, Jul 9 2012 10:33 am
Subject: Re: Help defining a macro

Fred Krogh <fkr...@mathalacarte.com> writes:
> I'm tired of typing: <alt cntrl s>\Wxy\W

You need to read the tutorial.  Type C-h t.
ie. it's not <cntrl h> t, it's C-h t.

> to search for a variable with name xy, where xy is some input.
> I'd like a macro set up so I could type <cntrl c><cntrl s>xy<enter>
> to do this.  Better still if after doing this <cntrl>s would do the
> same search.  A similar macro starting with <cntrl c><cntrl
> r>xy<enter> to do the same search backward would also be nice, but
> instructions to do the first should enable me to do that.
> Thanks for any help.

This cannot be done with a macro.  (Neither with a keyboard macro or an
elisp macro).  You have to write a command instead.

Now that you know the correct term, you can read emacs manuals and
learn about it.

    An Introduction to Programming in Emacs Lisp
    http://www.gnu.org/software/emacs/emacs-lisp-intro/  or  M-: (info "(eintr)Top") RET
    (for non-programmers)

    Emacs Lisp Manual
    http://www.gnu.org/software/emacs/manual/elisp.html  or  M-: (info "(elisp)Top") RET

    Emacs Manual
    http://www.gnu.org/software/emacs/manual/   or  M-: (info "(emacs)Top") RET

Something like:

(defun fred-search-variable (name)
  (interactive "sVariable name:")
  (search-forward-regexp (format "\\W%s\\W" name)))

(local-set-key (kbd "C-c C-s") ; notice how it's not "<cntrl c>"?
               'fred-search-variable)

--
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


 
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.
Fred Krogh  
View profile  
 More options Jul 9 2012, 11:34 am
Newsgroups: comp.emacs
From: Fred Krogh <fkr...@mathalacarte.com>
Date: Mon, 09 Jul 2012 08:34:56 -0700
Local: Mon, Jul 9 2012 11:34 am
Subject: Re: Help defining a macro
On 07/09/2012 07:33 AM, Pascal J. Bourguignon wrote:

> Something like:

> (defun fred-search-variable (name)
>    (interactive "sVariable name:")
>    (search-forward-regexp (format "\\W%s\\W" name)))

> (local-set-key (kbd "C-c C-s") ; notice how it's not "<cntrl c>"?
>                 'fred-search-variable)

Thanks, this was very helpful.  But then I discovered <alt s>w which
does most of what I want, since it lets me continue a search easily.

 
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 »