From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.devel Subject: Better way to require with shorthands/renamed symbols Date: Mon, 27 Sep 2021 04:10:49 -0700 Message-ID: References: <20210927003203.15806.29864@vcs0.savannah.gnu.org> <20210927003205.EF26620A5E@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15756"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Adam Porter To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 27 13:14:27 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mUoaX-0003rK-TO for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Sep 2021 13:14:25 +0200 Original-Received: from localhost ([::1]:54574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUoaV-0001s5-SW for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Sep 2021 07:14:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUoZ1-0000Ar-VN for emacs-devel@gnu.org; Mon, 27 Sep 2021 07:12:52 -0400 Original-Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:33766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUoX5-0007OW-JX for emacs-devel@gnu.org; Mon, 27 Sep 2021 07:12:51 -0400 Original-Received: by mail-pf1-x42b.google.com with SMTP id s16so15573720pfk.0 for ; Mon, 27 Sep 2021 04:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:in-reply-to:references:mime-version:date:message-id:subject:to :cc:content-transfer-encoding; bh=jNQ31P9xmrH5b6AF+CaaEcLo8aJ5pZeTGRu8uQTWbJQ=; b=qF9YezdXaL+oURLjWp+lk+RUlNErHgmZSU++ygFKSyhOQWWx2UQBzWsD5+r1XWt4Fh MSKB+n7xHx2I93ArlbejAOtscgoedv9eFUv6gizfABgrA0Fb8CP3UVL1MBTc054+JkUg l9CsVaFA+DYJwTWqt/MhNgX325Dlylzcazg/Ub2xf8iBoqHrCRb930htPU7F7ZgZ5QdG 6G4N54dvt021mCuUQczpTl/e+azAg+VWJgwmEER2UhbfTSQqX+EVp/3UmbxKcgqN8hg8 WGtBNYt6NqayS+OtKR51K3aqjfFCvYqrdtf4V50LqO6qEFqQ3/FbemUOnB2UFIEgPI41 5J3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc:content-transfer-encoding; bh=jNQ31P9xmrH5b6AF+CaaEcLo8aJ5pZeTGRu8uQTWbJQ=; b=4pFIJQR/p9Rbctx0AnY+98ECEKtuno+r/9XWmTUOlT8qhyYhpDtywG/K0Hho0SiWiF CNaiNkRl9oE0OWEiaEPhjc7cla/0RJU/sNPoiE8rSSoAcOfrYpsk+wqb1/5SsrEKbb7r G9Y6HrpeMgfql1qZDiYEX/yj+0Yr7jW7NYHxRo0qpnhPllDfHJkcC2Swzx3QHOrN+UIj JnlDeuULO5XW2Vk5/TtZUkyeNx0BOmx4B21hSzB5WAtxW7Mftikp0AvKF1T2PrqPaBie H3AslwyX3TsNCxf5pAhMoY050MvizYf4yn1olCExwVwiqZdqfyNLzVc5dWhZB3+jxnNA T1DQ== X-Gm-Message-State: AOAM5320GCVURIqCIBMtwfiXUNY943nVc5P/f6jGzDO8M28QweLp11Rd V2IWu2ANbkZ6B7Khn49skLgERt6edFqzt+dB+k8= X-Google-Smtp-Source: ABdhPJxeMGzNEOEmWI8rEFW44Q92Zbfw3fzmVc/PsM4TAfIB3dT7x4SvrO0yIqHNrbYUiajtzBNCXhixVLPBcmXsRHI= X-Received: by 2002:a63:6941:: with SMTP id e62mr16074819pgc.114.1632741050237; Mon, 27 Sep 2021 04:10:50 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 27 Sep 2021 04:10:49 -0700 In-Reply-To: <20210927003205.EF26620A5E@vcs0.savannah.gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=stefankangas@gmail.com; helo=mail-pf1-x42b.google.com X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:275569 Archived-At: joaotavora@gmail.com (Jo=C3=A3o T=C3=A1vora) 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