• Stars
    star
    249
  • Rank 162,987 (Top 4 %)
  • Language
    Emacs Lisp
  • Created over 10 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Namespace implementation for Emacs-Lisp

Names https://secure.travis-ci.org/Malabarba/names.png?branch=master

Names is designed as a practical, complete, robust, and debuggable tool which writes your namespaces for you.

It is part of Emacs and is available through GNU Elpa, so every Emacs user running at least 24.1 has access to it.

package-example.png
Example usage of Names to namespace an emacs-lisp function.

A Namespace implementation for Emacs-Lisp

The Names package aims to provide an implementation of namespaces in Emacs with four guiding principles:

Practical
Actually useful and easy to grasp.
Complete
Support any macro, function, or special-form available in emacs-lisp, even the ones defined by you or a third party.
Robust
No-surprises, well-tested, and with clearly stated limitations.
Debuggable
Support edebug and eval-defun, and any other package developing tools.

See Why a namespace package? for a description on why this is necessary, and see Other-Packages.org for a description and comparison of previous packages attempting similar things.

Version Compatibility

Currently, Names is being supported on the entire Emacs 24 family (24.1–24.4). Any new changes or pull requests are tested on a Travis-CI machine. See the “tests” subdirectory for our test suite, and see .

Usage

The UsageExample file clearly displays and explains how to use Names in your package. There are few simple measures to take. Go have a look if you’re interested, I promise it’s worth it!

If you want deeper descriptions of use-cases, see TheNittyGritty.org.

Developer Tools

Names offers a series of tools to make package writing more convenient inside a namespace. These developer facilities are on this separate file, so the file isn’t loaded on the user’s computer when your package calls (require 'names).

To access them add the following line to your init file.

(require 'names-dev)

Edebug and eval-defun support

First and foremost, the edebug-eval-defun command (bound to C-u C-M-x) is an essential tool for any package developer. Names wouldn’t be a very useful utility if it prevented you from using this asset.

Therefore, it provides the names-eval-defun command, which is identical to edebug-eval-defun except it also works inside namespaces. It will automatically be added to your emacs-lisp-mode-map.

Font-locking

Font-lock for define-namespace and :autoload.

Expansion and comparison functions

names-compare-forms and names-print offer information when something just doesn’t seem to make sense.

Nomenclature

The name of this package is Names, always with a capital “N”. Despite the word being plural, refer to it in the singular (e.g., “Names is an amazing achievement”). If possible consider giving it a slight emphasis, such as: Names. When there’s a risk of confusion or ambiguity, be it due to context or lack of knowledge by the reader, names.el is also acceptable.

Why a namespace package?

Plain and simple: Emacs doesn’t have namespaces, and it needs them.

Nic Ferrier has a great essay on the subject, and you might want to read an opposing opinion as well. Note that Names is very different from the solution he proposes, but it does solve the problem he had with other alternatives which left the debugger unusable.

Emacs takes the approach of prefixing every symbol name with the name of the package. This successfully avoids name clashes between packages, but it quickly leads to code that’s repetitive and annoying to write. Below is an example from package.el, the word ”package” is repeated 7 times in a 10-line function.

Names doesn’t change this overall approach. It adheres to Emacs standards and is completely invisible to the end-user. Names simply gives you (the developer) a convenient way of writing code that adheres to this standard.

package-example.png Example usage of Names to namespace an emacs-lisp function.

  • At runtime, the right-hand-side will create the same definitions as the left-hand-side.
  • At compilation, it will create the exact same compiled file (with no left-over reference to names.el functions).

Tested On:

Below are the packages on which I’ve tested Names. If you’re interested, try using it on one of your packages and let me know how it goes.

elnode

  • Number of ert tests passed: Same as before namespacing (62).
  • Reduction in code size: Approx. 2000 characters.

s.el

  • Number of ert tests passed: All.
  • Reduction in code size: Approx. 1000 characters (8%).

1000 characters is a lot when you consider s.el has the second shortest namespace possible, s-.

dash.el

  • Number of ert tests passed: Same as before namespacing (104).

latex-extra

  • Number of ert tests passed: ALL.

More Repositories

1

smart-mode-line

A powerful and beautiful mode-line for Emacs.
Emacs Lisp
895
star
2

aggressive-indent-mode

Emacs minor mode that keeps your code always indented. More reliable than electric-indent-mode.
Emacs Lisp
850
star
3

beacon

A light that follows your cursor around so you don't lose it!
Emacs Lisp
657
star
4

paradox

Project for modernizing Emacs' Package Menu. With package ratings, usage statistics, customizability, and more.
Emacs Lisp
561
star
5

elisp-bug-hunter

Hunt down errors in elisp files.
Emacs Lisp
271
star
6

emacs-google-this

A set of emacs functions and bindings to google under point.
Emacs Lisp
264
star
7

Nameless

Less is more. Hide package namespace in your emacs-lisp code
Emacs Lisp
134
star
8

fancy-narrow

Emacs package to immitate narrow-to-region with more eye-candy
Emacs Lisp
129
star
9

rich-minority

Emacs package for hiding and/or highlighting the list of minor-modes in the mode-line.
Emacs Lisp
108
star
10

camcorder.el

Tool for capturing screencasts directly from Emacs.
Emacs Lisp
108
star
11

spinner.el

Emacs mode-line spinner for operations in progress
Emacs Lisp
104
star
12

speed-of-thought-lisp

Write elisp at the speed of thought. Emacs minor mode with abbrevs and keybinds.
Emacs Lisp
73
star
13

latex-extra

A series of usability improvements for Emacs latex-mode.
Emacs Lisp
69
star
14

org-agenda-property

Display org properties in the agenda buffer.
Emacs Lisp
65
star
15

gmail-mode

A major-mode for editing gmail messages using markdown syntax (in emacs).
Emacs Lisp
57
star
16

lazy-map-clojure

Create Clojure maps whose values are only calculated when accessed, either from data or from java objects.
Clojure
49
star
17

ham-mode

Html As Markdown. Transparently edit an html file using markdown.
Emacs Lisp
42
star
18

control-pianobar

Pair of scripts that interact with pianobar entirely through notification bubbles and hotkeys. No terminal necessary.
Shell
35
star
19

ox-jekyll-subtree

Extension to ox-jexkyll for better export of subtrees
Emacs Lisp
30
star
20

audio-notes-mode

Emacs mode to play audio notes synced from somewhere else.
Emacs Lisp
26
star
21

speed-of-thought-clojure

Write clojure at the speed of thought.
Emacs Lisp
23
star
22

validate.el

Schema validator for Emacs-lisp
Emacs Lisp
23
star
23

emacs-online-documentation

A project meant to keep an updated online documentation of ALL emacs' built-in functions and variables.
Emacs Lisp
22
star
24

html-to-markdown

HTML to Markdown converter written in emacs-lisp.
Emacs Lisp
17
star
25

alpine-osd-notify

Script to run alpine mail client using a notify-osd notification system.
Shell
17
star
26

conkeror-minor-mode

Mode for editing conkeror javascript files.
Emacs Lisp
17
star
27

emacs-archive-tracker

A script in emacs-lisp to track some statistics about emacs package archives.
Emacs Lisp
14
star
28

comment-or-uncomment-sexp

Emacs-lisp command for inteligently commenting and commenting the sexp under point.
Emacs Lisp
9
star
29

org-bibtex

Simple example of combining a .bib file with org-mode.
8
star
30

emacs-documentation-android

Emacs Documentation android app. Search emacs variables/functions and view their documentations on android.
Java
5
star
31

HugeSQLiteCursor

A version of SQLiteCursor which remains fast even when the cursor is arbitrarily large.
Java
4
star
32

EndlessParentheses

Endless Parentheses blog. See http://endlessparentheses.com
HTML
4
star
33

lisp-assistant

A set of functions, variables, and snippets to assist in developing lisp code.
Emacs Lisp
3
star
34

threads-list-mode

tabulated-list-mode specialized at viewing threads
Emacs Lisp
3
star
35

Keystone

Play Hearthstone with the keyboard.
AutoHotkey
2
star
36

Zumi

Rails WebApp for apartment listings
Ruby
2
star
37

hdh

Ruby gem for rendering plain data into HTML
Ruby
2
star
38

Zumi-front

Frontend for https://github.com/Malabarba/Zumi
Vue
1
star
39

display-keys-emacs

Popup that displays keys pressed for certain commands
Emacs Lisp
1
star
40

greek-unicode-insert

Simple keymap to insert Unicode Greek characters in emacs.
Emacs Lisp
1
star