Skip to content

Commit

Permalink
Remove aput, and with it the obsolete assoc package
Browse files Browse the repository at this point in the history
  • Loading branch information
glasserc committed Jun 28, 2012
1 parent 9f02ace commit 585e240
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lisp/ethan-wspace.el
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@
;; Currently each whitespace type is represented as an association list ;; Currently each whitespace type is represented as an association list
;; with keys :check, :clean, and :highlight, and values symbols of functions ;; with keys :check, :clean, and :highlight, and values symbols of functions
;; or whatever. ;; or whatever.
(require 'assoc)


(defvar ethan-wspace-types nil (defvar ethan-wspace-types nil
"The list of all known whitespace types.") "The list of all known whitespace types.")


;; Define the format/structure for the each wspace type. Right now it's ;; Define the format/structure for the each wspace type. Right now it's
;; (name . (:foo bar :baz quux)), aka (name :foo bar :baz :quux). ;; (name . (:foo bar :baz quux)), aka (name :foo bar :baz :quux).
(defun ethan-wspace-add-type (name args) (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) (defun ethan-wspace-get-type (name)
(or (assq name ethan-wspace-types) (or (assq name ethan-wspace-types)
Expand All @@ -92,12 +91,10 @@


(defun ethan-wspace-all-error-types () (defun ethan-wspace-all-error-types ()
"The list of all currently-defined types as symbol names." "The list of all currently-defined types as symbol names."
;; Repeated loads could define types multiple times, so we define ;; Repeated loads could define types multiple times, so we
;; this slightly ugly mechanism that stores symbols uniquely in an ;; deduplicate before returning.
;; association list, and then pulls out the names. (let ((type-names (mapcar 'car ethan-wspace-types)))
(let ((type-names nil)) (delete-dups type-names)))
(mapc '(lambda (type) (aput 'type-names (car type) t)) ethan-wspace-types)
(mapcar 'car type-names)))


(defun ethan-wspace-buffer-errors () (defun ethan-wspace-buffer-errors ()
(let ((errors nil)) (let ((errors nil))
Expand Down

8 comments on commit 585e240

@dgutov
Copy link
Contributor

@dgutov dgutov commented on 585e240 Jun 28, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@dgutov
Copy link
Contributor

@dgutov dgutov commented on 585e240 Jun 28, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@dgutov
Copy link
Contributor

@dgutov dgutov commented on 585e240 Jun 28, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@dgutov dgutov commented on 585e240 Jun 28, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. All good!

Please sign in to comment.