1 #+OPTIONS: toc:nil num:nil
3 * Nameless --- /less is more/
4 *Hide package namespaces in your emacs-lisp code.*
6 Simply put, turn on this minor mode, and the namespace prefix of the
7 package you’re editing will be hidden by a ~:~. Here’s a comparison.
8 The image to the *left* is what you normally see. The image to
9 the *right* has ~nameless-mode~ turned on.\\
10 [[file:example-nameless.png]]
14 To use this package add the following configuration to your Emacs init file.
16 #+BEGIN_SRC emacs-lisp
17 (add-hook 'emacs-lisp-mode-hook #'nameless-mode-from-hook)
20 You can configure a string to use instead of ~:~ by setting the
21 ~nameless-prefix~, and the name of the face used is ~nameless-face~.
22 You can even just hide the prefix completely by setting this variable
25 While the mode is active, the =C-c C--= key inserts the
26 package namespace if appropriate.
30 ** Quickly typing the namespace
31 ~nameless-mode~ binds the =C-c C--= key to
32 ~nameless-insert-name~, which immediately inserts the current name for
33 you, or even expands aliases to the names they point to.
35 Let’s say you’re in a file called ~foo-bar.el~.
38 fl C-c C-- → font-lock-
41 There’s also a command called ~nameless-insert-name-or-self-insert~.
42 You can bind this to the =_= key and make it even faster to
44 ** Configuring the namespace name
45 Nameless guesses the package name with the ~lm-get-package-name~
46 function, but sometimes this might not match the name you want to use.
48 In these situations, simply set ~nameless-current-name~ as file-local variable.
49 To do that, invoke the following command:
51 M-x add-file-local-variable RET nameless-current-name RET "package-name"
53 You can also set the same name for all lisp files in a project by
54 setting dir-local variables with ~M-x add-file-local-variable~.
56 ** Requiring other packages as aliases
57 Nameless can also be used to “import” other packages as aliases. For
58 instance, in the default behaviour, functions in the ~font-lock~
59 package (e.g., ~font-lock-add-keywords~) will be displayed with the
60 ~fl:~ prefix (e.g., ~fl:add-keywords~).
62 You can configure your own aliases globally with ~nameless-global-aliases~.
63 #+BEGIN_SRC emacs-lisp
64 (setq nameless-global-aliases '(("fl" . "font-lock")
71 You can also configure aliases per-file by setting ~nameless-aliases~
72 as a file-local variable.
73 #+BEGIN_SRC emacs-lisp
75 ;; nameless-aliases: (("c" . "cider"))
78 Note that there’s no ~quote~ before ~((c~!\\
79 You can also configure it for a whole project, by setting it as a dir-local variable.
83 Private symbols in elisp are written with an extra dash after the
84 prefix (e.g., ~foobar--indent-impl~). With Nameless, these are usually
85 displayed as ~:-indent-impl~, but you can also make them be displayed
86 as ~::indent-impl~ by setting
88 #+BEGIN_SRC emacs-lisp
89 (setq nameless-private-prefix t)
92 ** Indentation and paragraph filling
93 Hiding parts of symbols could affect the way Emacs indents your code
94 and fills your paragraphs. Nameless lets you decide whether you want
95 that to happen or not.
97 The default behavior is that code is indented according to what you
98 see (i.e., according to short symbols), but text inside strings is
99 *not*. So text inside strings will be filled in the same way as if you
100 didn’t have ~nameless-mode~. Here’s how a docstring might be filled
101 with ~nameless-mode~ enabled:
103 If point is immediately after an alias configured in the name you
104 had in `:aliases' or `:global-aliases', replace
105 it with the full name for that alias.
107 Altough it may look strange that the second line is so short, that’s
108 the correct way. When view on a ~*Help*~ buffer, that docstring will
111 If point is immediately after an alias configured in the name you
112 had in `nameless-aliases' or `nameless-global-aliases', replace
113 it with the full name for that alias.
116 To change this behavior, configure the variable
117 ~nameless-affect-indentation-and-filling~.