[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help with wrong-number-of-arguments
From: |
Stephen Berman |
Subject: |
Re: help with wrong-number-of-arguments |
Date: |
Tue, 26 Sep 2023 16:11:09 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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)...
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)))))