[comp.emacs] Thanks ...but the `fix' does not work

katz@VENERA.ISI.EDU (02/03/90)

OK, you will probably get tons of responses, but apart from using 
the 'high level' commands in a lisp program (which you should not
do), the problems with even getting your function to run are:

	1.  The extra parenthesis.  Just because you get a wierd error
	    message you don't understand without it doesn't mean
	    putting it in is correct!!

	2.  you did not give set-mark-command the correct number
	    of arguments (ie 1 of them).  Here is the source:

	(defun set-mark-command (arg)
	  "Set mark at where point is, or jump to mark.
	With no prefix argument, set mark, and push previous mark on mark ring.
	With argument, jump to mark, and pop into mark off the mark ring.
	Novice emacs-lisp programmers often try to use the mark for the wrong
	purposes.  See the documentation of `set-mark' for more information."
	  (interactive "P")
	  (if (null arg)
	      (push-mark)
	    (if (null (mark))
		(error "No mark set in this buffer")
	      (goto-char (mark))
	      (pop-mark))))

	Notice that it takes one argument, ARG.  Used interactively,
	it gets this by examining the prefix arg, but if called from
	a lisp program (WHICH YOU SHOULD NOT DO ANYWAY!) it needs
	an argument.  (As an aside, the program checks to see if
	ARG is nil, so if the declaration said:
		set-mark-command (&optional arg)
	it would have worked.)  Since you did not provide the correct
	number of arguments, when it got called, an error was signaled
	which appeared in the mini-buffer.


			Alan



	

worley@compass.UUCP (Dale Worley) (02/05/90)

   Recently I posted an article titled: What's wrong with my function?
   I received an enormous amount of email on the subject and I want to thank
   everyone who responded. The function I had problems with is:

   I was told by everyone who responded to me that the problem is I
   have too many parenthesis. The reason I put the extra set in is
   that with out it I get an error message that I don't understand.
   The error appears in the mini buffer and when I touch a key it is
   gone. Basically it says that I have too many parameters for lamda
   or somthing... The upshot is that removing the extra set of
   parenthesis does not work.

Well, to start out with, if you'd asked about the original problem,
you might have gotten it solved quicker.  Making a hack change and
then asking why *that* doesn't work doesn't solve the original
problem.

The error message you got tells you that something was called with the
wrong number of arguments.  Unfortunately, it doesn't tell you what.
You could, of course, check each of the seven functions you invoke,
but that would take a couple of minutes.

The solution is to use the Emacs debugger.  (See the topic Lisp
Debugger in Info.)  Set debug-on-error to t and then run your
function.  The debugger will tell you that you are calling
set-mark-command with the wrong number of arguments.  Checking the
documentation for set-mark-command doesn't tell you how many arguments
it has, but it tells you that you shouldn't be calling it.  However,
checking the code for set-mark-command (use find-tag) tells you that
it takes one argument.

Also, put your path at the end of your article -- many news feeds
(including mine) lose your path from the header.

Dale Worley		Compass, Inc.			worley@compass.com
--
Captain's Log, Star-date 6701.9:  After a major staff dispute, I have been
nailed to the hull.