help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: undo custom delete


From: Johan Bockgård
Subject: Re: undo custom delete
Date: Wed, 05 Oct 2005 19:49:09 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

"Shug Boabby" <Shug.Boabby@gmail.com> writes:

> how can i get the first element from the list, and once i have it
> test which type it is, reference it's components and delete it from
> the list if need be.

All of this is thoroughly explained in the "Emacs Lisp Reference
Manual".

Lists are constructed from "cons cells".

The expression
    (cons 1 (cons 2 (cons 3 nil)))
builds the list
    (1 2 3)
which can also be represented as
    (1 . (2 . (3 . nil))).

`car' picks out the left half (the "car") of a pair / the first
      element of a list

`cdr' picks out the right half (the "cdr") of a pair / the rest
      of a list

(car '(1 2 3))                => 1
(car '(1 . (2 . (3 . nil))))  => 1 ; this is exactly the same as above
(car '("text" . position))    => "text"
(cdr '("text" . position))    => position

`stringp' is used to test an object for being a string.

(stringp "text")  => t
(stringp 0)      => nil

Maybe you should start with "Introduction to Programming in Emacs
Lisp", http://www.gnu.org/software/emacs/emacs-lisp-intro/

If you use the CVS version of emacs then the Emacs manual, Elisp
manual, and Elisp Intro manual are all included.


You can use `M-x ielm RET' to practice evaluating simple Lisp
expressions:

*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (+ 1 2)
3
ELISP> (list 'a 'b 'c)
(a b c)

ELISP> (cons 'a 'b)
(a . b)

You can use C-x C-e (eval-last-sexp) to evaluate Lisp expressions
anywhere.

> it doesn't seem to record the operation that was performed

Correct. Only changes to the text are recorded, not which command was
used.

-- 
Johan Bockgård


reply via email to

[Prev in Thread] Current Thread [Next in Thread]