unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: seberino@spawar.navy.mil (Christian Seberino)
Subject: Re: How run a command JUST on region highlighted by MOUSE?!?!
Date: 2 Sep 2003 17:16:06 -0700	[thread overview]
Message-ID: <bf23f78f.0309021616.754e8bf5@posting.google.com> (raw)
In-Reply-To: 3F4FC986.4060602@yahoo.com

Kevin

Thanks for your help.  I finally got a version that works!

  (defun cs-py-comment-region(beg end) (interactive "r")
    (save-restriction
      (narrow-to-region beg end)
      (py-comment-region beg end)
      (delete-trailing-whitespace)))
 

What does the (interactive "r") do??? I really ONLY ever invoke my
functions
with key-combos that are hard wired to start the functions....e.g.
C-ac, C-z, etc....
Does this mean I can omit all this (interactive ..) stuff from .emacs
everywhere???

It appears that beg and end got automagically set when I dragged mouse
over some region.

It also appears that although py-comment-region did not need it's 2
args
without narrow-to-region part... it does now when I add the
narrow-to-region
part and that was the main bug.

Thank goodness it works but there is a lot going on I don't understand
here
about how arguments get defined and (interactive..) function.  Any
help would
be greatly appreciated.

Sincerely,

Chris

Kevin Rodgers <ihs_4664@yahoo.com> wrote in message news:<3F4FC986.4060602@yahoo.com>...
> Christian Seberino wrote:
> 
> > I set .emacs up to run this function when I highlight a region with
> > mouse
> > and type C-ac.....
> > 
> >  (defun cs-py-comment-region() (interactive)
> >       (narrow-to-region)
> >       (py-comment-region)
> >       (delete-trailing-whitespace)
> >       (widen))
> > 
> > I'm getting this error message...
> > 
> > cs-py-comment-region: Wrong number of arguments: #<subr narrow-to-region>, 0
> > (New file)
> > Mark set
> > cs-py-comment-region: Wrong number of arguments: #<subr narrow-to-region>, 0
> > 
> > I read Emacs LISP reference manual on narrow-to-region and it said..
> > 
> > Command: narrow-to-region start end
> >     This function sets the accessible portion of the current buffer to
> > start at start and end at end. Both arguments should be character
> > positions.
> > 
> >     In an interactive call, start and end are set to the bounds of the
> > current region (point and the mark, with the smallest first).
> > 
> > 
> > I assume "interactive call" = "highlighted a region with mouse"??
> > 
> > It seems narrow-to-region should get the start and end point values
> > automatically??!
> 
> It does when you call it interactively.  When you call it programmatically,
> you need to specify the START and END arguments: (region-beginning) and
> (region-end), respectively.
> 
> Your cs-py-comment-region function should take 2 arguments, provide a
> way for them to be specified when it's called interactively, and pass
> the region bounds to py-comment-region:
> 
> (defun cs-py-comment-region (beg end)
>    (interactive "r")
>    (py-comment-region beg end)
>    ...)

  reply	other threads:[~2003-09-03  0:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-28 21:24 How run a command JUST on region highlighted by MOUSE?!?! Christian Seberino
2003-08-28 21:32 ` Andrew Taylor
2003-08-29 18:22   ` Christian Seberino
2003-08-29 18:34     ` Oliver Scholz
2003-09-03  0:03       ` Christian Seberino
2003-09-03  0:19       ` Christian Seberino
2003-08-29 18:56     ` Johan Bockgård
2003-08-29 21:45     ` Kevin Rodgers
2003-09-03  0:16       ` Christian Seberino [this message]
2003-09-03 22:04         ` Jeffery B. Rancier
2003-09-03 23:13         ` Kevin Rodgers

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=bf23f78f.0309021616.754e8bf5@posting.google.com \
    --to=seberino@spawar.navy.mil \
    /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).