emacs-devel
[Top][All Lists]
Advanced

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

Re: A read-based grep-like for symbols (el-search?) (was Do shorthands b


From: Gregory Heytings
Subject: Re: A read-based grep-like for symbols (el-search?) (was Do shorthands break basic tooling (tags, grep, etc)? (was Re: Shorthands have landed on master))
Date: Sat, 02 Oct 2021 15:01:59 +0000



Then WTFG, watch the fine gif? Can you find out in the top message? Hope you can. The answer is there in front of your eyes. Watch it well. This constant email flood a true DOS so I'm sorry I can't be your personal tutor on the matter here.


I'm certainly not asking for a tutor, no, and no, the answer is not "in front of my eyes". Because your "fine gif" doesn't show what "magnars-string" is. I'm going to assume that it's the "s.el" library, at the end of which you added the following local variable:

;; elisp-shorthands: (("s-" . "magnars-string-"))

and in which you replaced (provide 's) by (provide 'magnars-string).

Now, I agree with you what you said in an earlier post: "Language design never has been held back by the particular assumptions of a search tool, popular and ubiquitous as it may be." To which I would add that language design should not be influenced by particular choices of libraries, popular and ubiquitous as they may be.

A handful Elisp libraries have decided (for good reasons, but against the common practice so far) to use a short prefix for their functions. That doesn't seem a sufficient reason to design namespaces in Elisp in such a way that these particular libraries need to be changed as little as possible. (And they have to be changed more than you apparently think: if I do the above and do C-h f magnars-string-presence RET, the docstring says "Return S if it's `s-present?', otherwise return nil.". Of course `s-present?' is not considered as a symbol in the *Help* buffer, and C-h o s-present? RET does not work.)

If supporting these few libraries is a requirement, a better approach would be to introduce a particular and temporary exception for them, something like:

diff --git a/src/lread.c b/src/lread.c
index af0a799459..44e94b9604 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -4657,6 +4657,10 @@ oblookup_considering_shorthand (Lisp_Object obarray, const char *in,
       Lisp_Object lh_prefix = XCDR (pair);
       if (!STRINGP (sh_prefix) || !STRINGP (lh_prefix))
        continue;
+      if (strlen (SSDATA (sh_prefix)) < 3)
+       sh_prefix = concat2 (sh_prefix, build_string ("-"));
+      else
+       sh_prefix = concat2 (sh_prefix, build_string ("::"));
       ptrdiff_t sh_prefix_size = SBYTES (sh_prefix);

       /* Compare the prefix of the transformation pair to the symbol

Such short prefixes would raise a warning in Emacs 30, and an error in Emacs 32.



reply via email to

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