Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting read invalid syntax at certain point in buffer #251

Closed
ddoherty03 opened this issue Oct 4, 2020 · 7 comments
Closed

Getting read invalid syntax at certain point in buffer #251

ddoherty03 opened this issue Oct 4, 2020 · 7 comments

Comments

@ddoherty03
Copy link

I have my init file in a "literate" org file, and I am getting the following error when I invoke helpful-variable while the cursor is at a certain point in the buffer:

Debugger entered--Lisp error: (invalid-read-syntax "#")
  read(#<buffer init-ded.org>)
  helpful--variable-defined-at-point()
  helpful--variable-at-point()
  byte-code("\300\301\302 \303#C\207" [helpful--read-symbol "Variable: " helpful--variable-at-point helpful--variable-p] 4)
  call-interactively(helpful-variable nil nil)
  command-execute(helpful-variable)

The error is triggered by the following code snippet, which is in an org-mode src block:

#+BEGIN_SRC emacs-lisp
  (use-package rainbow-delimiters
    :ensure t
    :config
    (bind-key "C-z t (" #'rainbow-delimiters-mode))
#+END_SRC

To be precise, the error is triggered if the cursor is anywhere on or after the closing " in the bind-key macro call. Anywhere before that and there is no error.

@Wilfred
Copy link
Owner

Wilfred commented Oct 12, 2020

I'm unable to replicate this. I created a foo.org file containing that literate block, and helpful--variable-defined-at-point did not error in any position.

Are you getting this error in a standalone org file with just this literate block?

@ddoherty03
Copy link
Author

Wilfred,

After a lot of trial and error bisecting, the following looks like a fairly small file that triggers the error:

"hello (all ye worlds"
"hello all ye) []worlds""
it should not look outside the string for a matching paren.
#+BEGIN_SRC emacs-lisp
  (use-package rainbow-delimiters
    :ensure t
    :config
    (bind-key "C-z t (" 'rainbow-delimiters-mode))
#+END_SRC

I didn't notice the double close quote at the end of the second line above the source block until I did this exercise. It seems to be the culprit. I was able to solve /my/ problem by simply deleting the errant quote. But I thought you might want this in case it catches a corner case that might pop up elsewhere.

Thanks for the wonderful package, by the way.

@bhepple
Copy link

bhepple commented Nov 8, 2020

I believe I've also fallen into this - in my case it was an unhappy face in the middle of a pretty big org file - but the following text will exhibit the problem:

foo bar :-(
bar foo

... put the cursor on the second line and invoke helpful-variable (or helpful-symbol) and it attempts to parse something and gets upset at the unpaired parenthesis.

End of file during parsing

If the cursor is before the '(' all is well.

In my big org file, I get different parsing errors depending on where I am in the file.

With debug-on-error toggled on, I get this:

Debugger entered--Lisp error: (invalid-read-syntax ". in wrong context")
  read(#<buffer bh.org>)
  helpful--variable-defined-at-point()
  helpful--variable-at-point()
  byte-code("\300\301\302 \303#C\207" [helpful--read-symbol "Variable: " helpful--variable-at-point helpful--variable-p] 4)
  #<subr call-interactively>(helpful-variable nil nil)
  apply(#<subr call-interactively> helpful-variable (nil nil))
  call-interactively@ido-cr+-record-current-command(#<subr call-interactively> helpful-variable nil nil)
  apply(call-interactively@ido-cr+-record-current-command #<subr call-interactively> (helpful-variable nil nil))
  call-interactively(helpful-variable nil nil)
  command-execute(helpful-variable)

... perhaps helpful shouldn't attempt parsing at point unless a lisp mode is in effect?

@bigodel
Copy link

bigodel commented Nov 21, 2020

I'm getting a similar error when inside a ( ... ) when it spans multiple lines. So when trying to call helpful-variable, either through a binding or M-x helpful-variable in a any major mode in a similar setting to:

(
  anythingWithAComma,
)

In case it is either

(anythingWithAComma,)

or

(
anythingWithAComma,)

or even

(
anythingWithAComma,)

I don't get any errors and helpful-variable works as expected.

The error I get is

Debugger entered--Lisp error: (invalid-read-syntax ")")
  read(#<buffer *scratch*>)
  helpful--variable-defined-at-point()
  helpful--variable-at-point()
  byte-code("\300\301\302 \303#C\207" [helpful--read-symbol "Variable: " helpful--variable-at-point helpful--variable-p] 4)
  call-interactively(helpful-variable nil nil)
  command-execute(helpful-variable)

To reproduce, simply open any buffer and put any text with a comma on the in the middle line between parenthesis.

@narendraj9
Copy link
Contributor

narendraj9 commented Dec 16, 2020

I get the same error if I use helpful-symbol in Info mode buffers. helpful-symbol-at-point tries to read the whole buffer and fails.

@paultopia
Copy link

I also just got this error with helpful-symbol. It does appear to be related to location in buffer---I got it in the middle of a big line of markdown tet.

@wyuenho
Copy link
Contributor

wyuenho commented Mar 3, 2021

@Wilfred This issue can be easily reproduced by invoking helpful-variable after an unbalanced open paren in any elisp file. Just make one that's basically

;; test.el
(

and place the cursor after the open paren and invoke helpful-variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants