Emacs is an extremely useful tool for everyone, working with text files. It can be used for programming with many programming languages or for typesetting with LaTeX and many more tasks. There are at least two prominent flavors of Emacs, the first one is GNU Emacs and the other one is called XEmacs. I chose XEmacs, years ago, because it had nicer toolbars. But nowadays I am using GNU Emacs.
In the following I will show you how I configured Emacs to fit my needs: I used Turbo Pascal and Delphi for many years. So wanted my well known keystrokes like C-F9, etc in Emacs. I am also used to the Wordstar shortcuts beginning with C-K and C-Q. And I never get used to Emacs default shortcuts.
There is something called wordstar-mode, but this is a major mode. Its keybindings will be overwritten if you change to others modes (e.g. for programming in C or java or AucTeX). So it is not useful for me.
Another problem is the copy and paste. I do not understand how you do it in the default configuration. I want Shift-Del and Shift-ins, nothing more, nothing less. Newer Emacsen have also CUA-mode (activate it from the Options Menu). It supports C-c, C-v, C-x for copy and paste, if there is a selection, otherwise C-c and C-x act as the default prefix-keys. Shift-Del and Shift-Ins are also available.
I have CUA mode activated so I can copy and paste in a more friendly way. In addition I worked out some lisp code that makes Emacs behave more like Turbo Pascal without being a major or minor mode. I used these settings for several years and over the years they have change a bit. But all in all by downloading and activating LFMode you get something which behaves like Turbo Pascal or Wordstar and works with different major modes.
|C-K F1||Show the keybindings with prefix C-K|
|C-Q F1||Show the keybindings with prefix C-Q|
|The next keystrokes are only a selection, use the two keystrokes above for more details.|
|Shift-F3||Save, then close file|
|F9||runs "make run"|
|C-F9||runs "make all"|
|C-k 0..9||saving a bookmark at position 0..9|
|C-q 0..9||moving to the bookmark saved at position 0..9|
|C-q b||search backward|
|C-q a||query replace|
|C-q r||beginning of buffer|
|C-q c||end of buffer|
|C-q g||goto line|
|C-q t||insert template in rectangle (string-rectangle)|
|C-k C-d||closes buffer/file, ask for confirmation if unsaved|
|C-k C-w||mark whole buffer|
|C-k i||insert file|
|C-k e||edit (open) file|
|C-k s||save file|
|C-k y||kill line|
cd /usr/local/share/emacs/site-lisp/ ln -s ~/LFMode/LF*.el
(setq load-path (append (list nil "~/LFMode/" ) load-path ) )
;;--------- LFMode (former tp_compat_mode) ------------- (load-library "LFKeys")at the end of your .emacs file.
For the real Tubro Pascal feeling I need yellow font on blue background: add the following lines to your .emacs or .xemacs file: there is a color-theme package, probably you have to install it (the Ubuntu package containing color-theme is called emacs-goodies-el):
(require 'color-theme) (color-theme-jonadabian)
After setting the colors, I need a nice looking non-proportional font for programming. The nicest font, I have found, belongs to the xfonts-terminus package. And I set them via XResources: append the next lines to your /etc/X11/Xresources/defaults file:
emacs*geometry: 80x70 emacs*font: -xos4-terminus-*-r-normal-*-14-*-*-*-*-*-*-*
The first line sets emacs to about one half of my 1280x1024 screen. The settings are activated the next time you start X. But it is also possible to try them at once:
xrdb -merge /etc/X11/Xresources/defaults
A fresh install of Emacs 22 (under Ubuntu 7.10) provides C-x + C-Right and C-x + C-Left as shortcuts for switching between buffers. That is nice and very user-friendly compared to what was available with older Emacsen. I used cycle-buffer.el from EmacsWiki for a long time, together with these lines in my .emacs file:
;; --------- cycle-buffer --------------------- (autoload 'cycle-buffer "cycle-buffer" "Cycle forward." t) (autoload 'cycle-buffer-backward "cycle-buffer" "Cycle backward." t) (autoload 'cycle-buffer-permissive "cycle-buffer" "Cycle forward allowing *buffers*." t) (autoload 'cycle-buffer-backward-permissive "cycle-buffer" "Cycle backward allowing *buffers*." t) (autoload 'cycle-buffer-toggle-interesting "cycle-buffer" "Toggle if this buffer will be considered." t) ;; Switch Buffers functions used to come from LFLib, now they come ;; from cycle-buffer, except other-window and -reverse ;; F6/shift-F6 changes the current buffer, also C-k C-n / C-k C-p (global-set-key '[f5] 'other-window) (global-set-key '[(shift f5)] 'other-window-reverse) (global-set-key [(shift f6)] 'cycle-buffer-backward) (global-set-key [f6] 'cycle-buffer) (global-set-key [(shift f7)] 'cycle-buffer-backward-permissive) (global-set-key [(f7)] 'cycle-buffer-permissive)
(setq text-mode-hook '(lambda () (flyspell-mode 1) (ispell-change-dictionary "german-latin1" ) ))
As you can see from the LFKey and LFLib files, I use the make command (and of course Makefiles) for building and running projects (and also for creating complex LaTeX-Documents). Make is a mature tool for running a command on a set or subset of files, depending when one individual file was changed compared to the rest. There is a lot of good documentation available, you can use. But for a start man make or info make provide some introduction.
Save one of these files in your project directory and rename it to "Makefile". Then edit it to fit your needs, use your filenames. Then you can use F9 or C-F9 as in Turbo Pascal, for every language with a command-line compiler or interpreter.
The first two Makefiles in the next table are intended to be include:
TARGET=MyDocument include /usr/local/include/Makefile/Makefile.latex
|simple Makefile for Python programming|
|Makefile for Latex, it is very complicated, and shows off many nice things. Be sure to read the comments.|
complex example featuring:
|simple Makefile for use with Pari/GP|