1

I have the following code that is launched on Emacs startup:

(defun my-prolog-mode ()
  (define-key prolog-mode-map (kbd "M-a") 'pop-tag-mark))

(eval-after-load "prolog-mode" '(my-prolog-mode))

I expect pop-tag-mark function to be launched when M-a is clicked. But for some reason M-a is bound to another function:

M-a runs the command prolog-beginning-of-clause, which is an
interactive compiled Lisp function in ‘prolog.el’.

What is it?

1
  • Over time, you'll find you build up lots of small additions and changes to your main packages. Naming becomes important. I would just caution you against naming a function something-mode when it does not in fact create a mode, which is a well-established and widespread naming convention. Can I suggest my-prolog-mode-setup instead? Oct 20, 2021 at 4:24

1 Answer 1

2

eval-after-load expects the first argument to be the name of a file, with or without an extension. prolog-mode is defined in the file "prolog.el", not "prolog-mode.el". This should work:

(eval-after-load "prolog" '(my-prolog-mode))
3
  • Now it gives an error: Symbol's value as variable is void: prolog-mode-map.
    – user4035
    Oct 16, 2021 at 17:18
  • Even though prolog-mode-map is a valid symbol. Probably, prolog mode is not loaded when my-prolog-mode is executed.
    – user4035
    Oct 16, 2021 at 17:23
  • 1
    Ok, I find out: I had my own ~/emacs.d/prolog.el. Renaming it to my-prolog.el fixed the issue.
    – user4035
    Oct 16, 2021 at 17:27

Your Answer

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

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