From: Johan Andersson <johan.rejeep@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Always return a list
Date: Thu, 25 Nov 2010 11:05:17 +0100 [thread overview]
Message-ID: <AANLkTin5UEraYrzdKYTET5SEb_kBFwNgDt9VzyteO08W@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 911 bytes --]
Hey,
I have a struct. To make it simple, lets assume this is the struct:
(defstruct package name deps)
The deps slot is for the package dependencies. Example of packages:
(make-package :name "one" :deps "two")
(make-package :name "two" :deps '("three" "four"))
To make it easier to use the dependencies from the code, when I
call (package-deps package) I always want it to return a list. So:
(let ((one (make-package :name "one" :deps "two"))
(two (make-package :name "two" :deps '("three" "four"))))
(print (package-deps one)) ;; => ("two")
(print (package-deps two)) ;; => ("three" "four")
)
I tried doing this using an advice, with no success:
(defadvice package-deps (around package-deps-around)
(let ((deps ad-do-it))
(if (listp deps) deps (list deps))))
(ad-activate 'package-deps)
Can I do this in a way that doesn't require that much of a hack?
Thanks!
[-- Attachment #2: Type: text/html, Size: 1453 bytes --]
next reply other threads:[~2010-11-25 10:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-25 10:05 Johan Andersson [this message]
[not found] <mailman.0.1290679543.16375.help-gnu-emacs@gnu.org>
2010-11-25 23:03 ` Always return a list Tim X
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=AANLkTin5UEraYrzdKYTET5SEb_kBFwNgDt9VzyteO08W@mail.gmail.com \
--to=johan.rejeep@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/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.