unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Help with elisp
@ 2003-07-30 18:06 David Chadd
  0 siblings, 0 replies; 18+ messages in thread
From: David Chadd @ 2003-07-30 18:06 UTC (permalink / raw)



Apologies for a question demonstrating beginner's total Elisp
incompetence.  I want to make lists out of series of
attribute-values in an xml file.  (The values are sigla of
manuscripts.)  These are e.g. in the form:

  wit="CAO-C Alb2 Hyd" 

Having found the string of values (CAO-C Alb2 Hyd) with a regexp
search, I simple-mindedly thought I would be able to do something like

  (setq wits (split-string (match-string 1)))

This does indeed make a list --- (listp wits) returns T --- but the
lists don't behave as I would expect.  For instance, they don't
respond correctly to (set-difference), (intersection) etc.  And for
reasons I can guess at, but don't know enough to do anything about,
the lists are in the form ("CAO-C" "Alb2" "Hyd") rather than (CAO-C
Alb2 Hyd).

I'm obviously going totally the wrong way about this.  How should I be
trying to make a conventional Lisp list out of a found string of this
kind?  Advice and guidance gratefully received.

DC
-- 
--------------------------
Professor David Chadd
University of East Anglia
Norwich NR4 7TJ, UK
net: <d.chadd@uea.ac.uk>
fax: +44 (0)1263 250454
--------------------------

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

* Re: Help with elisp
       [not found] <mailman.767.1059641390.8231.help-gnu-emacs@gnu.org>
@ 2003-07-31 11:30 ` lawrence mitchell
  2003-07-31 11:59 ` Tom Capey
  1 sibling, 0 replies; 18+ messages in thread
From: lawrence mitchell @ 2003-07-31 11:30 UTC (permalink / raw)


David Chadd wrote:

> Apologies for a question demonstrating beginner's total Elisp
> incompetence.  I want to make lists out of series of
> attribute-values in an xml file.  (The values are sigla of
> manuscripts.)  These are e.g. in the form:

>   wit="CAO-C Alb2 Hyd"

> Having found the string of values (CAO-C Alb2 Hyd) with a regexp
> search, I simple-mindedly thought I would be able to do something like

>   (setq wits (split-string (match-string 1)))

> This does indeed make a list --- (listp wits) returns T --- but the
> lists don't behave as I would expect.  For instance, they don't
> respond correctly to (set-difference), (intersection) etc.  And for
> reasons I can guess at, but don't know enough to do anything about,
> the lists are in the form ("CAO-C" "Alb2" "Hyd") rather than (CAO-C
> Alb2 Hyd).

> I'm obviously going totally the wrong way about this.  How should I be
> trying to make a conventional Lisp list out of a found string of this
> kind?  Advice and guidance gratefully received.

In fact, you're almost there.  The only thing you're missing is
the correct equality test.  You see, strings are not EQ, or EQL
in emacs lisp.

(eq "foo" "foo")
   => nil

(eql "foo" "foo")
   => nil

instead, you need to check for equality either with EQUAL, or,
if you know you are using strings, STRING=.

(equal "foo" "foo")
   => t

(string= "foo" "foo")
   => t

Now, the functions SET-DIFFERENCE and INTERSECTION by default
test for equality with EQ, so you need to tell them to use a
different testing function.  This can be done by supplying them
with a keyword argument.

(setq foo '("foo" "bar" "baz")
      bar '("bar" "baz" "quux"))

foo
   => ("foo" "bar" "baz")

bar
   => ("bar" "baz" "quux")

;; Default, comparison done with EQ.
(set-difference foo bar)
   => ("baz" "bar" "foo")

(intersection foo bar)
   => nil

;; Comparison done with STRING=
(set-difference foo bar :test 'string=)
   => ("foo")

(intersection foo bar :test 'string=)
   => ("baz" "bar")

Hope that clears things up a bit
-- 
lawrence mitchell <wence@gmx.li>

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

* Re: Help with elisp
       [not found] <mailman.767.1059641390.8231.help-gnu-emacs@gnu.org>
  2003-07-31 11:30 ` lawrence mitchell
@ 2003-07-31 11:59 ` Tom Capey
  2003-07-31 15:59   ` Kevin Rodgers
  1 sibling, 1 reply; 18+ messages in thread
From: Tom Capey @ 2003-07-31 11:59 UTC (permalink / raw)


* David Chadd <d.chadd@uea.ac.uk> writes:

> Apologies for a question demonstrating beginner's total Elisp
> incompetence.  I want to make lists out of series of
> attribute-values in an xml file.  (The values are sigla of
> manuscripts.)  These are e.g. in the form:

>   wit="CAO-C Alb2 Hyd" 

> Having found the string of values (CAO-C Alb2 Hyd) with a regexp
> search, I simple-mindedly thought I would be able to do something like

>   (setq wits (split-string (match-string 1)))

> This does indeed make a list --- (listp wits) returns T --- but the
> lists don't behave as I would expect.  For instance, they don't
> respond correctly to (set-difference), (intersection) etc.  And for
> reasons I can guess at, but don't know enough to do anything about,
> the lists are in the form ("CAO-C" "Alb2" "Hyd") rather than (CAO-C
> Alb2 Hyd).


  change the test in the set functions from `eq':

(setq a (list "CAO-C" "Alb2" "Hyd")
      b (list "CAO-C" "Alb2" "Hyd" "foo"))

(intersection a b :test 'string-equal)
=> ("Hyd" "Alb2" "CAO-C")

(set-difference b a :test 'string-equal)
=> ("foo")

(set-difference a b :test 'string-equal)
=> nil


/Tom
-- 
Mais, à part ça, Madame la Marquise,
Tout va très bien, tout va très bien.

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

* Re: Help with elisp
  2003-07-31 11:59 ` Tom Capey
@ 2003-07-31 15:59   ` Kevin Rodgers
  0 siblings, 0 replies; 18+ messages in thread
From: Kevin Rodgers @ 2003-07-31 15:59 UTC (permalink / raw)


Tom Capey wrote:

> * David Chadd <d.chadd@uea.ac.uk> writes:
>>Having found the string of values (CAO-C Alb2 Hyd) with a regexp
>>search, I simple-mindedly thought I would be able to do something like
>>
>>  (setq wits (split-string (match-string 1)))
>>
>>This does indeed make a list --- (listp wits) returns T --- but the
>>lists don't behave as I would expect.  For instance, they don't
>>respond correctly to (set-difference), (intersection) etc.  And for
>>reasons I can guess at, but don't know enough to do anything about,
>>the lists are in the form ("CAO-C" "Alb2" "Hyd") rather than (CAO-C
>>Alb2 Hyd).
> 
>   change the test in the set functions from `eq':
> 
> (setq a (list "CAO-C" "Alb2" "Hyd")
>       b (list "CAO-C" "Alb2" "Hyd" "foo"))
> 
> (intersection a b :test 'string-equal)
> => ("Hyd" "Alb2" "CAO-C")
> 
> (set-difference b a :test 'string-equal)
> => ("foo")
> 
> (set-difference a b :test 'string-equal)
> => nil

Or create a list of symbols (which can be compared with `eq')

instead of strings (which can't):

(setq wits (mapcar 'intern (split-string (match-string 1))))

-- 
Kevin Rodgers

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

* Re: Help with elisp
@ 2003-07-31 18:13 David Chadd
  0 siblings, 0 replies; 18+ messages in thread
From: David Chadd @ 2003-07-31 18:13 UTC (permalink / raw)



Lawrence, Tom

Wonderful, just the help I needed.  Thank you both very much.

David
-- 
--------------------------
Professor David Chadd
University of East Anglia
Norwich NR4 7TJ, UK
net: <d.chadd@uea.ac.uk>
web: www.uea.ac.uk/~q506/
fax: +44 (0)1263 250454
--------------------------

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

* help with Elisp
@ 2021-10-14 22:18 Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-14 22:21 ` Emanuel Berg via Users list for the GNU Emacs text editor
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-14 22:18 UTC (permalink / raw)
  To: help-gnu-emacs

How can I disable the Elisp syntax helper that appears in the
echo area?

I don't even know what triggers it?

And after it pops up, the text remains even after
I move point.

Annoying!

But I see its value ... if it can just be disabled I'm happy.

GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, cairo version
1.16.0) of 2021-10-04

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




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

* Re: help with Elisp
  2021-10-14 22:18 help with Elisp Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-14 22:21 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-14 22:23 ` [External] : " Drew Adams
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 18+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-14 22:21 UTC (permalink / raw)
  To: help-gnu-emacs

> How can I disable the Elisp syntax helper that appears in
> the echo area?

That's `eldoc-mode', probably!

Thanks to the people at #emacs ...

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




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

* RE: [External] : help with Elisp
  2021-10-14 22:18 help with Elisp Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-14 22:21 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-14 22:23 ` Drew Adams
  2021-10-14 22:34   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-15  4:01   ` Michael Heerdegen
  2021-10-14 22:23 ` Gregory Heytings
  2021-10-14 22:24 ` Óscar Fuentes
  3 siblings, 2 replies; 18+ messages in thread
From: Drew Adams @ 2021-10-14 22:23 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

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

> How can I disable the Elisp syntax helper that appears in the
> echo area?
> 
> I don't even know what triggers it?
> 
> And after it pops up, the text remains even after
> I move point.
> 
> Annoying!
> 
> But I see its value ... if it can just be disabled I'm happy.

`eldoc-mode'

Yeah, it's annoying.
It used to be opt-in, now it's opt-out.

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

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

* Re: help with Elisp
  2021-10-14 22:18 help with Elisp Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-14 22:21 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-14 22:23 ` [External] : " Drew Adams
@ 2021-10-14 22:23 ` Gregory Heytings
  2021-10-14 22:24 ` Óscar Fuentes
  3 siblings, 0 replies; 18+ messages in thread
From: Gregory Heytings @ 2021-10-14 22:23 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs


>
> How can I disable the Elisp syntax helper that appears in the echo area?
>
> I don't even know what triggers it?
>
> And after it pops up, the text remains even after I move point.
>
> Annoying!
>
> But I see its value ... if it can just be disabled I'm happy.
>

(eldoc-mode -1)?



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

* Re: help with Elisp
  2021-10-14 22:18 help with Elisp Emanuel Berg via Users list for the GNU Emacs text editor
                   ` (2 preceding siblings ...)
  2021-10-14 22:23 ` Gregory Heytings
@ 2021-10-14 22:24 ` Óscar Fuentes
  3 siblings, 0 replies; 18+ messages in thread
From: Óscar Fuentes @ 2021-10-14 22:24 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> How can I disable the Elisp syntax helper that appears in the
> echo area?

M-x eldoc-mode




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

* Re: [External] : help with Elisp
  2021-10-14 22:23 ` [External] : " Drew Adams
@ 2021-10-14 22:34   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-14 22:39     ` Gregory Heytings
  2021-10-15  4:01   ` Michael Heerdegen
  1 sibling, 1 reply; 18+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-14 22:34 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

> `eldoc-mode'
>
> Yeah, it's annoying.
> It used to be opt-in, now it's opt-out.

You have to do that each time?

;; (setq emacs-lisp-mode-hook nil)
(defun emacs-lisp-mode-hook-f ()
  ;; ...
  (eldoc-mode -1) )
(add-hook 'emacs-lisp-mode-hook #'emacs-lisp-mode-hook-f)

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




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

* Re: [External] : help with Elisp
  2021-10-14 22:34   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-14 22:39     ` Gregory Heytings
  2021-10-14 22:48       ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 18+ messages in thread
From: Gregory Heytings @ 2021-10-14 22:39 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs


>
> You have to do that each time?
>

(global-eldoc-mode -1)



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

* Re: [External] : help with Elisp
  2021-10-14 22:39     ` Gregory Heytings
@ 2021-10-14 22:48       ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 18+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-14 22:48 UTC (permalink / raw)
  To: help-gnu-emacs

Gregory Heytings wrote:

>> You have to do that each time?
>
> (global-eldoc-mode -1)

Great ... better.

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




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

* Re: [External] : help with Elisp
  2021-10-14 22:23 ` [External] : " Drew Adams
  2021-10-14 22:34   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-15  4:01   ` Michael Heerdegen
  2021-10-15  7:18     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-15 14:29     ` Drew Adams
  1 sibling, 2 replies; 18+ messages in thread
From: Michael Heerdegen @ 2021-10-15  4:01 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams <drew.adams@oracle.com> writes:

> `eldoc-mode'
>
> Yeah, it's annoying.

Why again is it annoying?  Just curious.

TIA,

Michael.




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

* Re: [External] : help with Elisp
  2021-10-15  4:01   ` Michael Heerdegen
@ 2021-10-15  7:18     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-15  7:31       ` Michael Heerdegen
  2021-10-15 14:29     ` Drew Adams
  1 sibling, 1 reply; 18+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-15  7:18 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen wrote:

>> `eldoc-mode'
>>
>> Yeah, it's annoying.
>
> Why again is it annoying? [...]

It appears without you doning anything.

Then it doesn't go away, even when you do move point.
-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: [External] : help with Elisp
  2021-10-15  7:18     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-15  7:31       ` Michael Heerdegen
  2021-10-15  9:52         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Heerdegen @ 2021-10-15  7:31 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> It appears without you doning anything.
>
> Then it doesn't go away, even when you do move point.

And it's not equally useful at the same time?  Can you keep syntax
(argument order) of thousands of Elisp functions in your head?

I could not live without it.  For the cost that it covers the -
otherwise empty - echo area.

Michael.




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

* Re: [External] : help with Elisp
  2021-10-15  7:31       ` Michael Heerdegen
@ 2021-10-15  9:52         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 18+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-15  9:52 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen wrote:

> And it's not equally useful at the same time? Can you keep
> syntax (argument order) of thousands of Elisp functions in
> your head?

Ha! Thanks, but I don't think I use that many :)

I wonder how many I used? You could count unique words in your
Elisp source I guess, and remove comments and strings.
Would that give a good estimate?

Not that it matters ...

> I could not live without it. For the cost that it covers the
> - otherwise empty - echo area.

Yep, I see the use case for people who like it, I don't want
the computer to do or say anything unless I push
a button first.

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




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

* RE: [External] : help with Elisp
  2021-10-15  4:01   ` Michael Heerdegen
  2021-10-15  7:18     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-15 14:29     ` Drew Adams
  1 sibling, 0 replies; 18+ messages in thread
From: Drew Adams @ 2021-10-15 14:29 UTC (permalink / raw)
  To: Michael Heerdegen, help-gnu-emacs@gnu.org

> > `eldoc-mode'  Yeah, it's annoying.
> 
> Why again is it annoying?  Just curious.

Not important; didn't mean to exaggerate.

To me it's noise.  If I want to know what
it shows me I'll ask, and in those cases
I usually want to know more than what it
shows me.

Probably also a case of habit and not a
feeling of needing it.

I wouldn't say that it's _particularly_
noisy or annoying.  Just one user who
doesn't get much from it, I guess.



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

end of thread, other threads:[~2021-10-15 14:29 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-14 22:18 help with Elisp Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-14 22:21 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-14 22:23 ` [External] : " Drew Adams
2021-10-14 22:34   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-14 22:39     ` Gregory Heytings
2021-10-14 22:48       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-15  4:01   ` Michael Heerdegen
2021-10-15  7:18     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-15  7:31       ` Michael Heerdegen
2021-10-15  9:52         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-15 14:29     ` Drew Adams
2021-10-14 22:23 ` Gregory Heytings
2021-10-14 22:24 ` Óscar Fuentes
  -- strict thread matches above, loose matches on Subject: below --
2003-07-31 18:13 Help with elisp David Chadd
     [not found] <mailman.767.1059641390.8231.help-gnu-emacs@gnu.org>
2003-07-31 11:30 ` lawrence mitchell
2003-07-31 11:59 ` Tom Capey
2003-07-31 15:59   ` Kevin Rodgers
2003-07-30 18:06 David Chadd

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