unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Better way to require with shorthands/renamed symbols
       [not found] ` <20210927003205.EF26620A5E@vcs0.savannah.gnu.org>
@ 2021-09-27 11:10   ` Stefan Kangas
  2021-09-27 11:58     ` Dmitry Gutov
  2021-09-27 12:24     ` Better way to require with shorthands/renamed symbols João Távora
  0 siblings, 2 replies; 22+ messages in thread
From: Stefan Kangas @ 2021-09-27 11:10 UTC (permalink / raw)
  To: João Távora, emacs-devel; +Cc: Adam Porter

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



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  2021-09-27 11:10   ` Better way to require with shorthands/renamed symbols Stefan Kangas
@ 2021-09-27 11:58     ` 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 12:24     ` Better way to require with shorthands/renamed symbols João Távora
  1 sibling, 1 reply; 22+ messages in thread
From: Dmitry Gutov @ 2021-09-27 11:58 UTC (permalink / raw)
  To: Stefan Kangas, João Távora, emacs-devel; +Cc: Adam Porter

On 27.09.2021 14:10, Stefan Kangas wrote:
> In my ideal world, we should be able to just say simply:
> 
>      (require 'magnar-string :as "s-")

This would be much nicer, yes.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  2021-09-27 11:10   ` Better way to require with shorthands/renamed symbols Stefan Kangas
  2021-09-27 11:58     ` Dmitry Gutov
@ 2021-09-27 12:24     ` João Távora
  2021-09-27 12:55       ` Dmitry Gutov
  1 sibling, 1 reply; 22+ messages in thread
From: João Távora @ 2021-09-27 12:24 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Adam Porter, emacs-devel

Stefan Kangas <stefankangas@gmail.com> writes:

> 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-")
>

I wrote before that something like is reasonable and sounds useful.  But
I was rash in that assessment.  Or rather, it must be very clearly
thought out.

One should understand (or perhaps, as a programmer, one _must_
understand) that the Shorthands feature works at the Lisp reader level.

It's tricky to think about the execution of that manifestation of the
'require' special and what it does at the Shorthands level.  You're
probably thinking of putting it on the top of your file, which is the
most common case, but far from the only use.  What if it happens at
non-top level, in an IF form?  What if it happen sat top level but in
the middle of the file?  It would amount to setting variables that
influence the reader during the read process.

Of course, that is exactly what Common Lisp's IN-PACKAGE does.  But that
comes with other challenges, prominent among which teaching tools like
xref, ElDoc, describe-function and completions what the "current"
shorthands are.  You see, those tools are always finding symbols in the
current buffer and they also need to know the value of
'elisp-shorthands' (soon to be renamed 'read-shorthands', hopefully).

We'd need to update 'elisp-shorthands' whenever point moves perhaps? Or
just-in-time before an 'intern-soft' is called.  That is how SLY and
SLIME do it.  Maybe.  At any rate, this is more work.  Perhaps, when we
arrive at that that point, we decide to put the effort and implement
IN-PACKAGE, since it's so well understood (...but is it? Not by some, I
fear, maybe that'll change).

For now, I'd just like people to experiment with Shorthands.

As Stefan Monnier once wrote (here?), implementing namespace systems
isn't hard in itself (it wasn't here).  It's making the tooling around
it consistent.  The latter was only possible with the Shorthands feature
because of the relative dumbness of its approach.

João





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Shorthands have landed on master (Was: Better way to require with shorthands/renamed symbols)
  2021-09-27 11:58     ` Dmitry Gutov
@ 2021-09-27 12:54       ` João Távora
  2021-09-27 13:06         ` Dmitry Gutov
                           ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: João Távora @ 2021-09-27 12:54 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Adam Porter, Stefan Kangas, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 213 bytes --]

Hello all.

Anyway, as you may have noticed, "Shorthands" have landed on master.
Please check out the NEWS entry and the manual section on "Shorthands".

For the impatient, I leave with with a tiny animated gif.


[-- Attachment #2: shorthand-demo.gif --]
[-- Type: image/gif, Size: 846811 bytes --]

[-- Attachment #3: Type: text/plain, Size: 560 bytes --]


Dmitry Gutov <dgutov@yandex.ru> writes:
> On 27.09.2021 14:10, Stefan Kangas wrote:
>> In my ideal world, we sho  uld be able to just say simply:
>>      (require 'magnar-string :as "s-")
> This would be much nicer, yes.

Unfortunately, that comes with many other implications that you may or
may not be seeing.  I've replied to Stefan in detail.  Anyway, I hope
people can briefly try out the feature as it is now, and report any
bugs, slightly delaying their "much nicer" suggestion (which are more
than expected and very welcome).

João



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  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
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Gutov @ 2021-09-27 12:55 UTC (permalink / raw)
  To: João Távora, Stefan Kangas; +Cc: Adam Porter, emacs-devel

On 27.09.2021 15:24, João Távora wrote:

> One should understand (or perhaps, as a programmer, one _must_
> understand) that the Shorthands feature works at the Lisp reader level.
> 
> It's tricky to think about the execution of that manifestation of the
> 'require' special and what it does at the Shorthands level.  You're
> probably thinking of putting it on the top of your file, which is the
> most common case, but far from the only use.  What if it happens at
> non-top level, in an IF form?  What if it happen sat top level but in
> the middle of the file?  It would amount to setting variables that
> influence the reader during the read process.

I think the key part is for this info to reside somewhere near the top 
of the file (if not in the require form, then above it, maybe).

> As Stefan Monnier once wrote (here?), implementing namespace systems
> isn't hard in itself (it wasn't here).  It's making the tooling around
> it consistent.  The latter was only possible with the Shorthands feature
> because of the relative dumbness of its approach.

BTW, it seems the new feature will need dedicated support in 
xref-backend-references as well.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Shorthands have landed on master (Was: Better way to require with shorthands/renamed symbols)
  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-28 23:37         ` Shorthands have landed on master (Was: Better way to require with shorthands/renamed symbols) Richard Stallman
  2 siblings, 0 replies; 22+ messages in thread
From: Dmitry Gutov @ 2021-09-27 13:06 UTC (permalink / raw)
  To: João Távora; +Cc: Adam Porter, Stefan Kangas, emacs-devel

On 27.09.2021 15:54, João Távora wrote:
> Anyway, I hope
> people can briefly try out the feature as it is now, and report any
> bugs, slightly delaying their "much nicer" suggestion (which are more
> than expected and very welcome).

I will, thanks.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  2021-09-27 12:55       ` Dmitry Gutov
@ 2021-09-27 13:09         ` João Távora
  2021-09-27 15:05           ` Stefan Kangas
  0 siblings, 1 reply; 22+ messages in thread
From: João Távora @ 2021-09-27 13:09 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Adam Porter, Stefan Kangas, emacs-devel

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 27.09.2021 15:24, João Távora wrote:
>
>> One should understand (or perhaps, as a programmer, one _must_
>> understand) that the Shorthands feature works at the Lisp reader level.
>> It's tricky to think about the execution of that manifestation of
>> the
>> 'require' special and what it does at the Shorthands level.  You're
>> probably thinking of putting it on the top of your file, which is the
>> most common case, but far from the only use.  What if it happens at
>> non-top level, in an IF form?  What if it happen sat top level but in
>> the middle of the file?  It would amount to setting variables that
>> influence the reader during the read process.
>
> I think the key part is for this info to reside somewhere near the top
> of the file (if not in the require form, then above it, maybe).

OK.  I agree that that is much better from a usability point of view.
And the key part of my position is that currently, we shouldn't try to
make it a part of Lisp code.  Maybe we can somehoe have file-local
variables in other points of the file?

Would that suffice for you and Stefan now?

João



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  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
  0 siblings, 1 reply; 22+ messages in thread
From: Stefan Kangas @ 2021-09-27 15:05 UTC (permalink / raw)
  To: João Távora, Dmitry Gutov; +Cc: Adam Porter, emacs-devel

João Távora <joaotavora@gmail.com> writes:

> [...] Maybe we can somehoe have file-local
> variables in other points of the file?
>
> Would that suffice for you and Stefan now?

Sure, if we can figure out how to do that in a clean way.  Otherwise, we
are probably better off just leaving things as they are, rather than
complicating things just for the sake of it.  Maybe it's already fine as
it is, given the scope of the feature.

I guess most files will not use this, so it should okay if those that
do just add a note "see below" to their requires section.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  2021-09-27 15:05           ` Stefan Kangas
@ 2021-09-27 16:59             ` João Távora
  2021-09-27 20:12               ` Stefan Kangas
  0 siblings, 1 reply; 22+ messages in thread
From: João Távora @ 2021-09-27 16:59 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Adam Porter, emacs-devel, Dmitry Gutov

On Mon, Sep 27, 2021 at 4:05 PM Stefan Kangas <stefankangas@gmail.com> wrote:

> > [...] Maybe we can somehoe have file-local
> > variables in other points of the file?
> > Would that suffice for you and Stefan now?
> Sure, if we can figure out how to do that in a clean way.

I don't think it's particularly hard to do cleanly.  Just think of how
file-local variables are already supported in the first line
of a file.

>  Otherwise, we are probably better off just leaving things as they are,
> rather than complicating things just for the sake of it.

Yes, "for the sake of it" is obviously bad.  But solving particular
problems that are well described is fine with me.  For example, I'd like
to be able to activate shorthands in certain parts of the buffer, just like
one switches to a package in Common Lisp.  But I'm a CL guy and like
packages.

On this topic, it has come to my attention that some people are sore
or frustrated about how this feature has somehow "defeated" their
preferred idea.  I think that doesn't make sense.  If those ideas aren't
happening it is not because of my work.

I hope people come forward and state what it is they would like to do
namespacing-wise in Elisp.  And then help everyone else think if it is
possible to actually implement it without impacting the existing tooling
(too much). Ideally, a prototype of this hypothetical feature be made.

> Maybe it's already fine as  it is, given the scope of the feature.

The Shorthands feature doesn't have any particular "scope", IMO. It
depends on the use you want to give it.  I believe it will be used for
importing `s.el` and `s.el`-dependent libraries into Emacs or *-ELPA
somehow. That's one application.

Personally, I plan on using it in newer Emacs28-only versions of my
packages: i hate typing/reading long prefixes. Maybe a clean Elisp
version can be developed for older Emacsen, I dunno (the first
version I did was Elisp only, but I don't remember if it worked fully
like this one).

João



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  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  4:01                 ` Ihor Radchenko
  0 siblings, 2 replies; 22+ messages in thread
From: Stefan Kangas @ 2021-09-27 20:12 UTC (permalink / raw)
  To: João Távora; +Cc: Adam Porter, emacs-devel, Dmitry Gutov

João Távora <joaotavora@gmail.com> writes:

>>  Otherwise, we are probably better off just leaving things as they are,
>> rather than complicating things just for the sake of it.
>
> Yes, "for the sake of it" is obviously bad.  But solving particular
> problems that are well described is fine with me.

I guess I'm trying to say that it would also be fine to wait until we
have more experience with this.

In any case, I fully trust you will do the right thing with this
feedback.

> On this topic, it has come to my attention that some people are sore
> or frustrated about how this feature has somehow "defeated" their
> preferred idea.  I think that doesn't make sense.  If those ideas aren't
> happening it is not because of my work.

Fully agreed, that makes no sense.

> The Shorthands feature doesn't have any particular "scope", IMO. It
> depends on the use you want to give it.  I believe it will be used for
> importing `s.el` and `s.el`-dependent libraries into Emacs or *-ELPA
> somehow. That's one application.
>
> Personally, I plan on using it in newer Emacs28-only versions of my
> packages: i hate typing/reading long prefixes. Maybe a clean Elisp
> version can be developed for older Emacsen, I dunno (the first
> version I did was Elisp only, but I don't remember if it worked fully
> like this one).

Absolutely, I intend to experiment with it as well.  Currently, I use
the nameless package (and have done for many years), and I'm quite happy
with it.  It basically detects in "my-long-library-name.el" symbols
looking like `my-long-library-name-foo-bar' and hides the package part
so you only see `:foo-bar'.  The text is still there, but it is out of
sight.  Extremely handy, and it works in any package.

It obviously doesn't solve the problem of very short prefix packages
like "s.el", etc.  It's mostly just a very useful hack.

The main drawback though is that you still need to type out the package
name.  So I intend to start experimenting with very short shorthand
prefixes like ":".  It will be interesting to see how useful/usable it
turns out to be.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  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-28  4:01                 ` Ihor Radchenko
  1 sibling, 1 reply; 22+ messages in thread
From: João Távora @ 2021-09-27 20:18 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Adam Porter, emacs-devel, Dmitry Gutov

On Mon, Sep 27, 2021 at 9:12 PM Stefan Kangas <stefankangas@gmail.com> wrote:
>
> João Távora <joaotavora@gmail.com> writes:
>
> >>  Otherwise, we are probably better off just leaving things as they are,
> >> rather than complicating things just for the sake of it.
> >
> > Yes, "for the sake of it" is obviously bad.  But solving particular
> > problems that are well described is fine with me.
>
> I guess I'm trying to say that it would also be fine to wait until we
> have more experience with this.

Yeah, that is exactly what I wish will happen.  For people to try
it and to detect where it solves their problems and where it doesn't.
Not to mention say where it has _created_ problems (i.e. where
it might have introduced bugs).

João



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Shorthands have landed on master
  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         ` Philip Kaludercic
  2021-09-27 22:58           ` João Távora
  2021-09-28 23:37         ` Shorthands have landed on master (Was: Better way to require with shorthands/renamed symbols) Richard Stallman
  2 siblings, 1 reply; 22+ messages in thread
From: Philip Kaludercic @ 2021-09-27 22:40 UTC (permalink / raw)
  To: João Távora
  Cc: Adam Porter, emacs-devel, Stefan Kangas, Dmitry Gutov

João Távora <joaotavora@gmail.com> writes:

> Hello all.
>
> Anyway, as you may have noticed, "Shorthands" have landed on master.
> Please check out the NEWS entry and the manual section on "Shorthands".
>
> For the impatient, I leave with with a tiny animated gif.

From what I see, elisp-shorthands only allows a shorter prefix to be
mapped to a longer prefix, right? So this doesn't allow me to use cl-lib
without the cl- prefix, or remove the compat-- prefix from compatibility
functions?

-- 
	Philip Kaludercic



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Shorthands have landed on master
  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
  0 siblings, 1 reply; 22+ messages in thread
From: João Távora @ 2021-09-27 22:58 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Adam Porter, emacs-devel, Stefan Kangas, Dmitry Gutov

On Mon, Sep 27, 2021 at 11:40 PM Philip Kaludercic <philipk@posteo.net> wrote:
>
> João Távora <joaotavora@gmail.com> writes:
>
> > Hello all.
> >
> > Anyway, as you may have noticed, "Shorthands" have landed on master.
> > Please check out the NEWS entry and the manual section on "Shorthands".
> >
> > For the impatient, I leave with with a tiny animated gif.
>
> From what I see, elisp-shorthands only allows a shorter prefix to be
> mapped to a longer prefix, right? So this doesn't allow me to use cl-lib
> without the cl- prefix,

You need to have _some_ prefix.  It cannot be of 0 length.  Best
you can do is '-loop' and '-destructuring-bind', for example.

In fact, I lie.  You _can_ map 'loop' to 'cl-loop' explicitly.
'loop' is the shorthand.  'cl-loop' is still the symbol.
But you have to do it symbol by symbol.

That's because I've purposely turned off "freer" renamings in
favor of prefixes, simplicity and read speed.  But they are
not impossible.

> or remove the compat-- prefix from compatibility
> functions?

It's too late in the day for me to understand what you mean by
"remove" here :-)  You must first understand what shorthands are:
they are merely file-local aliases to symbols which keep their
full names.

Does this help in answering your question?

If it doesn't, provide a toy example with files and code in it,
and illustrate clearly what you would like to be able to write,
but can't (right now) Then maybe I can say if shorthands can
help you.

João



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  2021-09-27 20:18                 ` João Távora
@ 2021-09-28  1:53                   ` T.V Raman
  2021-09-30  6:04                     ` Richard Stallman
  0 siblings, 1 reply; 22+ messages in thread
From: T.V Raman @ 2021-09-28  1:53 UTC (permalink / raw)
  To: João Távora
  Cc: Stefan Kangas, Adam Porter, emacs-devel, Dmitry Gutov

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 496 bytes --]

This is a suggestion for thinking about *after* we have had some
experience using this:

Consider a prefix separator char like ':' so that the shorthand is
easily distinguishable as a shorthand prefix? Might help in many ways:

1. Indicates to the reader that new: is a shorthand prefix.
   2. Enable refactoring/renaming code to easily change the prefix or
      undo it if desired 
-- 

Thanks,

--Raman(I Search, I Find, I Misplace, I Research)
7©4 Id: kg:/m/0285kf1  •0Ü8



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  2021-09-27 20:12               ` Stefan Kangas
  2021-09-27 20:18                 ` João Távora
@ 2021-09-28  4:01                 ` Ihor Radchenko
  1 sibling, 0 replies; 22+ messages in thread
From: Ihor Radchenko @ 2021-09-28  4:01 UTC (permalink / raw)
  To: Stefan Kangas
  Cc: Adam Porter, Dmitry Gutov, João Távora, emacs-devel

Stefan Kangas <stefankangas@gmail.com> writes:

> The main drawback though is that you still need to type out the package
> name.

You can simply
(bind-key "_" #'nameless-insert-name-or-self-insert nameless-mode-map)

Best,
Ihor



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Shorthands have landed on master
  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
  0 siblings, 1 reply; 22+ messages in thread
From: Philip Kaludercic @ 2021-09-28  7:15 UTC (permalink / raw)
  To: João Távora
  Cc: Adam Porter, Dmitry Gutov, Stefan Kangas, emacs-devel

João Távora <joaotavora@gmail.com> writes:

> On Mon, Sep 27, 2021 at 11:40 PM Philip Kaludercic <philipk@posteo.net> wrote:
>>
>> João Távora <joaotavora@gmail.com> writes:
>>
>> > Hello all.
>> >
>> > Anyway, as you may have noticed, "Shorthands" have landed on master.
>> > Please check out the NEWS entry and the manual section on "Shorthands".
>> >
>> > For the impatient, I leave with with a tiny animated gif.
>>
>> From what I see, elisp-shorthands only allows a shorter prefix to be
>> mapped to a longer prefix, right? So this doesn't allow me to use cl-lib
>> without the cl- prefix,
>
> You need to have _some_ prefix.  It cannot be of 0 length.  Best
> you can do is '-loop' and '-destructuring-bind', for example.
>
> In fact, I lie.  You _can_ map 'loop' to 'cl-loop' explicitly.
> 'loop' is the shorthand.  'cl-loop' is still the symbol.
> But you have to do it symbol by symbol.
>
> That's because I've purposely turned off "freer" renamings in
> favor of prefixes, simplicity and read speed.  But they are
> not impossible.

I see. Do you think it would make sense to use predefined shorthand
groups, in case someone *would* want to use cl-lib without the prefix?

>> or remove the compat-- prefix from compatibility
>> functions?
>
> It's too late in the day for me to understand what you mean by
> "remove" here :-)  You must first understand what shorthands are:
> they are merely file-local aliases to symbols which keep their
> full names.

This was in reference to the compat.el discussion from a few days
ago. It was mentioned that shorthands might provide an alternative to
aliasing function definitions. But this doesn't make much sense, if a
prefix has to be used, short or long: I want to call
(macroexp-file-name), not (co-macroexp-file-name), (~macroexp-file-name)
or (compat--macroexp-file-name) to provide transparent compatibility.

> Does this help in answering your question?

After trying out

     ;; elisp-shorthands: (("" . "cl-"))

I saw what went wrong and I understand why. On that topic, I think the
behaviour was inadequate, because a lot of unrelated commands also
broke that might become annoying.

> If it doesn't, provide a toy example with files and code in it,
> and illustrate clearly what you would like to be able to write,
> but can't (right now) Then maybe I can say if shorthands can
> help you.
>
> João
>
>

-- 
	Philip Kaludercic



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Shorthands have landed on master
  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:22                 ` Philip Kaludercic
  0 siblings, 2 replies; 22+ messages in thread
From: João Távora @ 2021-09-28  9:03 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Adam Porter, Dmitry Gutov, Stefan Kangas, emacs-devel

On Tue, Sep 28, 2021 at 8:15 AM Philip Kaludercic <philipk@posteo.net> wrote:
>
> João Távora <joaotavora@gmail.com> writes:
>
> > On Mon, Sep 27, 2021 at 11:40 PM Philip Kaludercic <philipk@posteo.net> wrote:

> I see. Do you think it would make sense to use predefined shorthand
> groups, in case someone *would* want to use cl-lib without the prefix?

Yes, I do think that makes sense.

...meaning that drawbacks aren't immediately visible to me right now :-)

Since elisp-shorthands is a file-local variable, I think it allows (eval)
specs.  Perhaps you can try with that, for now? I don't think it'd be
hard to add better support for such predefined groups of shorthands.

> This was in reference to the compat.el discussion from a few days
> ago. It was mentioned that shorthands might provide an alternative to
> aliasing function definitions. But this doesn't make much sense, if a
> prefix has to be used, short or long: I want to call
> (macroexp-file-name), not (co-macroexp-file-name), (~macroexp-file-name)
> or (compat--macroexp-file-name) to provide transparent compatibility.

If I understand this right, then I think you may solve it similarly to the
cl- situation.

But you understand that, for the moment, shorthands are only supported in
Emacs 28, right?  Not sure where (in which versions) the library you're
intending to write would be loaded.  If that library is loaded in Emacs 27,
elisp-shorthands is simply ignored and the file is loaded normally.

João



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Shorthands have landed on master
  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
  1 sibling, 1 reply; 22+ messages in thread
From: Eli Zaretskii @ 2021-09-28  9:14 UTC (permalink / raw)
  To: João Távora; +Cc: adam, philipk, emacs-devel, stefankangas, dgutov

> From: João Távora <joaotavora@gmail.com>
> Date: Tue, 28 Sep 2021 10:03:01 +0100
> Cc: Adam Porter <adam@alphapapa.net>, Dmitry Gutov <dgutov@yandex.ru>,
>  Stefan Kangas <stefankangas@gmail.com>, emacs-devel <emacs-devel@gnu.org>
> 
> Since elisp-shorthands is a file-local variable, I think it allows (eval)
> specs.

But that will be unsafe, no?



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Shorthands have landed on master
  2021-09-28  9:14                 ` Eli Zaretskii
@ 2021-09-28  9:17                   ` João Távora
  0 siblings, 0 replies; 22+ messages in thread
From: João Távora @ 2021-09-28  9:17 UTC (permalink / raw)
  To: Eli Zaretskii
  Cc: Adam Porter, Philip K., emacs-devel, Stefan Kangas, Dmitry Gutov

On Tue, Sep 28, 2021 at 10:14 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: João Távora <joaotavora@gmail.com>
> > Date: Tue, 28 Sep 2021 10:03:01 +0100
> > Cc: Adam Porter <adam@alphapapa.net>, Dmitry Gutov <dgutov@yandex.ru>,
> >  Stefan Kangas <stefankangas@gmail.com>, emacs-devel <emacs-devel@gnu.org>
> >
> > Since elisp-shorthands is a file-local variable, I think it allows (eval)
> > specs.
>
> But that will be unsafe, no?

Yes, this is why I wrote "for now".  It does seem plausible that
Emacs provides pre-canned alists of substitutions such as
the one used for reading 'loop' as 'cl-loop', 'second' as
'cl-second', and so on. Those would be "safe" AFAIK and we
could have a mechanism to mark them so.

João



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Shorthands have landed on master
  2021-09-28  9:03               ` João Távora
  2021-09-28  9:14                 ` Eli Zaretskii
@ 2021-09-28  9:22                 ` Philip Kaludercic
  1 sibling, 0 replies; 22+ messages in thread
From: Philip Kaludercic @ 2021-09-28  9:22 UTC (permalink / raw)
  To: João Távora
  Cc: Adam Porter, Dmitry Gutov, Stefan Kangas, emacs-devel

João Távora <joaotavora@gmail.com> writes:

>> This was in reference to the compat.el discussion from a few days
>> ago. It was mentioned that shorthands might provide an alternative to
>> aliasing function definitions. But this doesn't make much sense, if a
>> prefix has to be used, short or long: I want to call
>> (macroexp-file-name), not (co-macroexp-file-name), (~macroexp-file-name)
>> or (compat--macroexp-file-name) to provide transparent compatibility.
>
> If I understand this right, then I think you may solve it similarly to the
> cl- situation.
>
> But you understand that, for the moment, shorthands are only supported in
> Emacs 28, right?  Not sure where (in which versions) the library you're
> intending to write would be loaded.  If that library is loaded in Emacs 27,
> elisp-shorthands is simply ignored and the file is loaded normally.

Yes, my idea was to use shorthands for versions greater or equal to
28.1. 

> João

-- 
	Philip Kaludercic



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Shorthands have landed on master (Was: Better way to require with shorthands/renamed symbols)
  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-28 23:37         ` Richard Stallman
  2 siblings, 0 replies; 22+ messages in thread
From: Richard Stallman @ 2021-09-28 23:37 UTC (permalink / raw)
  To: João Távora; +Cc: adam, emacs-devel, stefankangas, dgutov

[[[ 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. ]]]

  > Anyway, as you may have noticed, "Shorthands" have landed on master.

Congratulations and thanks.

-- 
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)





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Better way to require with shorthands/renamed symbols
  2021-09-28  1:53                   ` T.V Raman
@ 2021-09-30  6:04                     ` Richard Stallman
  0 siblings, 0 replies; 22+ messages in thread
From: Richard Stallman @ 2021-09-30  6:04 UTC (permalink / raw)
  To: T.V Raman; +Cc: adam, emacs-devel, dgutov, joaotavora, stefankangas

[[[ 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. ]]]

  > Consider a prefix separator char like ':' so that the shorthand is
  > easily distinguishable as a shorthand prefix? Might help in many ways:

We plan to use this for existing prefixes that do not have a colon.
For instance, 's-'.

 
-- 
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)





^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-09-30  6:04 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20210927003203.15806.29864@vcs0.savannah.gnu.org>
     [not found] ` <20210927003205.EF26620A5E@vcs0.savannah.gnu.org>
2021-09-27 11:10   ` Better way to require with shorthands/renamed symbols Stefan Kangas
2021-09-27 11:58     ` 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).