helpful icon indicating copy to clipboard operation
helpful copied to clipboard

Some function lookups using `helpful-function' yield `args-out-of-range'

Open terlar opened this issue 8 years ago • 3 comments

When I do a lookup on certain functions I consistently get this error.

One example is org-edit-special:

Debugger entered--Lisp error: (args-out-of-range 0 10)
  replace-match(#("ffap" 0 4 (button (t) category helpful-describe-button-button symbol ffap)) t t "`ffap'" nil)
  replace-regexp-in-string("`\\_<\\(?:.\\|\n\\)+?\\_>'" #f(compiled-function (it) #<bytecode 0x1fdcbab>) "Call a special editor for the element at point.\n\nWhen at a table, call the formula editor with `org-table-edit-formulas'.\nWhen in a source code block, call `org-edit-src-code'.\nWhen in a fixed-width region, call `org-edit-fixed-width-region'.\nWhen in an export block, call `org-edit-export-block'.\nWhen at an #+INCLUDE keyword, visit the included file.\nWhen at a footnote reference, call `org-edit-footnote-reference'\nOn a link, call `ffap' to visit the link at point.\nOtherwise, return a user error." t t)
  helpful--format-docstring("Call a special editor for the element at point.\nWhen at a table, call the formula editor with `org-table-edit-formulas'.\nWhen in a source code block, call `org-edit-src-code'.\nWhen in a fixed-width region, call `org-edit-fixed-width-region'.\nWhen in an export block, call `org-edit-export-block'.\nWhen at an #+INCLUDE keyword, visit the included file.\nWhen at a footnote reference, call `org-edit-footnote-reference'\nOn a link, call `ffap' to visit the link at point.\nOtherwise, return a user error.")
  helpful-update()
  helpful-function(org-edit-special)
  funcall-interactively(helpful-function org-edit-special)
  call-interactively(helpful-function nil nil)
  command-execute(helpful-function)

Could it be related to some function being byte-compiled? Or is this some obvious error?

terlar avatar Nov 23 '17 18:11 terlar

I'm unable to reproduce this with org-edit-special. Are you seeing it with other commands? Could you report your Emacs and org-mode versions, or better yet describe how to reproduce starting from emacs -Q?

Wilfred avatar Nov 29 '17 22:11 Wilfred

It was tricky but I finally boiled it down to what it was, it is related to my setup and you can achieve it with the following steps:

  1. M-: (setq debug-on-error t)
  2. M-: (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/")))
  3. M-x package-install org-mode
  4. M-x package-install helpful
  5. M-: (defun +is-useful-buffer (buffer) (not (string-match "^ ?\\*.*\\*\\(<[0-9]+>\\)?$" (buffer-name buffer))))
  6. M-: (push '(buffer-predicate . +is-useful-buffer) default-frame-alist)
  7. C-x 5 2
  8. In the new frame run M-x helpful-function org-edit-special

So looking at this it is quite obvious since obviously the package expects some buffer with *...* to show up. I haven't experienced any issues with other things however with this buffer predicate (that I know of...)

Thank you for your help, perhaps I should look into alternatives to the buffer-predicate.

terlar avatar Dec 03 '17 08:12 terlar

Thanks, I can reproduce. I'm not sure what's causing it yet though.

Wilfred avatar Dec 06 '17 23:12 Wilfred