Permalink
Browse files

Remove aput, and with it the obsolete assoc package

  • Loading branch information...
glasserc committed Jun 28, 2012
1 parent 9f02ace commit 585e24066fd1bd921ff68c12ebb105a7e62d67ee
Showing with 5 additions and 8 deletions.
  1. +5 −8 lisp/ethan-wspace.el
View
@@ -73,15 +73,14 @@
;; Currently each whitespace type is represented as an association list
;; with keys :check, :clean, and :highlight, and values symbols of functions
;; or whatever.
-(require 'assoc)
(defvar ethan-wspace-types nil
"The list of all known whitespace types.")
;; Define the format/structure for the each wspace type. Right now it's
;; (name . (:foo bar :baz quux)), aka (name :foo bar :baz :quux).
(defun ethan-wspace-add-type (name args)
- (aput 'ethan-wspace-types name args))
+ (push (name args) 'ethan-wspace-types))
(defun ethan-wspace-get-type (name)
(or (assq name ethan-wspace-types)
@@ -92,12 +91,10 @@
(defun ethan-wspace-all-error-types ()
"The list of all currently-defined types as symbol names."
- ;; Repeated loads could define types multiple times, so we define
- ;; this slightly ugly mechanism that stores symbols uniquely in an
- ;; association list, and then pulls out the names.
- (let ((type-names nil))
- (mapc '(lambda (type) (aput 'type-names (car type) t)) ethan-wspace-types)
- (mapcar 'car type-names)))
+ ;; Repeated loads could define types multiple times, so we
+ ;; deduplicate before returning.
+ (let ((type-names (mapcar 'car ethan-wspace-types)))
+ (delete-dups type-names)))
(defun ethan-wspace-buffer-errors ()
(let ((errors nil))

8 comments on commit 585e240

@dgutov

This comment has been minimized.

Show comment Hide comment
@dgutov

dgutov Jun 28, 2012

Contributor

The second argument of push shouldn't be quoted:

Debugger entered--Lisp error: (error "(quote ethan-wspace-types) is not a valid place expression")
  signal(error ("(quote ethan-wspace-types) is not a valid place expression"))
  error("%S is not a valid place expression" (quote ethan-wspace-types))
  gv-get((quote ethan-wspace-types) #[(getter setter) "�\303    \nE!\207" [setter v getter cons] 4])
  ...
Contributor

dgutov replied Jun 28, 2012

The second argument of push shouldn't be quoted:

Debugger entered--Lisp error: (error "(quote ethan-wspace-types) is not a valid place expression")
  signal(error ("(quote ethan-wspace-types) is not a valid place expression"))
  error("%S is not a valid place expression" (quote ethan-wspace-types))
  gv-get((quote ethan-wspace-types) #[(getter setter) "�\303    \nE!\207" [setter v getter cons] 4])
  ...
@glasserc

This comment has been minimized.

Show comment Hide comment
@glasserc

glasserc Jun 28, 2012

Owner

Oops. I'm an idiot. Thanks. Pushed.

Owner

glasserc replied Jun 28, 2012

Oops. I'm an idiot. Thanks. Pushed.

@dgutov

This comment has been minimized.

Show comment Hide comment
@dgutov

dgutov Jun 28, 2012

Contributor

No problem. I missed another error, though (same line):

Debugger entered--Lisp error: (void-function name)
  (name args)
  (cons (name args) ethan-wspace-types)
  (setq ethan-wspace-types (cons (name args) ethan-wspace-types))
  (push (name args) ethan-wspace-types)
Contributor

dgutov replied Jun 28, 2012

No problem. I missed another error, though (same line):

Debugger entered--Lisp error: (void-function name)
  (name args)
  (cons (name args) ethan-wspace-types)
  (setq ethan-wspace-types (cons (name args) ethan-wspace-types))
  (push (name args) ethan-wspace-types)
@glasserc

This comment has been minimized.

Show comment Hide comment
@glasserc

glasserc Jun 28, 2012

Owner

It's amazing how many bugs I can introduce in one line of untested changes. I tested it now, I think it should be fine. Thanks again!

Owner

glasserc replied Jun 28, 2012

It's amazing how many bugs I can introduce in one line of untested changes. I tested it now, I think it should be fine. Thanks again!

@glasserc

This comment has been minimized.

Show comment Hide comment
@glasserc

glasserc Jun 28, 2012

Owner

Wait, that can't be right.. I think something's wrong with my testing setup. One second..

Owner

glasserc replied Jun 28, 2012

Wait, that can't be right.. I think something's wrong with my testing setup. One second..

@dgutov

This comment has been minimized.

Show comment Hide comment
@dgutov

dgutov Jun 28, 2012

Contributor

Probably.

Quoting the form (name args) makes the interpreter not evaluate its elements, so this way ethan-wspace-types will only contain lists with symbols name and args inside. You're looking for (cons name args) (or maybe (list name args), depending on how you're using the values). push is a special case because it's a macro, but it evaluates its first argument like usual.

No need to thank me in commit messages. :)

Contributor

dgutov replied Jun 28, 2012

Probably.

Quoting the form (name args) makes the interpreter not evaluate its elements, so this way ethan-wspace-types will only contain lists with symbols name and args inside. You're looking for (cons name args) (or maybe (list name args), depending on how you're using the values). push is a special case because it's a macro, but it evaluates its first argument like usual.

No need to thank me in commit messages. :)

@glasserc

This comment has been minimized.

Show comment Hide comment
@glasserc

glasserc Jun 28, 2012

Owner

I was running an old version of my own software by accident. It's a wonder they even let me use github. Sorry for the madness, I hope everything works now..

Owner

glasserc replied Jun 28, 2012

I was running an old version of my own software by accident. It's a wonder they even let me use github. Sorry for the madness, I hope everything works now..

@dgutov

This comment has been minimized.

Show comment Hide comment
@dgutov

dgutov Jun 28, 2012

Contributor

Yep. All good!

Contributor

dgutov replied Jun 28, 2012

Yep. All good!

Please sign in to comment.