emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A short defense of shorthands.el (but CL packages are still better)


From: Richard Stallman
Subject: Re: A short defense of shorthands.el (but CL packages are still better) (Was: Help sought understanding shorthands wrt modules/packages)
Date: Thu, 03 Nov 2022 23:28:27 -0400

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

Does shorthands break grep?  Let's look at a few cases.

* The case you brought up.

    > (defvar x--bar 42)
    > (defun x-foo () x--bar)
    > (provide 'x)
    > ;; x.el ends here
    > ;; Local Variables:
    > ;; read-symbol-shorthands: (("x-" . "xenomorph-"))
    > ;; End:

    > Its user file yummy.el

    > (require 'x)
    > (defun yummy () (x-foo))
    > ;; yummy.el ends here
    > ;; Local Variables:
    > ;; read-symbol-shorthands: (("x-" . "xenomorph-"))
    > ;; End:

If that's what files x.el and yummy.el contain, 
I don't think anyone will grep for `xenomorph-foo'.
The code in yummy.el actually says `x-foo', so that
is what someone will grep for, and grep will find that in x.el.
So I don't think this case causes any problem with grep.

* A user program foo.el requires strings.el.

Consider strings.el and s.el, strings.el defines strings- aliases for
the functions in s.el by loading s.el with a renaming.

foo.el should call functions named `strings-foo', etc.,
But strings.el does not explicitly contain those names.
So grep will work properly on foo.el
but fail on strings.el but not on foo.el.

We can fix that by adding to strings.el
text such as

    (ignore ;;This is for grep to find.  The definitions are in s.el.
    (defun strings-foo ())
    )

so that grep will find those function names there, and the user
will see to look in s.el for the definitions.

* Something like what CL packages do.

Suppose you want a file foo.el to refer to functions in the frob "package"
while eliding its name prefix, `frob:'.  For instance, `activate' in foo.el
would stand for `frob:activate'.

foo.el can have a shorthand to rename `activate' to `frob:activate'.
If you grep for `activate', grep will find uses of it in foo.el,
but also that renaming in foo.el.

This case does not pose a problem for grep.  When you see the
renaming of `activate' to `frob:activate' in foo.el, you will grep
for `frob:activate' and find that in the frob "package".

This does the same job as CL packages except that it avoids
heuristics and search paths.  Renamings are specified explicitly
rather than found due to the existence or nonexistence of
certain symbols in various packages.



-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]