all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Cannot find a variable that sets the "abbreviation" of a library name/prefix
@ 2023-04-29 14:47 Ruijie Yu via Emacs development discussions.
  2023-04-29 15:14 ` Eli Zaretskii
  2023-04-29 21:46 ` João Távora
  0 siblings, 2 replies; 3+ messages in thread
From: Ruijie Yu via Emacs development discussions. @ 2023-04-29 14:47 UTC (permalink / raw)
  To: emacs-devel

Hello,

I'm definitely not dreaming, but I saw a variable from a patch somewhere
the other day, that works like this:

When one sets this variable to an alist of full-name (string) ->
short-name (string), the file itself defines symbols with short names,
while the loader pretends they are using the long names.  For example,
lets say the full name is "library", and short name is "lib".  Then, you
can define functions or variables like this:

```emacs-lisp
;; library.el --- example
(defvar lib-foo nil)
(defun lib-bar () t)

(provide 'library)
;; Local variables:
;; i-dont-know-what-this-variable-is-called: (("library" . "lib"))
;; End:
```

And the outside Elisp environment, when loading this file, now pretends
that the variable `library-foo' and the function `library-bar' are
defined.

```emacs-lisp
(require 'library)
(progn library-foo (library-bar))
```

However, when I search for "abbrev" using M-x apropos-command, I cannot
find anything.  Have I actually been dreaming?  Thanks.

-- 
Best,


RY

[Please note that this mail might go to spam due to some
misconfiguration in my mail server -- still investigating.]



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

* Re: Cannot find a variable that sets the "abbreviation" of a library name/prefix
  2023-04-29 14:47 Cannot find a variable that sets the "abbreviation" of a library name/prefix Ruijie Yu via Emacs development discussions.
@ 2023-04-29 15:14 ` Eli Zaretskii
  2023-04-29 21:46 ` João Távora
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2023-04-29 15:14 UTC (permalink / raw)
  To: Ruijie Yu; +Cc: emacs-devel

> Date: Sat, 29 Apr 2023 22:47:49 +0800
> From:  Ruijie Yu via "Emacs development discussions." <emacs-devel@gnu.org>
> 
> I'm definitely not dreaming, but I saw a variable from a patch somewhere
> the other day, that works like this:
> 
> When one sets this variable to an alist of full-name (string) ->
> short-name (string), the file itself defines symbols with short names,
> while the loader pretends they are using the long names.  For example,
> lets say the full name is "library", and short name is "lib".  Then, you
> can define functions or variables like this:
> 
> ```emacs-lisp
> ;; library.el --- example
> (defvar lib-foo nil)
> (defun lib-bar () t)
> 
> (provide 'library)
> ;; Local variables:
> ;; i-dont-know-what-this-variable-is-called: (("library" . "lib"))
> ;; End:
> ```
> 
> And the outside Elisp environment, when loading this file, now pretends
> that the variable `library-foo' and the function `library-bar' are
> defined.
> 
> ```emacs-lisp
> (require 'library)
> (progn library-foo (library-bar))
> ```
> 
> However, when I search for "abbrev" using M-x apropos-command, I cannot
> find anything.  Have I actually been dreaming?  Thanks.

You are talking about read-symbol-shorthands, I think.



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

* Re: Cannot find a variable that sets the "abbreviation" of a library name/prefix
  2023-04-29 14:47 Cannot find a variable that sets the "abbreviation" of a library name/prefix Ruijie Yu via Emacs development discussions.
  2023-04-29 15:14 ` Eli Zaretskii
@ 2023-04-29 21:46 ` João Távora
  1 sibling, 0 replies; 3+ messages in thread
From: João Távora @ 2023-04-29 21:46 UTC (permalink / raw)
  To: Ruijie Yu; +Cc: emacs-devel

On Sat, Apr 29, 2023 at 3:58 PM Ruijie Yu via Emacs development
discussions. <emacs-devel@gnu.org> wrote:
>
> Hello,
>
> I'm definitely not dreaming, but I saw a variable from a patch somewhere
> the other day, that works like this:
>
> When one sets this variable to an alist of full-name (string) ->
> short-name (string), the file itself defines symbols with short names,
> while the loader pretends they are using the long names.  For example,
> lets say the full name is "library", and short name is "lib".  Then, you
> can define functions or variables like this:

This would be read-symbol-shorthands.  Look in up in the manual and see
the following for a practical example of a library that uses it:

https://github.com/joaotavora/beardbolt/edit/master/beardbolt.el

> And the outside Elisp environment, when loading this file, now pretends
> that the variable `library-foo' and the function `library-bar' are
> defined.

It's actually the other way round.  It's `lib-foo` and `lib-bar` that
were never really names of symbols.  They were always `library-foo` and
`library-bar` underneath, they're just written in abbreviated shorthand
form.

It's not only when loading the file from the "outside": it's also when
compiling definitions from inside, and looking up ElDoc documentation,
etc.

João



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

end of thread, other threads:[~2023-04-29 21:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-29 14:47 Cannot find a variable that sets the "abbreviation" of a library name/prefix Ruijie Yu via Emacs development discussions.
2023-04-29 15:14 ` Eli Zaretskii
2023-04-29 21:46 ` João Távora

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.