all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefankangas@gmail.com>
To: "João Távora" <joaotavora@gmail.com>, emacs-devel@gnu.org
Cc: Adam Porter <adam@alphapapa.net>
Subject: Better way to require with shorthands/renamed symbols
Date: Mon, 27 Sep 2021 04:10:49 -0700	[thread overview]
Message-ID: <CADwFkmmjVLHR9U-PjHFYjQ1=ryOLQDrHfxwSNEmVBJAJ9STXcg@mail.gmail.com> (raw)
In-Reply-To: <20210927003205.EF26620A5E@vcs0.savannah.gnu.org>

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



       reply	other threads:[~2021-09-27 11:10 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210927003203.15806.29864@vcs0.savannah.gnu.org>
     [not found] ` <20210927003205.EF26620A5E@vcs0.savannah.gnu.org>
2021-09-27 11:10   ` Stefan Kangas [this message]
2021-09-27 11:58     ` Better way to require with shorthands/renamed symbols Dmitry Gutov
2021-09-27 12:54       ` Shorthands have landed on master (Was: Better way to require with shorthands/renamed symbols) João Távora
2021-09-27 13:06         ` Dmitry Gutov
2021-09-27 22:40         ` Shorthands have landed on master Philip Kaludercic
2021-09-27 22:58           ` João Távora
2021-09-28  7:15             ` Philip Kaludercic
2021-09-28  9:03               ` João Távora
2021-09-28  9:14                 ` Eli Zaretskii
2021-09-28  9:17                   ` João Távora
2021-09-28  9:22                 ` Philip Kaludercic
2021-09-28 23:37         ` Shorthands have landed on master (Was: Better way to require with shorthands/renamed symbols) Richard Stallman
2021-09-27 12:24     ` Better way to require with shorthands/renamed symbols João Távora
2021-09-27 12:55       ` Dmitry Gutov
2021-09-27 13:09         ` João Távora
2021-09-27 15:05           ` Stefan Kangas
2021-09-27 16:59             ` João Távora
2021-09-27 20:12               ` Stefan Kangas
2021-09-27 20:18                 ` João Távora
2021-09-28  1:53                   ` T.V Raman
2021-09-30  6:04                     ` Richard Stallman
2021-09-28  4:01                 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmmjVLHR9U-PjHFYjQ1=ryOLQDrHfxwSNEmVBJAJ9STXcg@mail.gmail.com' \
    --to=stefankangas@gmail.com \
    --cc=adam@alphapapa.net \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.