all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Always return a list
@ 2010-11-25 10:05 Johan Andersson
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Andersson @ 2010-11-25 10:05 UTC (permalink / raw)
  To: help-gnu-emacs

[-- 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 --]

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

end of thread, other threads:[~2010-11-25 23:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.0.1290679543.16375.help-gnu-emacs@gnu.org>
2010-11-25 23:03 ` Always return a list Tim X
2010-11-25 10:05 Johan Andersson

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.