1

I am trying to modify a slot in a class (created with EIEIO library). I can access the slot with (oref-default 'helm-source-ffiles filtered-candidate-transformer) and that returns

(helm-ff-sort-candidates
 (lambda
  (candidates _source)
  (cl-loop for f in candidates for ff =
        (helm-ff-filter-candidate-one-by-one f)
        when ff collect ff)))

a list of two items. I am trying to add helm-adaptive-sort to the end of that list. However everything I have tried results in an error. Here is what I am trying to do.

(oset-default 'helm-source-ffiles
              filtered-candidate-transformer
              (helm-ff-sort-candidates
               (lambda
                 (candidates _source)
                 (cl-loop for f in candidates for ff =
                          (helm-ff-filter-candidate-one-by-one f)
                          when ff collect ff))
               helm-adaptive-sort))

that results in Symbol’s value as variable is void: helm-adaptive-sort. If I quote it I get the error Can’t set default to a sexp that gets evaluated again. The only thing that I have found that doesn't give an error is storing my list in a variable then calling it like this (oset-default 'helm-source-ffiles filtered-candidate-transformer (list foo)). However that wraps it in an extra set of quotes. How do I set a slot in a class?

Drew
  • 75,699
  • 9
  • 109
  • 225
Prgrm.celeritas
  • 849
  • 6
  • 15
  • EIEIO does not support this functionality: the default value is supposed to be set once and for all in the definition of the class. What are you trying to do? – Stefan Jul 28 '18 at 15:06
  • An instance of class `helm-source-ffiles` is used to to create a helm command. The slot `filtered-candidate-transformer` contains of list of functions to filter the candidates. I want to add another function to that list (`helm-adaptive-sort`). I can then update the instance used by the helm command and my function will be applied. – Prgrm.celeritas Jul 28 '18 at 15:51
  • AFAICT the `filtered-candidate-transformer` slot is not a class-slot, so why don't you just modify it in the instance ("object") rather than trying to modify the default value for the whole class? – Stefan Jul 28 '18 at 16:12
  • I am afraid that I don’t know the difference between a class slot and object slot. How would I do that? – Prgrm.celeritas Jul 28 '18 at 17:58
  • https://github.com/emacs-helm/helm/blob/master/helm-files.el#L669 – Prgrm.celeritas Jul 28 '18 at 18:04
  • "class slots" are those rare slots which live in the class rather than in the instances (i.e. the slot is shared by all instances). They're declared with `:allocation :class` (and they don't exist in CLOS). So why do you use `(oset-default 'helm-source-ffiles ...)` inastead of using `(oset ...)` ? – Stefan Jul 28 '18 at 18:37
  • You are right, that worked. Just setting the objects slot. It seems I was just confused about what need to be done. – Prgrm.celeritas Jul 29 '18 at 02:57

1 Answers1

0

I got my answer from Stephan in the comments, but I will elaborate encase anyone else has a similar question. Turns out that I was approaching this wrong. You can’t use oset-default to set a class default value. Instead you should use oset to overwrite the slot of an instance of the class (an object).

Prgrm.celeritas
  • 849
  • 6
  • 15