Evaluating lisp expressions in the minibuffer (or in the scratch buffer, or with C-x C-e
in an emacs-lisp buffer, or loading lisp libraries by hand with M-x load-file
or ....) only affects the current session of emacs. The moment you kill this emacs session everything that is not part of the initial emacs state is lost irretrievably. So even if you (add-to-list 'load-path ...)
appropriately and you (require '6502-mode)
in this session, if you are doing it interactively, you are only affecting the current session.
In order to affect a future emacs session, you need to save this initialization in a file and load that file into the future emacs session somehow. That's what the init file provides: when emacs starts up, it automatically knows to load that file. So you need to add such settings to your init file:
(add-to-list 'load-path "/usr/share/emacs/27.1/lisp/6502")
(require '6502-mode)
From that point on, every session of emacs you start up will load the init file, evaluating everything in it.
Sometimes, it is useful to start an emacs session that does NOT load your init file, e.g. there might be something wrong with it and your emacs session misbehaves: it is often useful in such cases to create an emacs session without your initializations in order to see whether emacs misbehaves the same way; if it does not, then that tells you that there is something wrong in your init file and you need to find it and fix it.
To start an emacs session without your initialization file, you can say emacs -q
: the -q
option tells emacs not to do its usual default action of loading the init file.
BTW, there are lots of details about the init file in the Emacs Manual: it's well worth reading that section (as is the whole manual of course, but you cannot read it in one sitting, but you should familiarize yourself with it, so you know where to go to look up something).
Another, very useful, way to read the manual is by using the Info system from within emacs. Assuming that you have the manual installed (which should be the case on any platform that you might use: Linux, Windows or MacOS), then in emacs you can say C-h i g (emacs)Init file RET
which will take you to the same page in your local copy of the manual that the link above takes you in the copy that's available on the web.
Learning how to use Info to look up things in emacs will prove invaluable: I highly recommend it.
load-path
addition higher up in your.emacs
/init.el
file so that when you(require '6502-mode)
Emacs knows where to find it? And, does your6502-mode.el
file have a(provide '6502-mode)
at the bottom or are you usingload
instead ofrequire
such that theprovide
statement is not needed?(add-to-list ...)
in the minibuffer only changes the currently running session of emacs. As @lawlist implies, you need to add the(add-to-list ...)
to your init file.(add-to-list 'auto-mode-alist '("\\.s65" . 6502-mode))
to auto-select the mode for associated files where 's65' may be replaced with any file extension. In my arduous search for the whereabouts of my init file I have also foundC-h v user-init-file RET
to be invaluable, thank you.