Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a specification for Emacs?

I'd like to implement another Emacs using Qt and Common Lisp as a hobby project just for my own learning. But I am not sure if there is such a thing as "Official specification for Emacs" so that I can follow to ensure maximum compatibility with other implementations, say GNU Emacs?

like image 241
Alex Avatar asked Jan 09 '23 11:01

Alex


2 Answers

Software and Specs

Some software is defined by a standard and have many implementations (e.g., Common Lisp, Scheme, C, C++ &c), and some software is defined by its unique implementation and the documentation is secondary to it (e.g., Emacs, Python, Ruby, Perl). There is an intermediate case of Java which is defined by an evolving standard and has a reference implementation which is tracked by a few others.

Emacs

The is no "Official specification for Emacs" - it is defined by the implementation (there are other Emacsen, some are more compatible, some less; some more alive, and some less). There is also extensive manuals for both Emacs the Editor and Emacs Lisp the language, and you should read both (start with C-h C-h). However, the doc is not the spec: when in doubt, refer to the sources, not the docs. If you find a disagreement between the two, the fix is usually to change the docs, not the code.

CL & Emacs

I suggest that you start with the CL-Emacs page - you did not think that you are the first person to think of Emacs in CL, did you? - there are quite a few similar projects already.

Shameless plug: 15 years ago I wrote elisp.lisp which lets you run "arbitrary" Emacs Lisp code in Common Lisp. Of course, it will not work with code which relies on Emacs editor features (like, e.g., buffers), but you can load Emacs calendar and convert dates from Gregorian to Mayan.

Plan

If you do decide to implement your CL Emacs from scratch, I suggest that you take a large Emacs Lisp project (e.g., Gnus, Calc, Org-mode &c) and make sure your editor supports it flawlessly. Then you know that you have something useful for other people.

like image 167
sds Avatar answered Jan 18 '23 12:01

sds


No such specification exists, to my knowledge (which is admittedly quite limited). Remember that, primarily, Emacs is just a rather quaint lisp VM, that just happens to edit text. Any Emacs user that doesn't immediately bind a bunch of keys, customize functionality and in general "mess up" whatever specifications exist, probably isn't using Emacs because they like it. Emacs was always meant to be an intermediate state, the jumping off point to whatever you want.

That said, not all is lost. First, there's the official GNU emacs manual, which is both fairly exaustive and easy to parse (in general). Unfortunately, much of the manual deals with Emacs Lisp, which, while central to Emacs, is not important to your project.


But! We're forgetting: One of the core pillars of Emacs philosophy is self-documentation. Emacs literally documents just about every aspect of its own behavior, via it's help system (and yes, the help system documents itself). Some useful commands

  • Control+h k <keybinding> (aka. describe-key) gives you the documentation for the function bound to the key you press. Accordingly, Control+h k, Control+h k gives you:

C-h k runs the command describe-key, which is an interactive compiled Lisp function in `help.el'.

It is bound to C-h k, <f1> k, <help> k, <menu-bar> <help-menu> <describe> <describe-key-1>.

(describe-key &optional KEY UNTRANSLATED UP-EVENT)

Display documentation of the function invoked by KEY. KEY can be any kind of a key sequence; it can include keyboard events, mouse events, and/or menu events. When calling from a program, pass KEY as a string or a vector. <content snipped>

  • Control+h f <function name> (aka. describe-function) gives you the documentation for any function in Emacs. As such, Control+h f describe-function renders:

describe-function is an interactive autoloaded compiled Lisp function in `help-fns.el'.

It is bound to C-h f, <f1> f, <help> f, <menu-bar> <help-menu> <describe> <describe-function>.

(describe-function FUNCTION)

Display the full documentation of FUNCTION (a symbol).

  • Control+h b (aka. describe-function) gives you a list of all keybindings and their corresponding commands. Typing Return on a command takes you to the description of that command (à la describe-function).

This is the tip of the iceberg. Type Alt + x describe- Tab and glory in the awesome power that is Emacs's documentation system.


Emacs is its own specification, in the same way that the old UNIX's existed, and the specifications were written off of them, not the other way 'round. Hopefully, this is sufficient for your needs.

Good Luck with your project. :)

like image 36
PythonNut Avatar answered Jan 18 '23 12:01

PythonNut