unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Alex Kost <alezost@gmail.com>
To: Renato Pontefice <renato.pontefice@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: how to automate a code
Date: Mon, 15 Sep 2014 18:50:05 +0400	[thread overview]
Message-ID: <87vbop3plu.fsf@gmail.com> (raw)
In-Reply-To: <e47cf35c-d158-4cdc-b504-6c131d8a6eb2@googlegroups.com> (Renato Pontefice's message of "Mon, 15 Sep 2014 03:50:35 -0700 (PDT)")

Renato Pontefice (2014-09-15 14:50 +0400) wrote:

> Hi,
> it's still me... with same question:
>
> How can I automate this elisp code, that works, if I paste on emacs
> ___________________________________________________________________
> (while (and (not (eobp))
>             (search-forward "[-" nil 'move))
>   (skip-chars-forward "A-Z")
>   (unless (looking-at "-]")
>     (message "Problem found, please fix and hit C-M-c to continue")
>     (recursive-edit)))
> ________________________________________________________________
>
> I'm sorry, but I lost my self on the previous thread :-( (my english is not so good :-( )
>
> All I need, is to run this code when I press a button (or better a key, keybind...)
>
> Can someone tell me how to do that?

1. You can define an interactive function:

(defun my-working-code ()
  "Some really useful thing."
  (interactive)
  (while (and (not (eobp))
              (search-forward "[-" nil 'move))
    (skip-chars-forward "A-Z")
    (unless (looking-at "-]")
      (message "Problem found, please fix and hit C-M-c to continue")
      (recursive-edit))))

2. And bind it to any key you want:

(global-set-key (kbd "C-S-z") 'my-working-code)

Hint: string in the (kbd ...) is the same as you see after pressing
"C-h c ..."




  reply	other threads:[~2014-09-15 14:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15 10:50 how to automate a code Renato Pontefice
2014-09-15 14:50 ` Alex Kost [this message]
     [not found] ` <mailman.8916.1410792630.1147.help-gnu-emacs@gnu.org>
2014-09-16  7:55   ` Renato Pontefice

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vbop3plu.fsf@gmail.com \
    --to=alezost@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=renato.pontefice@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).