davazp / graphql-mode

An Emacs mode for GraphQL
GNU General Public License v3.0
162 stars 31 forks source link

wrong-type-argument integer-or-marker-p nil #54

Closed jcubic closed 1 year ago

jcubic commented 1 year ago

Got this error when pressing TAB key:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  graphql-beginning-of-query()
  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)
jcubic commented 1 year ago

I think this is because of electric-indent-mode that doesn't work together with graphql-mode.

jcubic commented 1 year ago

I have this hack to fix the issue:

(defun new-line-and-indent-fix ()
  (interactive)
  (newline)
  (indent-for-tab-command))

(defun after-major-mode ()
  (if (memql major-mode '(yaml-mode
                          python-mode
                          nxml-mode
                          graphql-mode-hook
                          lisp-interaction-mode))
      (electric-indent-mode -1))
  (if (not (memql major-mode
                  '(fundamental-mode
                    erc-mode
                    text-mode
                    eshell-mode
                    shell-mode
                    minibuffer-mode
                    inferior-js-mode
                    nodejs-repl-mode
                    change-log-mode
                    comint-mode
                    lisp-interaction-mode
                    inferior-scheme-mode
                    sql-mode)))
      (progn
        (local-set-key (kbd "<RET>")
                       'new-line-and-indent-fix))))

(add-hook 'after-change-major-mode-hook 'after-major-mode)

I had to add graphql-mode to the list, the code was turned off in my .emacs not sure why.

davazp commented 1 year ago

I do have electric-indent-mode with graphql-mode without that error.

Could you try isolating it from the rest of the config? It might be a conflict with another package.

davazp commented 1 year ago

Oh I see in the new issue you mention selecting a region. That reproduced it for me. Closing this one.