1 Definition[edit | edit source]

Note: Copy/Paste from http://tecfa.unige.ch/guides/emacs/pointers.html (will clean this up sometimes soon I hope - Daniel K. Schneider 19:50, 2 November 2007 (MET)

Emacs is a text editor, and much more. XEmacs provides a comprehensive environment where you can edit source code, or multiple text files, read mail or news, and even edit files remotely using FTP.

There exist many variants: The most popular one is Gnu Emaces (the almost original)

Warning: Emacs is very powerful, but since it was born before Windows (or even MS-DOS), shortcuts are not the same. Also it is geared towards speed. The typical emacs user doesn't not want time-consuming pop dialogs, but you dialog though a little minibuffer window. That's stuff you have to learn. Else forget it. When you install Emacs there is a tutorial (Hit the help button) and do it at least 10 times ;)

See also: Text editor

2 Specialized tips[edit | edit source]

(Some tips regarding formats discussed in this wiki)

2.1 Some essential customization[edit | edit source]

E.g. setting the default directory, aspell directory, initial buffer properties, etc.

(setq default-directory "c:/")
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
'(case-fold-search t)
'(current-language-environment "UTF-8")
'(inhibit-startup-screen t)
'(initial-major-mode (quote text-mode))
'(initial-scratch-message nil)
'(ispell-alternate-dictionary "c:/Program Files/Aspell/dict")
'(ispell-complete-word-dict "c:/Program Files/Aspell/dict")
'(ispell-program-name "c:/Program Files/Aspell/bin/aspell.exe")
'(longlines-show-hard-newlines t)
'(longlines-wrap-follows-window-size t)
'(temporary-file-directory "c:/tmp")
'(transient-mark-mode (quote identity)))

2.2 Managing packages[edit | edit source]

Can be very difficult for a beginner.

However, for older emacsen try ELPA, a friendly package manager

Howto:

Try to install emacs-24 (2012). It does have an integrated package manager.

2.3 HTML[edit | edit source]

Some history

Back in time, we used to have fairly useful and productive HTML help modes. E.g. in the '90s hm-html-help-mode (or something like that) and then the PSGML mode. The latter did not support very well initial creation of a page, but could provide help for any kind of HTML/XHTML DTD (since PSGML is an SGML/XML editor mode). In later versions of Gnu Emacs, both extensions are not included by default and have to be installed and configured.

For PSGML (still one of the best DTD-based XML editors around), insert at least the following in your .emacs. There are endless other options....

 (autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)
 (autoload 'xml-mode "psgml" "Major mode to edit SGML files." t)
 (setq sgml-set-face t
      sgml-indent-data t
      sgml-auto-activate-dtd t)
 (defun go-bind-markup-menu-to-mouse3 ()
  (define-key sgml-mode-map [mouse-3] 'sgml-tags-menu)
  (define-key sgml-mode-map [shift-mouse-3] 'sgml-attrib-menu)
  )

;; change key binding whenever psgml mode is invoked
(add-hook 'sgml-mode-hook 'go-bind-markup-menu-to-mouse3)
(add-hook 'xml-mode-hook 'go-bind-markup-menu-to-mouse3)

PSGML is a must have extension if you work a lot with XML DTD's of various sorts. Modern distributions of Gnu Emacs don't include PSGML since they favor the Relax (rng) schema language and make the nxml extension the default XML editor. Support for HTML isn't satisfactory, e.g. nxml-based HTML editing is much too time consuming to use unless you do some heavy configuration work. However, readon ! There is a good HTML extension that is based on nxml.

nXhtml

For Gnu emacs 23.x the best HTML add-on is probably nXhtml since it supports editing of multiple formats (JavaScript and CSS) in one single page. See also its emacswiki entry. However, it will take some time to learn how to use it. E.g. when you start with a fresh page, there is no way to simply insert a new HTML/XHTML page template.

Under Windows (tested with Emacs 32.2 win 7 64bit)

c:\soft\emacs-32\site-lisp
This file typically sits in c:/Users/xxx/AppData/Roaming/ directory, else just open it with C-X C-F entering ~/.emacs
(load "YOUR-PATH-TO/nxhtml/autostart.el")

e.g.

(load "c:/soft/emacs-23.2/site-lisp/nxhtml/autostart.el")

Under Ubuntu

sudo apt-get install js2-mode
(require 'js2-mode)
/usr/share/emacs/site-lisp

E.g. (for a particular version). Also, add "sudo" in front of each if you are not root.

cd /usr/share/emacs/site-lisp
wget http://ourcomments.org/Emacs/DL/elisp/nxhtml/zip/nxhtml-2.08-100425.zip
unzip -l nxhtml-2.08-100425.zip
unzip nxhtml-2.08-100425.zip
sudo chown -R xxx:yyy nxhtml
(load "/usr/share/emacs/site-lisp/nxhtml/autostart.el")

2.4 ActionScript[edit | edit source]

Install: actionscript-mode.el written by Pet Tomato. Tested by Daniel K. Schneider with GnuEmacs 21.4.1 under Ubuntu. He provides 2 files:

There is a different and more recent actionscript mode from Austin Haas based on David Linquists ecmascript-mode. (made for emacsw32). I use this now for emacs 22.1.1 on Ubuntu - Daniel K. Schneider 13:17, 1 November 2008 (UTC)

To install these I did the following:

;; Actionscript stuff
(autoload 'actionscript-mode "actionscript-mode"
  "Major mode for editing ActionScript files." t)

(add-to-list 'auto-mode-alist '("\\.as[123]?$" . actionscript-mode))

2.5 XML[edit | edit source]

DTD support

The Xemacs (default "fat") installation provides good XML/DTD support through the PSGML library.

On recent Gnu Emacsen, the PSGML library has to be installed since nXML is now the default XML mode. E.g. on Linux Ubuntu this can be done through the Synaptic Package Manager. Type M-x xml-mode to get it.

Both Emacsen will find your private (system) DTDs and also includes/supports a list of public DTDs (you can add yours in the installation by editing ).

Relax NG (RNC) support

Use nXML mode (it is distributed with a standard recent Gnu emacs installation). Here is a short how to:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
</mx:Application>

As you can see, this interface was made for people willing to learn keyboard strokes. It's faster than using right-click contextual menus but more challenging for some ...

XML Schema (XSD) support
XSLT support

2.6 Mediawikis[edit | edit source]

Editing wiki code on Mediawiki's is a real pain if you got large articles to manipulate. The visual editor doesn't allow to do certain things. Over the years there have been several packages that allow editing wiki pages with Emacs and none really works to full satisfaction as of 2016/ 2017 and 2018.

2.6.1 Edit with Emacs (browser extension)[edit | edit source]

this is a browser extension that works both with Firefox and Chrome. Not as good as a direct emacs-mediawiki interface but almost. Tested and used with Ubuntu 16.04 and 18.04 LTS and Windows 8 and Windows 10.

It allows editing any HTML text area with emacs and therefore also wikipages.

Installation on Ubutu 16x (tested on April 2018)

(require 'edit-server)
(edit-server-start)

Use:

The same works on Emacs 25.x on Windows 10. However after saving (CTRL-X CTRL-S) the buffer will be burried and inactive. E.g. you'd have to press the edit button again.

Tip: Even if mediwiki.el doesn't work (see below) you could still install it in order to get mediawiki-mode (syntax hightligthning)-

2.6.2 MediaWiki.el[edit | edit source]

As of April 2018 (also in 2017) only this seemed to work with recent emacs/MediaWiki combos. But not on my machines :(

It is also available in the MELPA package:

In the .emacs files add

(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)

Or if you want some more complex code that should be more reliable:

(require 'package)

(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (proto (if no-ssl "http" "https")))
  ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
  (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
  (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t)
  ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
  (when (< emacs-major-version 24)
    ;; For important compatibility libraries like cl-lib
    (add-to-list 'package-archives '("gnu" . (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)

Then, use menu Options -> Manage Emacs Packages and select mediawiki.

Now it gets more difficult.

Trouble with Emacs 24x on Ubuntu 16x

As of Nov 2017, I used the 2.2.3 version for Ubuntu (24.5.1) and the the 27012 version for Windows 10 (Emacs 25.3.1). Frequently, Ubuntu distributes old code. This is probably due to the complexit of package management. But it is somewhat strange that a good workaround for not working open source software is to use Windows.

Trouble with Emacs 25x on Windows 10 (and probably many older versions too).

Emacs needs a TLS library. According to several sources, the following should work:

... anyhow this did not work for me (Emacs 25x/Win10/April 4, 2018).

2.6.3 Most important Mediawiki.el commands[edit | edit source]

Acknowledgement: (Slightly Modified) summaries and templates taken from Wikiemacs

M-x mediawiki-site
Choose a site (say "WikEmacs") for the current session.
[C-c C-o] (or M-x mediawiki-open)
Open a page. To edit the main page, type "Main Page". Make your edits. (Copy and paste the page name from your web browser). However you need to define this key (see below)
[C-x C-s] (or M-x mediawiki-save)
Submit your modifications.
[C-c] (or M-x mediawiki-save-and-bury)
Submit modifications and bury the buffer.
[C-return] (or M-x mediawiki-open-page-at-point)
Follow or browse to a WikiLink within the wiki code.
[M-g] (or M-x mediawiki-reload)
Reload a page

Suggested addition (edit your .emacs file)

(define-key mediawiki-mode-map (kbd "C-c o") 'mediawiki-browse)
[C-c o] (or M-x mediawiki-browse)
Will display the page in the web browser
The following commands put in markup structures.
C-c C-f C-s inserts italics
C-c C-f C-b inserts bold text
C-c C-f TAB italics
C-c C-f C-e header
C-c C-f C-l inserts a link
C-c C-f C-u inserts user name
C-c C-w inserts Daniel K. Schneider 15:25, 11 October 2012 (CEST)
<M-return> inserts enumerate type structures
C-\ inserts itemize type structures
C-c C-l inserts a hline


For more information:

Problems:

3 Installation[edit | edit source]

3.1 Ubuntu 16 and 18 LTS[edit | edit source]

$ sudo apt update
$ sudo apt install emacs

Install packages (works much better now than previous extensions)

4 Links[edit | edit source]

4.1 Manuals & Short References[edit | edit source]

GNU Emacs
XEmacs

En français:

4.2 Customization Links[edit | edit source]

Configuring the functionalities of XEmacs:

4.3 FAQ's[edit | edit source]

4.4 Tutorials[edit | edit source]

On the Web you can find many mini-tutorials, there are also book chapters, etc.

En français:

5 Specialized topics[edit | edit source]

5.1 Advanced tricks[edit | edit source]

5.2 Emacs programming[edit | edit source]

5.3 (Some) Emacs Modes[edit | edit source]

6 Tools / Software[edit | edit source]

Various emacs versions
Small versions

There are many ....

7 Other Links[edit | edit source]