help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EIEIO accessing class slots


From: pillule
Subject: Re: EIEIO accessing class slots
Date: Fri, 11 Jun 2021 01:04:18 +0200

Stefan Monnier via Users list for the GNU Emacs text editor 
<help-gnu-emacs@gnu.org> writes:

>> How can I accede to the initarg of an eieio class?
>
> What do you mean exactly by that and why do you need that?
>

I have a class 'moirai-dired-side' ; I make instances from it that I store as 
frame parameters, eg, 'moirai-dired-side-left' or 'moirai-dired-side-right'.

The following function is a function usable by 'display-buffer'.
At the moment of its call, an object of the class may already exist, or not.
Depending from which window it is called, I want to adjust the get-or-create of 
the object.
I could use 'left as I know it is the default value, but this is cutting grass 
under foots for future customizations.

This need adjustments but I hope you get the idea.

(defun display-buffer-in-dired-side-window (buffer alist)
  "Display BUFFER in a side window with `dired-side-window-parameters' as ALIST.

The side parameter that may be inherited from a selected dired side window.
Only apply for buffers using `dired-mode' without `inhibit-same-window'."
  (when (and (dired-buffer-p buffer)
             (not (cdr (assq 'inhibit-same-window alist))))
    (let* ((side (or (window-parameter (selected-window) 'window-side)
                     (alist-get 'side (oref-default 'moirai-dired-side 
:display-alist))))
           (strand-name (intern (concat (prin1-to-string 'moirai-dired-side)
                                        "-"
                                        (prin1-to-string side))))
           (strand (morai-get-or-create 'moirai-dired-side strand-name)))
      (let ((window (display-buffer-in-side-window buffer (cdr (oref strand 
:display-alist)))))
        (oset strand :buffer buffer)
        (oset strand :window window)
        (morai-update-prev-buffers strand window)
        window))))

>> ;; apparently this is not an eieio-class ?!
>> (eieio--class-p 'morai-dired-side)
>> ;; => nil
>
> `eieio--class-p` checks if the arg is a class object, where you passed
> a symbol which is the *name* of the class object.

Then how to access to the object ?



--



reply via email to

[Prev in Thread] Current Thread [Next in Thread]