From: "Drew Adams" <drew.adams@oracle.com>
To: "'Harry Putnam'" <reader@newsguy.com>, <help-gnu-emacs@gnu.org>
Subject: RE: how to load code conditional on uid
Date: Sat, 12 Nov 2011 06:36:57 -0800 [thread overview]
Message-ID: <09C3CFA2787F439387815B2EF709341D@us.oracle.com> (raw)
In-Reply-To: <87sjltpoyv.fsf@newsguy.com>
> C-h f member <RET> shows something that for a lightweight like me is
> your basic greek.
>
> (member ELT LIST)
> Return non-nil if ELT is an element of LIST. Comparison
> done with `equal'.
(member ELT LIST) shows the calling sequence of function `member'.
ELT is the first parameter, LIST is the second.
See (Elisp manual) `Conventions' for documentation conventions.
Use `g' to go to a section of the manual such as `Conventions'.
> The value is actually the tail of LIST whose car is ELT.
This completes the description of the function signature: its parameters are ELT
and LIST, and its return value is the (longest) tail of LIST whose first element
is ELT. That is, it returns nil if element ELT is not a member of LIST, and if
it is a member then it returns a sublist (a tail) whose first element is ELT.
> Doing an index search in `emacs-lisp-intro' on `member' shows
> no hits so apparently it is not used or explained in that document.
It is an pedagogical intro, similar to a tutorial. The reference manual for
Emacs Lisp is the Elisp manual. There, `i member' gives you more info about the
function.
> Not sure how I would find out what ELT means.
Read the doc conventions section mentioned above.
> Elisp manaual on ELT shows: Function: elt sequence index
That's a function named `elt'. It has nothing to do with the `member'
function's parameter referred to as ELT in its calling-sequence description.
But if you looked up `member' in the Elisp manual you would find this:
Function: member object list
The function `member' tests to see whether OBJECT is a member of
LIST, comparing members with OBJECT using `equal'. If OBJECT is a
member, `member' returns a list starting with its first occurrence
in LIST. Otherwise, it returns `nil'.
...
ELT and OBJECT are just names - ways to refer to the first parameter.
> But at a glance it sounds as if it could be a uid like 1000 or maybe
> (user-uid).
> (when (member 1000 (1000 1001 1002))...
You correctly understood that the first parameter is tested to see if it is an
element of the second parameter (a list). The only thing you didn't get was
that `member', as an ordinary function, evaluates its arguments, so if you want
to pass it the constant list (1000 1001 1002) then you need to quote that sexp:
(when (member 1000 '(1000 1001 1002))...
Otherwise, Lisp tries to evaluate the sexp (1000 1001 1002). In doing that, it
expects the first element, 1000, to be a _function_ and tries to apply that
function to the other elements - error.
If you add the quote mark then the sexp to be evaluated is (quote (1000 1001
1002)), which evaluates to the list (1000 1001 1002).
> or maybe (when (member (user-uid) (1000 1001 1002))
Again, correct, except for the missing quote mark.
You just need to spend a little more time reading the Lisp intro and then some
of the Elisp manual. IOW, do a little more homework. This too will help:
http://www.emacswiki.org/emacs/LearnEmacsLisp
next prev parent reply other threads:[~2011-11-12 14:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-11 13:33 how to load code conditional on uid Harry Putnam
2011-11-11 14:44 ` Drew Adams
2011-11-11 15:26 ` Harry Putnam
2011-11-11 15:45 ` Drew Adams
2011-11-11 22:46 ` Harry Putnam
2011-11-12 11:19 ` Harry Putnam
2011-11-12 14:36 ` Drew Adams [this message]
2011-11-13 23:14 ` Harry Putnam
[not found] <mailman.258.1321018489.798.help-gnu-emacs@gnu.org>
2011-11-12 2:40 ` Jason Rumney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=09C3CFA2787F439387815B2EF709341D@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=reader@newsguy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.