[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SOVLED: help with wrong-number-of-arguments
From: |
hw |
Subject: |
SOVLED: help with wrong-number-of-arguments |
Date: |
Tue, 26 Sep 2023 18:14:17 +0200 |
User-agent: |
Evolution 3.48.4 (3.48.4-1.fc38) |
On Tue, 2023-09-26 at 16:11 +0200, Stephen Berman wrote:
> On Tue, 26 Sep 2023 15:40:08 +0200 hw <hw@adminart.net> wrote:
>
> > Hi,
> >
> > I created the function at [1] a while ago and bound it to C-x t i, and
> > it has been working fine. Now when I press C-x t i, I'm getting
> >
> >
> > Debugger entered--Lisp error: (wrong-number-of-arguments #<subr
> > my-perltidy-replace> 1)
> > my-perltidy-replace(nil)
> > funcall-interactively(my-perltidy-replace nil)
> > command-execute(my-perltidy-replace)
> >
> >
> > What might have changed is the emacs version because I built one that
> > uses wayland, but I don't remember if it used to work with the wayland
> > version.
> >
> > I'm guessing that emacs now figures that the function is getting an
> > argument where it doesn't take one, and I fail to make sense of
> > this. How can I fix this?
>
> Change the line `(interactive "P")' to `(interactive")'. I don't see
> how it could have worked before, since `(interactive "P")' means the
> command can be called with a raw prefix argument, so it would have to be
> defined e.g. like this: (defun my-perltidy-replace (&optional arg)...
Thank you very much, it works now :)
>
> Steve Berman
>
> >
> >
> > [1]:
> >
> >
> > (defun my-perltidy-replace ()
> > "This function replaces the contents of the current buffer with
> > the output of perltidy, and makes a backup of the current buffer.
> > The backup is then saved."
> > (interactive "P")
> > (let ((tidy_buffer (generate-new-buffer (generate-new-buffer-name (concat
> > "TidyBackup-" (buffer-name))))))
> > (with-current-buffer (buffer-name)
> > (shell-command-on-region (point-min) (point-max) "perltidy
> > --standard-output" tidy_buffer)
> > (buffer-swap-text tidy_buffer))
> > (with-current-buffer tidy_buffer
> > (let ((visiting_file (generate-new-buffer-name (concat
> > "~/tmp/TidyBackup/" (buffer-name)))))
> > (set-visited-file-name visiting_file)
> > (save-buffer)
> > (message "backup saved as %s" visiting_file)))))
>