Question

I need to implement some new functions on an editor. I picked Emacs - although my main programming knowledge is in Java and C - and I want to add some functions and edit some existing functions of Emacs Editor. I looked at the source code of it and I'm a bit lost. I was wondering whether anyone can give me some advice about where to start and whether there are any tutorials that can help?

P.S. One specific question would be how one can start to write a new mode with all new features and behaviour? or how I can disable some basic functions like copy/paste?

Cheers

Was it helpful?

Solution

There are some tutorials out there specifically geared towards writing a major mode.

Other than that, writing modes in Emacs is just writing Lisp functions.

One thing I will note is that what you're proposing to do here may be pointless; if you implement a permission system as a major mode, a user can simply switch modes to turn it off. That's fine if the point of this permission system is to avoid clobbering edits (in which case I assume your users will cooperate with your aims). If you're expecting your users to be adversarial, then Emacs is the wrong tool for this.

OTHER TIPS

An Introduction to Programming in Emacs Lisp http://www.gnu.org/software/emacs/emacs-lisp-intro/ or type in emacs:

M-: (info "(eintr)Top") RET

Emacs Lisp Manual http://www.gnu.org/software/emacs/manual/elisp.html or type in emacs:

M-: (info "(elisp)Top") RET

Here is the manual section on defining major and minor modes:

C-hig (elisp) Modes RET

It is often beneficial to derive a new mode from an existing one which provides similar basic functionality to what you need.

If there's nothing which matches closely enough, examining the source code for modes which provide some of the same behaviour would be the next best thing.

I note that 'deriving' a mode from nil seems to be the common way of creating a completely new major mode. That way you still get all the benefits of the define-derived-mode macro.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top