[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Better way to require with shorthands/renamed symbols
From: |
Stefan Kangas |
Subject: |
Better way to require with shorthands/renamed symbols |
Date: |
Mon, 27 Sep 2021 04:10:49 -0700 |
joaotavora@gmail.com (João Távora) writes:
> +(defun t-reverse-lines (s) (string-join (reverse (sns-lines s)) "\n")
> +
> +;; Local Variables:
> +;; elisp-shorthands: (("t-" . "my-tricks-")
> +;; ("sns-" . "some-nice-string-utils-"))
> +;; End:
This is really nice and straight-forward, thanks!
I see one problem here. It basically splits the require up in two:
I need to look both at the start and at the end of the file to
understand what is going on.
In the previous discussion, Adam Porter suggested this:[1]
(shorthand-require 'magnar-string :with "^s-" :as "magnar-string-")
I like that proposal a lot, but it's a bit too verbose for my taste.
It also seems to flip the :as and :with from what I would expect (in
Python, "import x as y" means that x is available "as" y in this file).
In my ideal world, we should be able to just say simply:
(require 'magnar-string :as "s-")
There could be a variable inside magnar-string.el that gives us the
rest, e.g.:
elisp-default-import-prefix: "^magnar-string-"
WDYT?
Footnotes:
[1] https://lists.gnu.org/r/emacs-devel/2020-05/msg01754.html
- Better way to require with shorthands/renamed symbols,
Stefan Kangas <=
- Re: Better way to require with shorthands/renamed symbols, Dmitry Gutov, 2021/09/27
- Shorthands have landed on master (Was: Better way to require with shorthands/renamed symbols), João Távora, 2021/09/27
- Re: Shorthands have landed on master (Was: Better way to require with shorthands/renamed symbols), Dmitry Gutov, 2021/09/27
- Re: Shorthands have landed on master, Philip Kaludercic, 2021/09/27
- Re: Shorthands have landed on master, João Távora, 2021/09/27
- Re: Shorthands have landed on master, Philip Kaludercic, 2021/09/28
- Re: Shorthands have landed on master, João Távora, 2021/09/28
- Re: Shorthands have landed on master, Eli Zaretskii, 2021/09/28
- Re: Shorthands have landed on master, João Távora, 2021/09/28
- Re: Shorthands have landed on master, Philip Kaludercic, 2021/09/28