Subject: bug#20141: 24.4.91; Helm is broken after last changes in eieio

From: Tassilo Horn <[email-masked]>
Date: Thu, 19 Mar 2015 16:46:36 +0100

Stefan Monnier <[email-masked]> writes:

>> (eieio-class-slots 'helm-source)
> [...]
>> Until today it returned (name), now, you get
>> ([cl-struct-cl-slot-descriptor name nil t nil])
>
> eieio-class-slots is new in Emacs-25, so it's OK if it's different
> from yesterday.  But indeed, it looks I failed to adapt object-slots.
> Does the patch below fix the problems people are seeing?

Yes, it seems so.  However, I still get the error from yasnippet.

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-type-argument integerp nil)
  yas--populate-template([cl-struct-yas--template nil nil nil nil nil nil nil nil nil nil nil nil] :table [cl-struct-yas--table "haskell-mode" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ( ...)) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ( ...)) nil (keymap)] :key "new" :content "newtype ${1:Type} = $1 { un$1 :: ${2:a} } ${3:deriving (${4:Show, Eq})}" :name "newtype" :group nil :condition (= (length "new") (current-column)) :expand-env nil :file "/home/horn/.emacs.d/elpa/haskell-mode-20150317.204/snippets/haskell-mode/newtype" :keybinding nil :uuid "newtype")
  yas--define-snippets-1(("new" "newtype ${1:Type} = $1 { un$1 :: ${2:a} } ${3:deriving (${4:Show, Eq})}" "newtype" (= (length "new") (current-column)) nil nil "/home/horn/.emacs.d/elpa/haskell-mode-20150317.204/snippets/haskell-mode/newtype" nil nil) [cl-struct-yas--table "haskell-mode" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ( ...)) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ( ...)) nil (keymap)])
--8<---------------cut here---------------end--------------->8---

But I think the code that throws is probably too fragile anyway:

--8<---------------cut here---------------start------------->8---
(defun yas--populate-template (template &rest args)
  "Helper function to populate TEMPLATE with properties."
  (while args
    (aset template
          (position (intern (substring (symbol-name (car args)) 1))
                    (mapcar #'car (get 'yas--template 'cl-struct-slots)))
          (second args))
    (setq args (cddr args)))
  template)

;; the yas--template struct is defined like this
(defstruct (yas--template (:constructor yas--make-blank-template))
  "A template for a snippet."
  key
  content
  name
  condition
  expand-env
  file
  keybinding
  uuid
  menu-binding-pair
  group      ;; as dictated by the #group: directive or .yas-make-groups
  perm-group ;; as dictated by `yas-define-menu'
  table
  )
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo