Malabarba / names

A Namespace implementation for Emacs-Lisp
250 stars 19 forks source link

Manually rewriting files is boring and error-prone #9

Open DamienCassou opened 9 years ago

DamienCassou commented 9 years ago

When trying to use names, removing all the prefixes manually is boring, even in Emacs. This can't be done automatically (e.g., with a non-interactive search/replace) because:

  1. references to functions and variables in docstrings must not be changed
  2. it is easy for a call to a global function (e.g., emacs lisp length function) to become a call to a local function (e.g., when removing the prefix of mypackage-length):
(defun mypackage-length (foo)
  (length foo))

will easily be replaced by this non-working code:

(defun length (foo)
  (length foo)) ;; <-- should have been ::length instead
Malabarba commented 9 years ago

At the moment, names is more adequate for new packages than existing ones. I would love to offer a feature like the one you suggest, unfortunately it's also quite a challenge.

My guess is that something like this will have to make use of the code-walker. A simple replace-regexp won't do.