help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How run a command JUST on region highlighted by MOUSE?!?!


From: Kevin Rodgers
Subject: Re: How run a command JUST on region highlighted by MOUSE?!?!
Date: Fri, 29 Aug 2003 15:45:42 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

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)
  ...)

--
Kevin Rodgers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]