Emacs Tips

Optionally Requiring Modules

Modules can be optionally required in your .emacs file by adding a third paramter of true. e.g.

(require 'json-mode nil t)


-- Frank Dean - 5 Jan 2016

Line Wrap

M-x visual-line-mode

Seems to be equivalent to:

(setq word-wrap t) (setq visual-line-indicators (quote (nil nil))

See also:

Controlling Window Splitting

(setq split-height-threshold nil) (setq split-width-threshold 0)

e.g. Disable vertical splitting by (setq split-width-threshold 999)

Character Encoding

To change the character encoding for the current buffer, enter the following M-x command:


Tab completion works for this command's options, so e.g. type 'utf-8' then hitting tab shows all the file encoding options beginning with 'utf-8'.


JavaScript Mode

Using the Js2Mode mode:

(setq js-indent-level 2)


Change Default Dictionary

Emacs uses the ispell package. On a Debian system:

# apt-get install ispell iamerican wamerican ibritish wbritish
# dpkg-reconfigure dictionaries-common

Within a session, M-x ispell-change-dictionary - Press SPC to see a list of installed dictionaries

Using Hunspell

Install Hunspell and your required dictionaries.

Use customize-variable to set ispell-program-name to "/opt/local/bin/hunspell" or add (setq ispell-program-name "/opt/local/bin/hunspell") to your ~/.emacs file.

On some operating systems, you may also need to set the DICTIONARY environment variable in your .emacs file, e.g. (setenv "DICTIONARY" "en_GB")

Inserting Control Characters

To insert a control character such as ^L (Form Feed), type C-q then the actual character (using the CTRL key).

Emacs Manual (Debian)

The Debian distribution doesn't include the manual in the main distribution section. It can be installed from the non-free section package named emacs23-common-non-dfsg, emacs24-common-non-dfsg, etc.

See http://www.debian.org/vote/2006/vote_001 for an explanation of why the Emacs manual is not considered free.

-- Frank Dean - 10 Aug 2009

Useful Emacs Add-Ons

Debian Packages

  • emacs-goodies-el which includes Markdown-mode
  • python-mode
  • magit
  • php-elisp


See "How to enter ssh passphrase when pushing remote branches" re using Magit with SSH.

Web Browser

The web browser settings can be modified by customizing the browse-url-browser-function variable. It can be found under Options->Customize Emacs->Browse Customization Groups then under Emacs->Hypermedia->Browse URL group.

Alternatively, enter the command:

customize-group browse-url


customize-variable browse-url-browser-function

Setting browse-url-browser-function to browse-url-default-browser uses the system default browser.

Using Emacs within Firefox

Install the MozEX Firefox extension.

There is also a fork of Mozex and can also be donwloaded from mac.softpedia.com

-- Frank Dean - 28 Jan 2012

A recent add-on for Firefox (and other browsers) is It's All Text!.

-- Frank Dean - 21 Jan 2016

Using Emacs with Windows

Using Emacs with X

Window size and position

Set the geometry from the command line:

$ emacs -g 80x40
$ emacs -g 80x40+0+0

Add it to your ~/.XResources file (name may differ by distribution).

$ cat <<EOF >> ~/.XResources
emacs23*Geometry: 80x40-0+0
$ xrdb -merge ~/.Xresources

See also Xresources or Xdefaults

Collaborative Editing

One way:

    M-x make-frame-on-display <RET> display <RET>

See GNU Emacs Manual - Multiple-Displays

-- Frank Dean - 13 Mar 2010


Since Emacs 23, Rmail uses the standard Unix inbox (mbox) format internally. Rmail prior to that can be exported to inbox format with M-x unrmail.

Handling Attachments

Rmail Mime is now part of Emacs (Emacs 23?). To view the Mime parts, press 'v' when viewing a message. Attachments will be listed and can saved by pressing RET with point on the attachment.

-- Frank Dean - 6 Nov 2011

Unicode Input

    M-x ucs-insert


Other Emacs Flavours

Info Mode

  • http://www.emacswiki.org/emacs/InfoPath

Adding Items to Emacs Info Directory

Modify the ./emacs/info/dir file

  • http://www.gnu.org/software/texinfo/manual/info/info.html#Add

-- Frank Dean - 09 Nov 2013

Emacs Package Repository

See https://www.emacswiki.org/emacs/MELPA for more information.

List MELPA packages

M-x package-list-packages

Press 'i' to mark a package for installatin, 'U' to mark upgradeable packages, then 'x' to execute the installs and deletions. See MELPA Getting Started.

Ctrl-S Not Working


This is screen treating it as XOFF. Disable it in screen with C-a :flow off

-- Frank Dean - 31 Jan 2009

Related Topics: EmacsCCMode, FirefoxTips, LaTeX, Markdown, XmlTips