1
votes

I don't use dired mode too often, but was trying to practice with it a bit. So I created a few empty practice text files and marked them with the usual dired shortcut key. Then I tried to rename the files using the "R" command--in order to move the files to a new folder. I get this odd error and the operation does not succeed.

apply: Wrong number of arguments: (8 . 8), 10 [3 times]

I ran into the same error when I tried to do a copy using the "C" command. But interestingly enough, the problem does not occur when I tried to do a delete with "D". Delete did work. So it seems like somewhere the apply function is being used incorrectly.

I am using emacs version 25.3 and Spacemacs version 0.200.13.x on ubuntu linux 16.04 LTS.

Does anyone have a sense of why this error is occurring? Since dired is part of the emacs core, I imagine there might be some conflict with a different package or something. I checked the spacemacs github repo issues list, but did not see any problems mentioned. Any help would be appreciated.

UPDATED

As per Phil's suggestion, here is the stacktrace:

Debugger entered--Lisp error: (wrong-number-of-arguments (8 . 8) 10)
  helm-read-file-name-handler-1("Rename jarrett-iccv-09.pdf to: " read-file-name-internal file-exists-p nil "~/Downloads/" file-name-history nil nil "dired-do-rename" "*helm-mode-dired-do-rename*")
  apply(helm-read-file-name-handler-1 ("Rename jarrett-iccv-09.pdf to: " read-file-name-internal file-exists-p nil "~/Downloads/" file-name-history nil nil "dired-do-rename" "*helm-mode-dired-do-rename*"))
  helm--completing-read-default("Rename jarrett-iccv-09.pdf to: " read-file-name-internal file-exists-p nil "~/Downloads/" file-name-history nil nil)
  apply(helm--completing-read-default ("Rename jarrett-iccv-09.pdf to: " read-file-name-internal file-exists-p nil "~/Downloads/" file-name-history nil nil))
  #f(advice-wrapper :override completing-read-default helm--completing-read-default)("Rename jarrett-iccv-09.pdf to: " read-file-name-internal file-exists-p nil "~/Downloads/" file-name-history nil nil)
  completing-read("Rename jarrett-iccv-09.pdf to: " read-file-name-internal file-exists-p nil "~/Downloads/" file-name-history nil)
  read-file-name-default("Rename jarrett-iccv-09.pdf to: " "/home/krishnab/Downloads/" nil nil nil nil)
  read-file-name("Rename jarrett-iccv-09.pdf to: " "/home/krishnab/Downloads/" nil nil nil nil)
  ido-read-file-name("Rename jarrett-iccv-09.pdf to: " "/home/krishnab/Downloads/" nil nil nil nil)
  apply(ido-read-file-name ("Rename jarrett-iccv-09.pdf to: " "/home/krishnab/Downloads/" nil nil nil nil))
  #f(advice-wrapper :override #f(advice-wrapper :override read-file-name-default helm--generic-read-file-name) ido-read-file-name)("Rename jarrett-iccv-09.pdf to: " "/home/krishnab/Downloads/" nil nil nil nil)
  read-file-name("Rename jarrett-iccv-09.pdf to: " "/home/krishnab/Downloads/" nil)
  apply(read-file-name ("Rename jarrett-iccv-09.pdf to: " "/home/krishnab/Downloads/" nil))
  dired-mark-pop-up(nil move ("jarrett-iccv-09.pdf") read-file-name "Rename jarrett-iccv-09.pdf to: " "/home/krishnab/Downloads/" nil)
  dired-mark-read-file-name("Rename %s to: " "/home/krishnab/Downloads/" move nil ("jarrett-iccv-09.pdf") nil)
  dired-do-create-files(move dired-rename-file "Move" nil t "Rename")
  dired-do-rename(nil)
  funcall-interactively(dired-do-rename nil)
  call-interactively(dired-do-rename nil nil)
  command-execute(dired-do-rename)

UPDATED 2

There does seem to be a similar issue reported under the helm github repository. Seems that helm and ido mode are not compatible.

https://github.com/emacs-helm/helm/issues/1819

There is also a reference to this in the helm wiki.

https://github.com/emacs-helm/helm/wiki#use-helm-mode-and-ido-mode

I tried some of their suggestions, like adding

'(helm-completing-read-handlers-alist
   (quote
    ((find-file-read-only . ido)
     (find-alternate-file . nil))

But still getting the same error.

1
Can you replicate the problem when running emacs -Q ?phils
What @phils said. If not, bisect your init file to find the culprit.Drew
@phils I checked and when I used emacs -Q and then dired works correctly. The tricky thing is that I am using Spacemacs, so I am not seeing any strange errors in the Messages buffer. I also checked the help on the dired-do-rename function and it seems to reference the regular dired package. I thought that if it was overridden then I would see the name of the overriding package. Hmm, not sure where to look next?krishnab
Assuming M-x toggle-debug-on-error gives you a stack trace when the error occurs, paste that into the question. Does C-h k R in dired confirm that dired-do-rename is actually what is being called? If so, does the help say that there is any advice defined for that function? (If so, what does it tell you about it?)phils
@phils I did as you suggested. I did not know about that particular option. Thanks for the tip. I triggered the error on trying to rename(move) a pdf file called jarrett-XXX.pdf.krishnab

1 Answers

2
votes

At first glance, this looks to me like a bug in the current version of helm.

Installing helm from MELPA, I see that helm-read-file-name-handler-1 accepts 8 arguments:

(helm-read-file-name-handler-1 PROMPT DIR DEFAULT-FILENAME MUSTMATCH INITIAL PREDICATE NAME BUFFER)

While helm--completing-read-default is guaranteed to call it with 10, as per the stack trace.

helm--completing-read-default looks up dired-do-rename in helm-completing-read-handlers-alist and finds that it is mapped to helm-read-file-name-handler-1. It then recognises the handler as being name-spaced as a helm function and, on that basis, calls it with 2 additional helm-specific arguments.

By default, helm-completing-read-handlers-alist includes:

(dired-do-rename . helm-read-file-name-handler-1)
(dired-do-copy . helm-read-file-name-handler-1)
(dired-do-symlink . helm-read-file-name-handler-1)
(dired-do-relsymlink . helm-read-file-name-handler-1)
(dired-do-hardlink . helm-read-file-name-handler-1))

So this issue affects all of those dired commands.

You could presuambly work around this by removing all of those.

e.g. M-x customize-option RET helm-completing-read-handlers-alist