• Stars
    star
    134
  • Rank 270,312 (Top 6 %)
  • Language
    Emacs Lisp
  • License
    GNU General Publi...
  • Created about 9 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

Less is more. Hide package namespace in your emacs-lisp code

Nameless — less is more

Hide package namespaces in your emacs-lisp code.

Simply put, turn on this minor mode, and the namespace prefix of the package you’re editing will be hidden by a :. Here’s a comparison. The image to the left is what you normally see. The image to the right has nameless-mode turned on.
example-nameless.png

Usage

To use this package add the following configuration to your Emacs init file.

(add-hook 'emacs-lisp-mode-hook #'nameless-mode)

You can configure a string to use instead of : by setting the nameless-prefix, and the name of the face used is nameless-face. You can even just hide the prefix completely by setting this variable to an empty string.

While the mode is active, the C-c C-- key inserts the package namespace if appropriate.

Configuration

Quickly typing the namespace

nameless-mode binds the C-c C-- key to nameless-insert-name, which immediately inserts the current name for you, or even expands aliases to the names they point to.

Let’s say you’re in a file called foo-bar.el.

   C-c C-- → foo-bar-
fl C-c C-- → font-lock-

There’s also a command called nameless-insert-name-or-self-insert. You can bind this to the _ key and make it even faster to insert the name.

Configuring the namespace name

Nameless guesses the package name with the lm-get-package-name function, but sometimes this might not match the name you want to use.

In these situations, simply set nameless-current-name as file-local variable. To do that, invoke the following command:

M-x add-file-local-variable RET nameless-current-name RET "package-name"

You can also set the same name for all lisp files in a project by setting dir-local variables with:

M-x add-dir-local-variable RET emacs-lisp-mode RET nameless-current-name RET "package-name"

If you don’t want Nameless to use a namespace name at all (neither manual nor automatic), you can set nameless-discover-current-name to nil. This will disable this functionality, so that Nameless will only use aliases (see next item).

Requiring other packages as aliases

Nameless can also be used to “import” other packages as aliases. For instance, in the default behaviour, functions in the font-lock package (e.g., font-lock-add-keywords) will be displayed with the fl: prefix (e.g., fl:add-keywords).

You can configure your own aliases globally with nameless-global-aliases.

(setq nameless-global-aliases '(("fl" . "font-lock")
                                ("s" . "seq")
                                ("me" . "macroexp")
                                ("c" . "cider")
                                ("q" . "queue")))

You can also configure aliases per-file by setting nameless-aliases as a file-local variable.

;; Local Variables:
;; nameless-aliases: (("c" . "cider"))
;; End:

Note that there’s no quote before ((c!
You can also configure it for a whole project, by setting it as a dir-local variable.

Private symbols

Private symbols in elisp are written with an extra dash after the prefix (e.g., foobar--indent-impl). With Nameless, these are usually displayed as :-indent-impl, but you can also make them be displayed as ::indent-impl by setting

(setq nameless-private-prefix t)

Packages that don’t use - (hyphen) as a separator

You can set nameless-separator file-locally to whatever separator you package uses. Most packages use hyphens, but some use /, |, or :.

You can also set it to nil globally and the separator will never be hidden, and will not be inserted with `-name-insert-` functions.

Indentation and paragraph filling

Hiding parts of symbols could affect the way Emacs indents your code and fills your paragraphs. Nameless lets you decide whether you want that to happen or not.

The default behavior is that code is indented according to what you see (i.e., according to short symbols), but text inside strings is not. So text inside strings will be filled in the same way as if you didn’t have nameless-mode. Here’s how a docstring might be filled with nameless-mode enabled:

If point is immediately after an alias configured in the name you
had in `:aliases' or `:global-aliases', replace
it with the full name for that alias.

Altough it may look strange that the second line is so short, that’s the correct way. When viewed in a *Help* buffer, that docstring will look like this:

If point is immediately after an alias configured in the name you
had in `nameless-aliases' or `nameless-global-aliases', replace
it with the full name for that alias.

To change this behavior, configure the variable nameless-affect-indentation-and-filling.

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

names

A Namespace implementation for Emacs-Lisp
Emacs Lisp
249
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