all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Setting up abbrev
@ 2022-07-31 12:23 wilnerthomas--- via Users list for the GNU Emacs text editor
  2022-07-31 13:08 ` Jean Louis
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: wilnerthomas--- via Users list for the GNU Emacs text editor @ 2022-07-31 12:23 UTC (permalink / raw)
  To: help-gnu-emacs


Have seen discussions about abbrev.  How does it work exactly, and how could I set it up to test it?


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

* Re: Setting up abbrev
  2022-07-31 12:23 Setting up abbrev wilnerthomas--- via Users list for the GNU Emacs text editor
@ 2022-07-31 13:08 ` Jean Louis
  2022-08-01  3:06   ` Emanuel Berg
       [not found] ` <YuZ+ucBrwA9vOR/F@protected.localdomain-N8JMuQk----2>
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 25+ messages in thread
From: Jean Louis @ 2022-07-31 13:08 UTC (permalink / raw)
  To: wilnerthomas; +Cc: help-gnu-emacs

* wilnerthomas--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-07-31 15:24]:
> Have seen discussions about abbrev.  How does it work exactly, and
> how could I set it up to test it?

It is very handy and useful to use Emacs feature to abbreviate longer
phrases and expand them automatically on the fly.

Best is if you evalute following in Emacs and read it from manual:

(info "(emacs) Abbrevs")

29.2 Defining Abbrevs
=====================

‘C-x a g’
     Define an abbrev, using one or more words before point as its
     expansion (‘add-global-abbrev’).

‘C-x a l’
     Similar, but define an abbrev specific to the current major mode
     (‘add-mode-abbrev’).

‘C-x a i g’
     Define a word in the buffer as an abbrev
     (‘inverse-add-global-abbrev’).

‘C-x a i l’
     Define a word in the buffer as a mode-specific abbrev
     (‘inverse-add-mode-abbrev’).

‘M-x define-global-abbrev <RET> ABBREV <RET> EXP <RET>’
     Define ABBREV as an abbrev expanding into EXP.

‘M-x define-mode-abbrev <RET> ABBREV <RET> EXP <RET>’
     Define ABBREV as a mode-specific abbrev expanding into EXP.

‘M-x kill-all-abbrevs’
     Discard all abbrev definitions, leaving a blank slate.

Let us say you have following words: We are the champions⬛ and your
cursor is there on the end of the word "champions", you could write
{C-4 C-x a g} and enter into minibuffer: "wechamp" and then any time
you write "wechamp" and press {C-x '} after "wechamp" it would expand
to "We are the champions".

I often use it to expand websites, such as wgnu to expand to
https://www.GNU.org

Then if you do {M-x abbrev-mode RET} the expansion takes place
automatically.

Links in this email are surrounded by curly brackets and represent
Hyperbole package's hyperlinks which may be automatically invoked by
{M-RET}

In fact, my signature below is never automatically added, I use
abbrevs for that. My real signature is:

actfsf

suprms

however, then when I enter "actfsf" it expands into what you see here
below.

So signatures I always add manually, but by using abbrevs. 👀

Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




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

* Re: Setting up abbrev
       [not found] ` <YuZ+ucBrwA9vOR/F@protected.localdomain-N8JMuQk----2>
@ 2022-07-31 15:35   ` wilnerthomas--- via Users list for the GNU Emacs text editor
  2022-07-31 16:40     ` [External] : " Drew Adams
  2022-08-01  6:05     ` Jean Louis
  0 siblings, 2 replies; 25+ messages in thread
From: wilnerthomas--- via Users list for the GNU Emacs text editor @ 2022-07-31 15:35 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs


Jul 31, 2022, 13:08 by bugs@gnu.support:

> * wilnerthomas--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-07-31 15:24]:
>
>> Have seen discussions about abbrev.  How does it work exactly, and
>> how could I set it up to test it?
>>
>
> It is very handy and useful to use Emacs feature to abbreviate longer
> phrases and expand them automatically on the fly.
>
> Best is if you evalute following in Emacs and read it from manual:
>
> Let us say you have following words: We are the champions⬛ and your
> cursor is there on the end of the word "champions", you could write
> {C-4 C-x a g} and enter into minibuffer: "wechamp" and then any time
> you write "wechamp" and press {C-x '} after "wechamp" it would expand
> to "We are the champions".
>
Have tried it and works well.  Does it always have to work by pressing {C-x '}.
Was hoping it would work like company-mode, as you type.





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

* RE: [External] : Re: Setting up abbrev
  2022-07-31 15:35   ` wilnerthomas--- via Users list for the GNU Emacs text editor
@ 2022-07-31 16:40     ` Drew Adams
  2022-08-01  6:21       ` Jean Louis
  2022-08-01  6:05     ` Jean Louis
  1 sibling, 1 reply; 25+ messages in thread
From: Drew Adams @ 2022-07-31 16:40 UTC (permalink / raw)
  To: wilnerthomas@tutanota.com, Jean Louis
  Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

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

> Have tried [abbrev mode] and works well.  Does it always
> have to work by pressing {C-x '}.
> Was hoping it would work like company-mode, as you type.

https://emacs.stackexchange.com/q/72861/105

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 12971 bytes --]

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

* Re: Setting up abbrev
  2022-07-31 12:23 Setting up abbrev wilnerthomas--- via Users list for the GNU Emacs text editor
  2022-07-31 13:08 ` Jean Louis
       [not found] ` <YuZ+ucBrwA9vOR/F@protected.localdomain-N8JMuQk----2>
@ 2022-07-31 20:02 ` kf
  2022-08-01  3:03 ` Emanuel Berg
  3 siblings, 0 replies; 25+ messages in thread
From: kf @ 2022-07-31 20:02 UTC (permalink / raw)
  To: help-gnu-emacs

On 7/31/22 8:23 AM, wilnerthomas--- via Users list for the GNU Emacs 
text editor wrote:
> 
> Have seen discussions about abbrev.  How does it work exactly, and how could I set it up to test it?
> 

I was ready to write a long answer, but then, not wishing to re-invent 
any wheels, ran a (duck-duck-go) web search on "how to set up abbrevs in 
emacs" and found a lot of good pages.



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

* Re: Setting up abbrev
  2022-07-31 12:23 Setting up abbrev wilnerthomas--- via Users list for the GNU Emacs text editor
                   ` (2 preceding siblings ...)
  2022-07-31 20:02 ` kf
@ 2022-08-01  3:03 ` Emanuel Berg
  2022-08-01 10:41   ` uzibalqa
  2022-08-01 11:33   ` carlmarcos--- via Users list for the GNU Emacs text editor
  3 siblings, 2 replies; 25+ messages in thread
From: Emanuel Berg @ 2022-08-01  3:03 UTC (permalink / raw)
  To: help-gnu-emacs

wilnerthomas--- via Users list for the GNU Emacs text editor wrote:

> Have seen discussions about abbrev. How does it work
> exactly, and how could I set it up to test it?

Try for example:

;;; -*- lexical-binding: t -*-

;; (kill-all-abbrevs)
(let ((write '(
               ("lex"    ";;; -*- lexical-binding: t -*-")
               ("sld"    "sdl")
               ("wierd"  "weird")
               )))
  (define-abbrev-table 'global-abbrev-table write) )

You can do more things with abbrevs, including executing
functions - but it seems I did something wrong this time as
this doesn't work ...

(defun sh-mode-abbrev-f ()
  (goto-char (point-min))
  (insert "#! /bin/zsh\n")
  (sh-mode) )

(define-abbrev global-abbrev-table "zshbang" t #'sh-mode-abbrev-f)

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Setting up abbrev
  2022-07-31 13:08 ` Jean Louis
@ 2022-08-01  3:06   ` Emanuel Berg
  2022-08-01  6:04     ` Jean Louis
  0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg @ 2022-08-01  3:06 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>> Have seen discussions about abbrev. How does it work
>> exactly, and how could I set it up to test it?
>
> It is very handy and useful to use Emacs feature to
> abbreviate longer phrases and expand them automatically on
> the fly.

_And_ words that you always type the wrong way. Everyone has
a couple of those, for example I always type length instead of
"length".

But isnt' that the write way? Yes, because Emacs fixed it :)

It can't fix "write" into right tho it seems ...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Setting up abbrev
  2022-08-01  3:06   ` Emanuel Berg
@ 2022-08-01  6:04     ` Jean Louis
  2022-08-01  7:42       ` Emanuel Berg
  0 siblings, 1 reply; 25+ messages in thread
From: Jean Louis @ 2022-08-01  6:04 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <incal@dataswamp.org> [2022-08-01 06:16]:
> Jean Louis wrote:
> 
> >> Have seen discussions about abbrev. How does it work
> >> exactly, and how could I set it up to test it?
> >
> > It is very handy and useful to use Emacs feature to
> > abbreviate longer phrases and expand them automatically on
> > the fly.
> 
> _And_ words that you always type the wrong way. Everyone has
> a couple of those, for example I always type length instead of
> "length".

It must be that abbrev corrected your word which you always write as
length to length.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: Setting up abbrev
  2022-07-31 15:35   ` wilnerthomas--- via Users list for the GNU Emacs text editor
  2022-07-31 16:40     ` [External] : " Drew Adams
@ 2022-08-01  6:05     ` Jean Louis
  1 sibling, 0 replies; 25+ messages in thread
From: Jean Louis @ 2022-08-01  6:05 UTC (permalink / raw)
  To: wilnerthomas; +Cc: help-gnu-emacs

* wilnerthomas--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-07-31 18:36]:
> Have tried it and works well.  Does it always have to work by pressing {C-x '}.
> Was hoping it would work like company-mode, as you type.

To make it work automatically, then {M-x abbrev-mode RET}


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: [External] : Re: Setting up abbrev
  2022-07-31 16:40     ` [External] : " Drew Adams
@ 2022-08-01  6:21       ` Jean Louis
  0 siblings, 0 replies; 25+ messages in thread
From: Jean Louis @ 2022-08-01  6:21 UTC (permalink / raw)
  To: Drew Adams
  Cc: wilnerthomas@tutanota.com,
	'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

* Drew Adams <drew.adams@oracle.com> [2022-07-31 19:41]:
> > Have tried [abbrev mode] and works well.  Does it always
> > have to work by pressing {C-x '}.
> > Was hoping it would work like company-mode, as you type.
> 
> https://emacs.stackexchange.com/q/72861/105

I do not tend to jump to hyperlinks external to mailing list. But I
did.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: Setting up abbrev
  2022-08-01  6:04     ` Jean Louis
@ 2022-08-01  7:42       ` Emanuel Berg
  0 siblings, 0 replies; 25+ messages in thread
From: Emanuel Berg @ 2022-08-01  7:42 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>>>> Have seen discussions about abbrev. How does it work
>>>> exactly, and how could I set it up to test it?
>>>
>>> It is very handy and useful to use Emacs feature to
>>> abbreviate longer phrases and expand them automatically on
>>> the fly.
>> 
>> _And_ words that you always type the wrong way.
>> Everyone has a couple of those, for example I always type
>> length instead of "length".
>
> It must be that abbrev corrected your word which you always
> write as length to length.

Uhm, I think I float just that?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Setting up abbrev
  2022-08-01  3:03 ` Emanuel Berg
@ 2022-08-01 10:41   ` uzibalqa
  2022-08-01 11:39     ` Emanuel Berg
  2022-08-01 11:33   ` carlmarcos--- via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 25+ messages in thread
From: uzibalqa @ 2022-08-01 10:41 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

------- Original Message -------
On Monday, August 1st, 2022 at 3:03 AM, Emanuel Berg <incal@dataswamp.org> wrote:


> wilnerthomas--- via Users list for the GNU Emacs text editor wrote:
>
> > Have seen discussions about abbrev. How does it work
> > exactly, and how could I set it up to test it?
>
>
> Try for example:
>
> ;;; -- lexical-binding: t --
>
> ;; (kill-all-abbrevs)
> (let ((write '(
> ("lex" ";;; -- lexical-binding: t --")
> ("sld" "sdl")
> ("wierd" "weird")
> )))
> (define-abbrev-table 'global-abbrev-table write) )

I see that you make a list of three elements, each of which is a list of two elements.
Had been using (sld" . "sdl") thing instead.





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

* Re: Setting up abbrev
  2022-08-01  3:03 ` Emanuel Berg
  2022-08-01 10:41   ` uzibalqa
@ 2022-08-01 11:33   ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-08-01 11:42     ` Emanuel Berg
  1 sibling, 1 reply; 25+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-08-01 11:33 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

Aug 1, 2022, 03:03 by incal@dataswamp.org:

> wilnerthomas--- via Users list for the GNU Emacs text editor wrote:
>
>> Have seen discussions about abbrev. How does it work
>> exactly, and how could I set it up to test it?
>>
>
> Try for example:
>
> ;;; -*- lexical-binding: t -*-
>
> ;; (kill-all-abbrevs)
> (let ((write '(
>  ("lex"    ";;; -*- lexical-binding: t -*-")
>  ("sld"    "sdl")
>  ("wierd"  "weird")
>  )))
>  (define-abbrev-table 'global-abbrev-table write) )
>
Suppose I have a number of tables and want to introduce them to `global-abbrev-table', how
could I do it?

(setq tb1 '(("bf" "before") ("ll" "little"))
(setq tb2 '(("fm" "from") ("sc" "such"))







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

* Re: Setting up abbrev
  2022-08-01 10:41   ` uzibalqa
@ 2022-08-01 11:39     ` Emanuel Berg
  2022-08-01 14:56       ` [External] : " Drew Adams
  2022-08-01 16:56       ` tomas
  0 siblings, 2 replies; 25+ messages in thread
From: Emanuel Berg @ 2022-08-01 11:39 UTC (permalink / raw)
  To: help-gnu-emacs

uzibalqa wrote:

>> ;;; -- lexical-binding: t --
>>
>> ;; (kill-all-abbrevs)
>> (let ((write '(
>> ("lex" ";;; -- lexical-binding: t --")
>> ("sld" "sdl")
>> ("wierd" "weird")
>> )))
>> (define-abbrev-table 'global-abbrev-table write) )
>
> I see that you make a list of three elements, each of which
> is a list of two elements.

Well yes, but maybe it's better to think of that as data and
the number of elements are perhaps of no importance here.

> Had been using (sld" . "sdl") thing instead.

I know why it doesn't work then ...

Anyhow, the so-called dotted pair notation tells us that the
universal data structure actually isn't a list, but a pair!
Only a pair is a list as well ...

In practice - here, someone maybe disagrees? - but in my
experience I don't see why that should be used ...

And I don't know why it was ever essential to the point it
even got to symbolize Lisp on a couple of occasions?

Maybe that box diagram with arrows to make up a cons cell
link-list-fragment just looked neat and interesting ...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Setting up abbrev
  2022-08-01 11:33   ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-08-01 11:42     ` Emanuel Berg
  2022-08-01 12:54       ` carlmarcos--- via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg @ 2022-08-01 11:42 UTC (permalink / raw)
  To: help-gnu-emacs

carlmarcos--- via Users list for the GNU Emacs text editor wrote:

>>> Have seen discussions about abbrev. How does it work
>>> exactly, and how could I set it up to test it?
>>
>> Try for example:
>>
>> ;;; -*- lexical-binding: t -*-
>>
>> ;; (kill-all-abbrevs)
>> (let ((write '(
>>  ("lex"    ";;; -*- lexical-binding: t -*-")
>>  ("sld"    "sdl")
>>  ("wierd"  "weird")
>>  )))
>>  (define-abbrev-table 'global-abbrev-table write) )
>
> Suppose I have a number of tables and want to introduce them
> to `global-abbrev-table', how could I do it?

The way it's done above ...

> (setq tb1 '(("bf" "before") ("ll" "little"))
> (setq tb2 '(("fm" "from") ("sc" "such"))

Very bad examples what to do with abbrev. Disencouraged!

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Setting up abbrev
  2022-08-01 11:42     ` Emanuel Berg
@ 2022-08-01 12:54       ` carlmarcos--- via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 25+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-08-01 12:54 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs



-- 
 Sent with Tutanota, enjoy secure & ad-free emails. 



Aug 1, 2022, 11:42 by incal@dataswamp.org:

> carlmarcos--- via Users list for the GNU Emacs text editor wrote:
>
>>>> Have seen discussions about abbrev. How does it work
>>>> exactly, and how could I set it up to test it?
>>>>
>>>
>>> Try for example:
>>>
>>> ;;; -*- lexical-binding: t -*-
>>>
>>> ;; (kill-all-abbrevs)
>>> (let ((write '(
>>>  ("lex"    ";;; -*- lexical-binding: t -*-")
>>>  ("sld"    "sdl")
>>>  ("wierd"  "weird")
>>>  )))
>>>  (define-abbrev-table 'global-abbrev-table write) )
>>>
>>
>> Suppose I have a number of tables and want to introduce them
>> to `global-abbrev-table', how could I do it?
>>
>
> The way it's done above ...
>
>> (setq tb1 '(("bf" "before") ("ll" "little"))
>> (setq tb2 '(("fm" "from") ("sc" "such"))
>>
>
> Very bad examples what to do with abbrev. Disencouraged!
>
Get past the discouragement.  Because when pushing things by categorisation there is a pressing demand for more than a single rudimentary table.



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

* RE: [External] : Re: Setting up abbrev
  2022-08-01 11:39     ` Emanuel Berg
@ 2022-08-01 14:56       ` Drew Adams
  2022-08-01 15:14         ` Emanuel Berg
  2022-08-01 16:56       ` tomas
  1 sibling, 1 reply; 25+ messages in thread
From: Drew Adams @ 2022-08-01 14:56 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs@gnu.org

> Anyhow, the so-called dotted pair notation tells us that the
> universal data structure actually isn't a list, but a pair!

Yes.

> Only a pair is a list as well ...

Yes.  But a list isn't a pair. ;-)

> In practice - here, someone maybe disagrees? - but in my
> experience I don't see why that should be used ...
> 
> And I don't know why it was ever essential to the point it
> even got to symbolize Lisp on a couple of occasions?
> 
> Maybe that box diagram with arrows to make up a cons cell
> link-list-fragment just looked neat and interesting ...

1. Key-value pairs are quite common - far beyond Lisp.

2. A cons is a key-value pair.

But the constructor function `cons' is more/other than
that.  As a key-value pair, (cons a (cons b c)) has key
`a' and value key-value pair (b . c).  Not your typical
key-value pair use case - not typically thought of that
way, at least.

3. A fundamental structure-building thingie in our
universe is the unary constructor, `s' (successor
function).  Together with the nullary constructor, `0',
it gives you the Natural numbers - pretty foundational.

The next structure-building thingie is the binary
constructor, `cons'.  Together with nullary constructor
`nil' it gives you key-value pairs, or if you prefer,
essentially all structures/constructions - sculptures
of all sorts.

Syntax-tree and function-application are fundamental
structures for programs and (other) data.  In Lisp,
both are directly, unabashedly, handled as conses.

If you want lists then you have conses.  If you want
trees then you have conses.

As for the (a . b) _notation_: Why not?  JSON uses
`:'.  Prolog uses `|'.  Doesn't matter much what
notation you choose.  OOPs often use a dot notation
for method application.  Six of one; half a dozen of
another...



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

* Re: [External] : Re: Setting up abbrev
  2022-08-01 14:56       ` [External] : " Drew Adams
@ 2022-08-01 15:14         ` Emanuel Berg
  2022-08-01 16:36           ` Drew Adams
  0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg @ 2022-08-01 15:14 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

>> Only a pair is a list as well ...
>
> Yes.  But a list isn't a pair. ;-)

Every pair is a list but every list isn't a pair ...

Well, maybe one can think of a pair without order, i.e.
a set of two items?

The _ordered_ pair is the universal data structure that can
express anything then. The list is equally universal but the
ordered pair is the minimal working example, to speak with the
LaTeX guys ...

>> In practice - here, someone maybe disagrees? - but in my
>> experience I don't see why that should be used ...
>> 
>> And I don't know why it was ever essential to the point it
>> even got to symbolize Lisp on a couple of occasions?
>> 
>> Maybe that box diagram with arrows to make up a cons cell
>> link-list-fragment just looked neat and interesting ...
>
> 1. Key-value pairs are quite common - far beyond Lisp.

Sure, it's universal, and in particular Lisp is the most
universal of all programming languages ;)

> 2. A cons is a key-value pair.
>
> But the constructor function `cons' is more/other than that.
> As a key-value pair, (cons a (cons b c)) has key `a' and
> value key-value pair (b . c). Not your typical key-value
> pair use case - not typically thought of that way, at least.
>
> 3. A fundamental structure-building thingie in our universe
>    is the unary constructor, `s' (successor function).
>    Together with the nullary constructor, `0', it gives you
>    the Natural numbers - pretty foundational.
>
> The next structure-building thingie is the binary
> constructor, `cons'. Together with nullary constructor `nil'
> it gives you key-value pairs, or if you prefer, essentially
> all structures/constructions - sculptures of all sorts.
>
> Syntax-tree and function-application are fundamental
> structures for programs and (other) data. In Lisp, both are
> directly, unabashedly, handled as conses.
>
> If you want lists then you have conses. If you want trees
> then you have conses.
>
> As for the (a . b) _notation_: Why not? JSON uses `:'.
> Prolog uses `|'. Doesn't matter much what notation you
> choose. OOPs often use a dot notation for method
> application. Six of one; half a dozen of another...

Okay, but I still don't understand the benefit of using it in
practice compared to the list (a b)?

-- 
underground experts united
https://dataswamp.org/~incal




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

* RE: [External] : Re: Setting up abbrev
  2022-08-01 15:14         ` Emanuel Berg
@ 2022-08-01 16:36           ` Drew Adams
  2022-08-01 16:57             ` wilnerthomas--- via Users list for the GNU Emacs text editor
  2022-08-01 18:36             ` Emanuel Berg
  0 siblings, 2 replies; 25+ messages in thread
From: Drew Adams @ 2022-08-01 16:36 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs@gnu.org

> >> Only a pair is a list as well ...
> >
> > Yes.  But a list isn't a pair. ;-)
> 
> Every pair is a list but every list isn't a pair ...
|
                           not every list is a pair

"Not every X is" = "some X isn't" != "every X isn't"

> Well, maybe one can think of a pair without order, i.e.
> a set of two items?
> 
> The _ordered_ pair is the universal data structure that can
> express anything then. The list is equally universal but the
> ordered pair is the minimal working example, to speak with the
> LaTeX guys ...

Yes, ordered pair.  That's a cons.

> > As for the (a . b) _notation_: Why not? JSON uses `:'.
> > Prolog uses `|'. Doesn't matter much what notation you
> > choose. OOPs often use a dot notation for method
> > application. Six of one; half a dozen of another...
> 
> Okay, but I still don't understand the benefit of using it in
> practice compared to the list (a b)?

Do you mean use the _notation_?  I guess you instead
mean use a dotted list: a list whose last cdr is a
non-nil atom.

If so, the answer is that in general you do want to
use a true/proper list (last cdr is nil), and NOT a
dotted list.  For many reasons, not least of which
is using a function that needs to traverse all list
elements (e.g. `length', mapping/sequence functions).

You can use a dotted list in these cases:

1. You want to save conses (not create so many), in
a context where you're not going to be needing to
use the cons as a list (mapping etc.), or a context
where you know you'll only ever want an atom cdr.

2. You want/need, in effect, to have a backwards
key-value pair, (list-value . atom-key).  You have
a list to use for most purposes (ignoring the last
cdr), and you have an atom (the cdr) for a few rare
purposes, as a kind of label for the list.

#2 is usually the result of trying to adapt to
legacy code that expects to treat just a list (and
doesn't need to follow it to its end).  IOW, #2 is
typically an ugly hack.  For new code you'd instead
just put the atom first: (atom-key . list-value).



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

* Re: Setting up abbrev
  2022-08-01 11:39     ` Emanuel Berg
  2022-08-01 14:56       ` [External] : " Drew Adams
@ 2022-08-01 16:56       ` tomas
  2022-08-01 18:40         ` Emanuel Berg
  1 sibling, 1 reply; 25+ messages in thread
From: tomas @ 2022-08-01 16:56 UTC (permalink / raw)
  To: help-gnu-emacs

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

On Mon, Aug 01, 2022 at 01:39:22PM +0200, Emanuel Berg wrote:

[...]

> Only a pair is a list as well ...

But only in very restricted circumstances: when the pair's
cdr is nil, i.e. when it is an one-element list.

Otherwise it's an improper list...

Unless, of course, you consider the list's head as "the list",
in a pars pro toto way: then, a list is a pair whose cdr is
a list.

Or something.

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* RE: [External] : Re: Setting up abbrev
  2022-08-01 16:36           ` Drew Adams
@ 2022-08-01 16:57             ` wilnerthomas--- via Users list for the GNU Emacs text editor
  2022-08-01 18:36             ` Emanuel Berg
  1 sibling, 0 replies; 25+ messages in thread
From: wilnerthomas--- via Users list for the GNU Emacs text editor @ 2022-08-01 16:57 UTC (permalink / raw)
  To: Drew Adams; +Cc: Emanuel Berg, help-gnu-emacs@gnu.org

Aug 1, 2022, 16:36 by drew.adams@oracle.com:

>> >> Only a pair is a list as well ...
>> >
>> > Yes.  But a list isn't a pair. ;-)
>>
>> Every pair is a list but every list isn't a pair ...
>>
> |
>  not every list is a pair
>
> "Not every X is" = "some X isn't" != "every X isn't"
>
>> Well, maybe one can think of a pair without order, i.e.
>> a set of two items?
>>
>> The _ordered_ pair is the universal data structure that can
>> express anything then. The list is equally universal but the
>> ordered pair is the minimal working example, to speak with the
>> LaTeX guys ...
>>
>
> Yes, ordered pair.  That's a cons.
>
>> > As for the (a . b) _notation_: Why not? JSON uses `:'.
>> > Prolog uses `|'. Doesn't matter much what notation you
>> > choose. OOPs often use a dot notation for method
>> > application. Six of one; half a dozen of another...
>>
>> Okay, but I still don't understand the benefit of using it in
>> practice compared to the list (a b)?
>>
>
> Do you mean use the _notation_?  I guess you instead
> mean use a dotted list: a list whose last cdr is a
> non-nil atom.
>
> If so, the answer is that in general you do want to
> use a true/proper list (last cdr is nil), and NOT a
> dotted list.  For many reasons, not least of which
> is using a function that needs to traverse all list
> elements (e.g. `length', mapping/sequence functions).
>
> You can use a dotted list in these cases:
>
> 1. You want to save conses (not create so many), in
> a context where you're not going to be needing to
> use the cons as a list (mapping etc.), or a context
> where you know you'll only ever want an atom cdr.
>
> 2. You want/need, in effect, to have a backwards
> key-value pair, (list-value . atom-key).  You have
> a list to use for most purposes (ignoring the last
> cdr), and you have an atom (the cdr) for a few rare
> purposes, as a kind of label for the list.
>
> #2 is usually the result of trying to adapt to
> legacy code that expects to treat just a list (and
> doesn't need to follow it to its end).  IOW, #2 is
> typically an ugly hack.  For new code you'd instead
> just put the atom first: (atom-key . list-value).
>
You are all very good at technical entertainment but not how to show the way
 to use multiple lists.

(setq  tb2  '( ("all" "l")  ("as" "as") ))
 (setq  tb3  '( ("again" "ag")  ("any" "n") ))
(define-abbrev-table 'global-abbrev-table tb1)
(define-abbrev-table 'global-abbrev-table tb2)


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

* Re: [External] : Re: Setting up abbrev
  2022-08-01 16:36           ` Drew Adams
  2022-08-01 16:57             ` wilnerthomas--- via Users list for the GNU Emacs text editor
@ 2022-08-01 18:36             ` Emanuel Berg
  2022-08-01 19:20               ` Drew Adams
  1 sibling, 1 reply; 25+ messages in thread
From: Emanuel Berg @ 2022-08-01 18:36 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

>> Okay, but I still don't understand the benefit of using it
>> in practice compared to the list (a b)?
>
> Do you mean use the _notation_? I guess you instead mean use
> a dotted list: a list whose last cdr is a non-nil atom.
>
> If so, the answer is that in general you do want to use
> a true/proper list (last cdr is nil), and NOT a dotted list.
> For many reasons, not least of which is using a function
> that needs to traverse all list elements (e.g. `length',
> mapping/sequence functions).
>
> You can use a dotted list in these cases:
>
> 1. You want to save conses (not create so many), in
>    a context where you're not going to be needing to use the
>    cons as a list (mapping etc.), or a context where you
>    know you'll only ever want an atom cdr.
>
> 2. You want/need, in effect, to have a backwards key-value
>    pair, (list-value . atom-key). You have a list to use for
>    most purposes (ignoring the last cdr), and you have an
>    atom (the cdr) for a few rare purposes, as a kind of
>    label for the list.
>
> #2 is usually the result of trying to adapt to legacy code
> that expects to treat just a list (and doesn't need to
> follow it to its end). IOW, #2 is typically an ugly hack.
> For new code you'd instead just put the atom first:
> (atom-key . list-value).

Why? What data can (a . b) hold that (list a b) cannot?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Setting up abbrev
  2022-08-01 16:56       ` tomas
@ 2022-08-01 18:40         ` Emanuel Berg
  2022-08-01 20:37           ` tomas
  0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg @ 2022-08-01 18:40 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

>> Only a pair is a list as well ...
>
> But only in very restricted circumstances: when the pair's
> cdr is nil, i.e. when it is an one-element list.
>
> Otherwise it's an improper list...
>
> Unless, of course, you consider the list's head as "the
> list", in a pars pro toto way: then, a list is a pair whose
> cdr is a list.

A pair is a list with two elements.

-- 
underground experts united
https://dataswamp.org/~incal




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

* RE: [External] : Re: Setting up abbrev
  2022-08-01 18:36             ` Emanuel Berg
@ 2022-08-01 19:20               ` Drew Adams
  0 siblings, 0 replies; 25+ messages in thread
From: Drew Adams @ 2022-08-01 19:20 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs@gnu.org

> > You can use a dotted list in these cases:
> >
> > 1. You want to save conses (not create so many), in
> >    a context where you're not going to be needing to use the
> >    cons as a list (mapping etc.), or a context where you
> >    know you'll only ever want an atom cdr.
> >
> > 2. You want/need, in effect, to have a backwards key-value
> >    pair, (list-value . atom-key). You have a list to use for
> >    most purposes (ignoring the last cdr), and you have an
> >    atom (the cdr) for a few rare purposes, as a kind of
> >    label for the list.
> >
> > #2 is usually the result of trying to adapt to legacy code
> > that expects to treat just a list (and doesn't need to
> > follow it to its end). IOW, #2 is typically an ugly hack.
> > For new code you'd instead just put the atom first:
> > (atom-key . list-value).
> 
> Why? What data can (a . b) hold that (list a b) cannot?

Please reread what I wrote.  I never said that
(a . b) can hold data that (a b) cannot.  Nothing
like that.


I said:

1. (a . b) uses one less cons than (a b).

2. If you need to support legacy code that expects
to use a list (a b c), but you also want to label
such a list with an atom, you can sometimes use
(a b c . d) to get away with doing both.

That's all.  If the performance (space or access
time) of (a b) isn't a problem for your app, then
#1 probably doesn't apply.  If you don't need to
cover legacy cases such as #2 describes, then #2
probably doesn't apply.

Those are two use cases that come to (my) mind.



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

* Re: Setting up abbrev
  2022-08-01 18:40         ` Emanuel Berg
@ 2022-08-01 20:37           ` tomas
  0 siblings, 0 replies; 25+ messages in thread
From: tomas @ 2022-08-01 20:37 UTC (permalink / raw)
  To: help-gnu-emacs

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

On Mon, Aug 01, 2022 at 08:40:36PM +0200, Emanuel Berg wrote:
> tomas wrote:
> 
> >> Only a pair is a list as well ...
> >
> > But only in very restricted circumstances: when the pair's
> > cdr is nil, i.e. when it is an one-element list.
> >
> > Otherwise it's an improper list...
> >
> > Unless, of course, you consider the list's head as "the
> > list", in a pars pro toto way: then, a list is a pair whose
> > cdr is a list.
> 
> A pair is a list with two elements.

Dunno. In Lisp, there's no technical term "pair". In Scheme,
a "pair" is what Lisp calls a "cons" or a "cons pair", and
this is not a list. Just a building block for lists.

If you want to invent your own terminology, you're welcome,
but communication becomes cumbersome :)

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

end of thread, other threads:[~2022-08-01 20:37 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-31 12:23 Setting up abbrev wilnerthomas--- via Users list for the GNU Emacs text editor
2022-07-31 13:08 ` Jean Louis
2022-08-01  3:06   ` Emanuel Berg
2022-08-01  6:04     ` Jean Louis
2022-08-01  7:42       ` Emanuel Berg
     [not found] ` <YuZ+ucBrwA9vOR/F@protected.localdomain-N8JMuQk----2>
2022-07-31 15:35   ` wilnerthomas--- via Users list for the GNU Emacs text editor
2022-07-31 16:40     ` [External] : " Drew Adams
2022-08-01  6:21       ` Jean Louis
2022-08-01  6:05     ` Jean Louis
2022-07-31 20:02 ` kf
2022-08-01  3:03 ` Emanuel Berg
2022-08-01 10:41   ` uzibalqa
2022-08-01 11:39     ` Emanuel Berg
2022-08-01 14:56       ` [External] : " Drew Adams
2022-08-01 15:14         ` Emanuel Berg
2022-08-01 16:36           ` Drew Adams
2022-08-01 16:57             ` wilnerthomas--- via Users list for the GNU Emacs text editor
2022-08-01 18:36             ` Emanuel Berg
2022-08-01 19:20               ` Drew Adams
2022-08-01 16:56       ` tomas
2022-08-01 18:40         ` Emanuel Berg
2022-08-01 20:37           ` tomas
2022-08-01 11:33   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-08-01 11:42     ` Emanuel Berg
2022-08-01 12:54       ` carlmarcos--- via Users list for the GNU Emacs text editor

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.