1

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.

Community
  • 1
  • 1
krishnab
  • 9,270
  • 12
  • 66
  • 123
  • 1
    Can you replicate the problem when running `emacs -Q` ? – phils Aug 28 '18 at 13:08
  • What @phils said. If not, bisect your init file to find the culprit. – Drew Aug 28 '18 at 14:44
  • @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 Aug 28 '18 at 17:43
  • 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 Aug 28 '18 at 21:46
  • @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 Aug 28 '18 at 21:54
  • @phils I did confirm with `C-h k R` that the command being called is the `dired-do-rename`. I think the stacktrace above indicates that the correct command is being called. But it seems like the error is being triggered by the `helm-read-file-name-handler-1` and the `apply` function being called on that. Interesting. – krishnab Aug 28 '18 at 22:04

1 Answers1

2

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

phils
  • 71,335
  • 11
  • 153
  • 198
  • Assuming that all pans out, please do follow this up in the helm issue queue. If it doesn't quite mesh with an existing bug report, you should raise a new one. It seems to me that `helm-read-file-name-handler-1` needs to be modified if it's still intended to be used here. – phils Aug 28 '18 at 23:46
  • Oh man, this is really helpful. I will try this out and see if I can make it work. I already logged an issue with the Spacemacs folks, but I can also log a new issue with helm as well. I will try this and let you know how it goes. – krishnab Aug 28 '18 at 23:51
  • n.b. The combination with ido does indeed look to be the trigger -- I just tried it out myself, and by default helm uses `helm--generic-read-file-name` in this scenario (rather than `helm--completing-read-default`), and that function is only adding the 2 extra arguments to an initial set of 6 giving the correct total of 8, which is obviously how it's intended to work. As such, you may find nothing will be done about this, given https://www.reddit.com/r/emacs/comments/9a68sh/helm_development_in_bugfixonly_mode_for_now/ and https://github.com/emacs-helm/helm/issues/2083 – phils Aug 29 '18 at 01:24
  • you are right. I just saw that notification by the helm developer about stopping active development for a while. I was actually going to mention it to you, but you beat me to the punch. I suppose the best solution is to just remove those references in `helm-completing-read-handlers-alist` for now. I will still log the issue up there. – krishnab Aug 29 '18 at 01:34
  • 1
    Issue added to the helm repository. https://github.com/emacs-helm/helm/issues/2085 – krishnab Aug 29 '18 at 02:01