1

My emacs won't start properly any more. The basic, unmodified interface is opened with the following error:

Warning (initialization): An error occurred while loading ‘/home/qohelet/.emacs’:

Symbol's function definition is void: python-font-lock-assignment-matcher

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.

emacs --debug-init returns the following:

Debugger entered--Lisp error: (void-function python-font-lock-assignment-matcher)
  (python-font-lock-assignment-matcher (python-rx line-start (* space) (32 (or "[" "(")) grouped-assignment-target (* space) 44 (* space) (* assignment-target (* space) 44 (* space)) (32 assignment-target (* space)) (32 44 (* space)) (32 (or ")" "]") (* space)) (group assignment-operator)))
  (list (python-font-lock-assignment-matcher (python-rx line-start (* space) (32 (or "[" "(")) grouped-assignment-target (* space) 44 (* space) (* assignment-target (* space) 44 (* space)) (32 assignment-target (* space)) (32 44 (* space)) (32 (or ")" "]") (* space)) (group assignment-operator))) (quote (1 py-variable-name-face)) (cons (python-rx grouped-assignment-target) (quote ((progn (goto-char (match-end 1)) (match-beginning 2)) nil (1 py-variable-name-face)))))
  (list (rx symbol-start (or "if" "and" "del" "not" "while" "as" "elif" "global" "or" "async with" "with" "assert" "else" "pass" "yield" "break" "exec" "in" "continue" "finally" "is" "except" "raise" "return" "async for" "for" "lambda" "await" "match" "case") symbol-end) (cons (rx symbol-start (or "async def" "def" "class") symbol-end) (quote py-def-class-face)) (cons (rx symbol-start (or "import" "from") symbol-end) (quote py-import-from-face)) (cons (rx symbol-start (or "try" "if") symbol-end) (quote py-try-if-face)) (cons (rx symbol-start "def" (1+ space) (group (seq (any letter 95) (* (any word 95))))) (quote ((1 py-def-face)))) (cons (rx symbol-start "async def" (1+ space) (group (seq (any letter 95) (* (any word 95))))) (quote ((1 py-def-face)))) (cons (rx symbol-start (group "class") (1+ space) (group (seq (any letter 95) (* (any word 95))))) (quote ((1 py-def-class-face) (2 py-class-name-face)))) (cons (rx symbol-start (or "Ellipsis" "True" "False" "None" "__debug__" "NotImplemented") symbol-end) (quote py-pseudo-keyword-face)) (cons (rx line-start (* (any " \011")) (group "@" (1+ (or word 95)) (0+ "." (1+ (or word 95))))) (quote ((1 py-decorators-face)))) (cons (rx symbol-start (or "cls" "self") symbol-end) (quote py-object-reference-face)) (cons (rx word-start (or "ArithmeticError" "AssertionError" "AttributeError" "BaseException" "BufferError" "BytesWarning" "DeprecationWarning" "EOFError" "EnvironmentError" "Exception" "FloatingPointError" "FutureWarning" "GeneratorExit" "IOError" "ImportError" "ImportWarning" "IndentationError" "IndexError" "KeyError" "KeyboardInterrupt" "LookupError" "MemoryError" "NameError" "NoResultFound" "NotImplementedError" "OSError" "OverflowError" "PendingDeprecationWarning" "ReferenceError" "RuntimeError" "RuntimeWarning" "StandardError" "StopIteration" "SyntaxError" "SyntaxWarning" "SystemError" "SystemExit" "TabError" "TypeError" "UnboundLocalError" "UnicodeDecodeError" "UnicodeEncodeError" "UnicodeError" "UnicodeTranslateError" "UnicodeWarning" "UserWarning" "ValueError" "Warning" "ZeroDivisionError" ...) word-end) (quote py-exception-name-face)) (cons (rx (or space line-start (not (any "."))) symbol-start (group (or "_" "__doc__" "__import__" "__name__" "__package__" "abs" "all" "any" "apply" "basestring" "bin" "bool" "buffer" "bytearray" "bytes" "callable" "chr" "classmethod" "cmp" "coerce" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "execfile" "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" "int" "intern" "isinstance" "issubclass" "iter" "len" "list" "locals" ...)) symbol-end) (quote (1 py-builtins-face))) (quote ("f\\(['\"]\\{1,3\\}\\)\\([^\\1]+?\\)\\1" ("{[^}]*?}" (progn (goto-char (match-beginning 0)) (match-end 0)) (goto-char (match-end 0)) (0 py-variable-name-face t)))) (list (python-font-lock-assignment-matcher (python-rx line-start (* space) (32 (or "[" "(")) grouped-assignment-target (* space) 44 (* space) (* assignment-target (* space) 44 (* space)) (32 assignment-target (* space)) (32 44 (* space)) (32 (or ")" "]") (* space)) (group assignment-operator))) (quote (1 py-variable-name-face)) (cons (python-rx grouped-assignment-target) (quote ((progn (goto-char (match-end 1)) (match-beginning 2)) nil (1 py-variable-name-face))))) (cons (lambda (limit) (let ((re (rx (* "self") (group ...) (* space) (* 44 ... ... ...) (or ":" "=" "+=" "-=" "*=" "/=" "//=" "%=" "**=" ">>=" "<<=" "&=" "^=" "|="))) (res nil)) (while (and (setq res (re-search-forward re limit t)) (goto-char (match-end 1)) (nth 1 (parse-partial-sexp ... ...)))) res)) (quote (1 py-variable-name-face nil nil))) (cons (rx symbol-start (1+ digit) symbol-end) (quote py-number-face)))
  (\` ((\, (rx symbol-start (or "if" "and" "del" "not" "while" "as" "elif" "global" "or" "async with" "with" "assert" "else" "pass" "yield" "break" "exec" "in" "continue" "finally" "is" "except" "raise" "return" "async for" "for" "lambda" "await" "match" "case") symbol-end)) ((\, (rx symbol-start (or "async def" "def" "class") symbol-end)) . py-def-class-face) ((\, (rx symbol-start (or "import" "from") symbol-end)) . py-import-from-face) ((\, (rx symbol-start (or "try" "if") symbol-end)) . py-try-if-face) ((\, (rx symbol-start "def" (1+ space) (group (seq (any letter 95) (* ...))))) (1 py-def-face)) ((\, (rx symbol-start "async def" (1+ space) (group (seq (any letter 95) (* ...))))) (1 py-def-face)) ((\, (rx symbol-start (group "class") (1+ space) (group (seq (any letter 95) (* ...))))) (1 py-def-class-face) (2 py-class-name-face)) ((\, (rx symbol-start (or "Ellipsis" "True" "False" "None" "__debug__" "NotImplemented") symbol-end)) . py-pseudo-keyword-face) ((\, (rx line-start (* (any " \011")) (group "@" (1+ (or word 95)) (0+ "." (1+ ...))))) (1 py-decorators-face)) ((\, (rx symbol-start (or "cls" "self") symbol-end)) . py-object-reference-face) ((\, (rx word-start (or "ArithmeticError" "AssertionError" "AttributeError" "BaseException" "BufferError" "BytesWarning" "DeprecationWarning" "EOFError" "EnvironmentError" "Exception" "FloatingPointError" "FutureWarning" "GeneratorExit" "IOError" "ImportError" "ImportWarning" "IndentationError" "IndexError" "KeyError" "KeyboardInterrupt" "LookupError" "MemoryError" "NameError" "NoResultFound" "NotImplementedError" "OSError" "OverflowError" "PendingDeprecationWarning" "ReferenceError" "RuntimeError" "RuntimeWarning" "StandardError" "StopIteration" "SyntaxError" "SyntaxWarning" "SystemError" "SystemExit" "TabError" "TypeError" "UnboundLocalError" "UnicodeDecodeError" "UnicodeEncodeError" "UnicodeError" "UnicodeTranslateError" "UnicodeWarning" "UserWarning" "ValueError" "Warning" "ZeroDivisionError" ...) word-end)) . py-exception-name-face) ((\, (rx (or space line-start (not (any "."))) symbol-start (group (or "_" "__doc__" "__import__" "__name__" "__package__" "abs" "all" "any" "apply" "basestring" "bin" "bool" "buffer" "bytearray" "bytes" "callable" "chr" "classmethod" "cmp" "coerce" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "execfile" "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" "int" "intern" "isinstance" "issubclass" "iter" "len" "list" "locals" ...)) symbol-end)) 1 py-builtins-face) ("f\\(['\"]\\{1,3\\}\\)\\([^\\1]+?\\)\\1" ("{[^}]*?}" (progn (goto-char (match-beginning 0)) (match-end 0)) (goto-char (match-end 0)) (0 py-variable-name-face t))) ((\, (python-font-lock-assignment-matcher (python-rx line-start (* space) (32 (or "[" "(")) grouped-assignment-target (* space) 44 (* space) (* assignment-target (* space) 44 (* space)) (32 assignment-target (* space)) (32 44 (* space)) (32 (or ")" "]") (* space)) (group assignment-operator)))) (1 py-variable-name-face) ((\, (python-rx grouped-assignment-target)) (progn (goto-char (match-end 1)) (match-beginning 2)) nil (1 py-variable-name-face))) ((\, (lambda (limit) (let ((re ...) (res nil)) (while (and ... ... ...)) res))) 1 py-variable-name-face nil nil) ((\, (rx symbol-start (1+ digit) symbol-end)) . py-number-face)))
  (defconst python-font-lock-keywords (\` ((\, (rx symbol-start (or "if" "and" "del" "not" "while" "as" "elif" "global" "or" "async with" "with" "assert" "else" "pass" "yield" "break" "exec" "in" "continue" "finally" "is" "except" "raise" "return" "async for" "for" "lambda" "await" "match" "case") symbol-end)) ((\, (rx symbol-start (or "async def" "def" "class") symbol-end)) . py-def-class-face) ((\, (rx symbol-start (or "import" "from") symbol-end)) . py-import-from-face) ((\, (rx symbol-start (or "try" "if") symbol-end)) . py-try-if-face) ((\, (rx symbol-start "def" (1+ space) (group (seq ... ...)))) (1 py-def-face)) ((\, (rx symbol-start "async def" (1+ space) (group (seq ... ...)))) (1 py-def-face)) ((\, (rx symbol-start (group "class") (1+ space) (group (seq ... ...)))) (1 py-def-class-face) (2 py-class-name-face)) ((\, (rx symbol-start (or "Ellipsis" "True" "False" "None" "__debug__" "NotImplemented") symbol-end)) . py-pseudo-keyword-face) ((\, (rx line-start (* (any " \011")) (group "@" (1+ ...) (0+ "." ...)))) (1 py-decorators-face)) ((\, (rx symbol-start (or "cls" "self") symbol-end)) . py-object-reference-face) ((\, (rx word-start (or "ArithmeticError" "AssertionError" "AttributeError" "BaseException" "BufferError" "BytesWarning" "DeprecationWarning" "EOFError" "EnvironmentError" "Exception" "FloatingPointError" "FutureWarning" "GeneratorExit" "IOError" "ImportError" "ImportWarning" "IndentationError" "IndexError" "KeyError" "KeyboardInterrupt" "LookupError" "MemoryError" "NameError" "NoResultFound" "NotImplementedError" "OSError" "OverflowError" "PendingDeprecationWarning" "ReferenceError" "RuntimeError" "RuntimeWarning" "StandardError" "StopIteration" "SyntaxError" "SyntaxWarning" "SystemError" "SystemExit" "TabError" "TypeError" "UnboundLocalError" "UnicodeDecodeError" "UnicodeEncodeError" "UnicodeError" "UnicodeTranslateError" "UnicodeWarning" "UserWarning" "ValueError" "Warning" "ZeroDivisionError" ...) word-end)) . py-exception-name-face) ((\, (rx (or space line-start (not ...)) symbol-start (group (or "_" "__doc__" "__import__" "__name__" "__package__" "abs" "all" "any" "apply" "basestring" "bin" "bool" "buffer" "bytearray" "bytes" "callable" "chr" "classmethod" "cmp" "coerce" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "execfile" "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" "int" "intern" "isinstance" "issubclass" "iter" "len" "list" "locals" ...)) symbol-end)) 1 py-builtins-face) ("f\\(['\"]\\{1,3\\}\\)\\([^\\1]+?\\)\\1" ("{[^}]*?}" (progn (goto-char (match-beginning 0)) (match-end 0)) (goto-char (match-end 0)) (0 py-variable-name-face t))) ((\, (python-font-lock-assignment-matcher (python-rx line-start (* space) (32 ...) grouped-assignment-target (* space) 44 (* space) (* assignment-target ... 44 ...) (32 assignment-target ...) (32 44 ...) (32 ... ...) (group assignment-operator)))) (1 py-variable-name-face) ((\, (python-rx grouped-assignment-target)) (progn (goto-char (match-end 1)) (match-beginning 2)) nil (1 py-variable-name-face))) ((\, (lambda (limit) (let (... ...) (while ...) res))) 1 py-variable-name-face nil nil) ((\, (rx symbol-start (1+ digit) symbol-end)) . py-number-face))) "Keywords matching font-lock")
  eval-buffer(#<buffer  *load*-400657> nil "/home/qohelet/.emacs.d/elpa/python-mode-20220527.1144/python-mode.el" nil t)  ; Reading at buffer position 695603
  load-with-code-conversion("/home/qohelet/.emacs.d/elpa/python-mode-20220527.1144/python-mode.el" "/home/qohelet/.emacs.d/elpa/python-mode-20220527.1144/python-mode.el" nil t)
  require(python-mode)
  eval-buffer(#<buffer  *load*-655788> nil "/home/qohelet/.emacs.d/IDE.el" nil t)  ; Reading at buffer position 4433
  load-with-code-conversion("/home/qohelet/.emacs.d/IDE.el" "/home/qohelet/.emacs.d/IDE.el" nil nil)
  load("~/.emacs.d/IDE.el")
  eval-buffer(#<buffer  *load*> nil "/home/qohelet/.emacs" nil t)  ; Reading at buffer position 1174
  load-with-code-conversion("/home/qohelet/.emacs" "/home/qohelet/.emacs" t t)
  load("~/.emacs" t t)
  #f(compiled-function () #<bytecode 0x1e0f4d>)()
  command-line()
  normal-top-level()

From what I can say the error seems to be in the python-mode.el - which is making it a little harder to solve. https://emacs.stackexchange.com/a/51469 had a good suggestion and I assume it might be something like that (even though pretty unrelated error):

It appears that your file has a spurious | in it, which could be caused by an incomplete git merge.

So what do we have (yesterday everything was running, I did not change anything):

"/home/qohelet/.emacs" position 1174:

(load (mapconcat 'identity (list IDE-path "IDE.el") ""))

"/home/qohelet/.emacs.d/IDE.el" position 4433:

(require 'python-mode)

The code of this is public by the way: https://github.com/qohelet/emacs_python_ide - a colleague and I set up emacs to our needs.

At this point I tend to rule out I accidentally changed something in the files. The rest just leads me to python-mode.el (695603):

    (,(rx symbol-start (1+ digit) symbol-end) . py-number-face))
  >This line> "Keywords matching font-lock")

This is as it seems to me just the exception block (Lisp is not my strongest side, I'm guessing) as it's under the following head, followed by more exceptions:

;; Exceptions
    (,(rx word-start
          (or "ArithmeticError" "AssertionError" "AttributeError"

The mentioned function load-with-code-conversion in mule.el.gz:

(defun load-with-code-conversion (fullname file &optional noerror nomessage)
  "Execute a file of Lisp code named FILE whose absolute name is FULLNAME.
The file contents are decoded before evaluation if necessary.
If optional third arg NOERROR is non-nil,
 report no error if FILE doesn't exist.
Print messages at start and end of loading unless
 optional fourth arg NOMESSAGE is non-nil.
Return t if file exists."
  (if (null (file-readable-p fullname))
      (and (null noerror)
       (signal 'file-error (list "Cannot open load file" file)))
    ;; Read file with code conversion, and then eval.
    (let* ((buffer
            ;; We can't use `generate-new-buffer' because files.el
            ;; is not yet loaded.
            (get-buffer-create (generate-new-buffer-name " *load*")))
       (load-in-progress t)
       (source (save-match-data (string-match "\\.el\\'" fullname))))
      (unless nomessage
    (if source
        (message "Loading %s (source)..." file)
      (message "Loading %s..." file)))
      (when purify-flag
    (push (purecopy file) preloaded-file-list))
      (unwind-protect
      (let ((load-file-name fullname)
        (set-auto-coding-for-load t)
        (inhibit-file-name-operation nil))
        (with-current-buffer buffer
              ;; So that we don't get completely screwed if the
              ;; file is encoded in some complicated character set,
              ;; read it with real decoding, as a multibyte buffer.
              (set-buffer-multibyte t)
          ;; Don't let deactivate-mark remain set.
          (let (deactivate-mark)
        (insert-file-contents fullname))
          ;; If the loaded file was inserted with no-conversion or
          ;; raw-text coding system, make the buffer unibyte.
          ;; Otherwise, eval-buffer might try to interpret random
          ;; binary junk as multibyte characters.
          (if (and enable-multibyte-characters
               (or (eq (coding-system-type last-coding-system-used)
                   'raw-text)))
          (set-buffer-multibyte nil))
          ;; Make `kill-buffer' quiet.
          (set-buffer-modified-p nil))
        ;; Have the original buffer current while we eval.
        (eval-buffer buffer nil
             ;; This is compatible with what `load' does.
             (if purify-flag file fullname)
             nil t))
    (let (kill-buffer-hook kill-buffer-query-functions)
      (kill-buffer buffer)))
      (do-after-load-evaluation fullname)

      (unless (or nomessage noninteractive)
    (if source
        (message "Loading %s (source)...done" file)
      (message "Loading %s...done" file)))
      t)))

Also here I can't find anything unusual on looking over it. python-font-lock-assignment-matcher which is there when started regularly has nothing except its own code online, so I assume it's not the proper error.

First I removed everything in .emacs.d and even tried if there is a weird package not properly updated. No success. All packages are apparently upgraded.

I am using GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14)

4
  • I think you need the built-in python module, so just write (require ‘python), not python-mode, which is another one, external module. Other posters had the same/similar problem(s).
    – Ian
    May 31, 2022 at 5:42
  • Interesting pick? Seems to work so far. Emacs starts again regularly (before I removed the line already to continue working) Would you mind explaining me what is the issue for that?
    – Qohelet
    May 31, 2022 at 5:59
  • For the sake of any other readers with the same issue who might try to copy/paste, that should be (require 'python) with a normal ascii apostrophe rather than the unicode quote character accidentally used in the earlier comment.
    – phils
    May 31, 2022 at 6:20
  • 1
    @Qohelet: (require 'python) loads and evals a different library (the built-in python.el) than (require 'python-mode), which loads python-mode.el, available in MELPA. May 31, 2022 at 8:50

2 Answers 2

1

It should be noted that python-font-lock-assignment-matcher is a function in package python, which is invoked by python-mode. However, there are two python packages, one is the built-in version and the other is modified from the built-in version with some fontification and can be installed by the package manager from EPLA. Here, the function python-font-lock-assignment-matcher comes from the latter version of python package. So, you can try to install or update the modified python package to solve the problem.

1

python-mode.el maintainer here. The version in question contained a (require 'python). However, with an older Emacs,python-font-lock-assignment-matcher might not be provided. Should be fixed by a replacement calling py-font-lock-assignment-matcher now: 1

1
  • Hey cool, thank you for answering :)
    – Qohelet
    Jun 2, 2022 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.