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

indent region doesn't work #55

Open
jcubic opened this issue Apr 10, 2023 · 3 comments
Open

indent region doesn't work #55

jcubic opened this issue Apr 10, 2023 · 3 comments

Comments

@jcubic
Copy link

jcubic commented Apr 10, 2023

when selecting text and press tab to indent region. Got this error:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  graphql-beginning-of-query()
  graphql-indent-line()
  indent-according-to-mode()
  indent-region-line-by-line(1 155)
  indent-region(1 155)
  indent-for-tab-command(nil)
  funcall-interactively(indent-for-tab-command nil)
  command-execute(indent-for-tab-command)
@davazp
Copy link
Owner

davazp commented Apr 11, 2023

The problem seem to be indenting lines that are outside of the {..}. For example

query |Name {
}

where | is the cursor, it'll throw that error. I've fixed it by assuming the toplevel query starts at the same line if that is the case.

Please try the latest version from master or when it is released.

@jcubic
Copy link
Author

jcubic commented Apr 11, 2023

I've downloaded and loaded the file but now got this error when pressing TAB:

Debugger entered--Lisp error: (void-function pos-bol)
  (pos-bol)
  (syntax-ppss (pos-bol))
  (syntax-ppss-toplevel-pos (syntax-ppss (pos-bol)))
  (or (syntax-ppss-toplevel-pos (syntax-ppss (pos-bol))) (pos-bol))
  (goto-char (or (syntax-ppss-toplevel-pos (syntax-ppss (pos-bol))) (pos-bol)))
  graphql-beginning-of-query()
  (save-excursion (graphql-beginning-of-query) (setq column (current-column)))
  (let ((position (point)) (column) (indent-pos)) (save-excursion (graphql-beginning-of-query) (setq column (current-column))) (save-excursion (let ((level (car (syntax-ppss (point-at-bol))))) (if (looking-at "\\s-*\\s)") (progn (setq level (1- level)))) (indent-line-to (+ column (* graphql-indent-level level))) (setq indent-pos (point)))) (if (< position indent-pos) (progn (goto-char indent-pos))))
  graphql-indent-line()
  indent--funcall-widened(graphql-indent-line)
  indent-for-tab-command(nil)
  funcall-interactively(indent-for-tab-command nil)
  command-execute(indent-for-tab-command)

@davazp
Copy link
Owner

davazp commented Apr 11, 2023

Oh, it seems pos-bol is a new function that will be available >= 29.

Probably introduced at or before Emacs version 29.1.

I replaced with line-beginning-position at 0ad4ae0

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

No branches or pull requests

2 participants