-
-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from (setf (get-default ...)) to hooks #381
Comments
Those are usability problems indeed. My guts tell me we'd rather do it in pure CL though. |
What do you mean "pure CL"? |
With standard CL mechanism, thus without the hooks library. |
How though? I think we can only to it with `initialize-instance
:after`, but this can be defined only _once_.
Say we already use the :after in the Next code base, then the user won't
be able to reuse it (without breaking Next).
I believe hooks solve this precise problem (among other things) by
exposing a _list_ of handlers.
Am I missing something?
|
Cant say about hooks, but that syntax is rather verbose, would be interesting a simpler interface to accessors as (with 'minibuffer (setf minibuffer-font-size "1em"
minibuffer-style '((body ...)))) As in Python context-manager. |
What you propose is not possible as is, because we don't want to expose
global variables.
We need new functions, something like
```
(set-interface-default 'minibuffer-style "1em")
```
which would add a handler to the `after-init-hook`.
Similarly, we can add helper functions to set values for all
running instances of a class, e.g.
```
(set-all-buffers 'scroll-distance 20)
(push-all-buffers 'modes 'vi-normal-mode)
```
Thoughts?
|
That's even better. |
What do you mean? Emacs' setq does not deal with classes. |
I thought a little bit about this and I realized a big issue with hooks: if they are not named, the user essentially loses control over what's in it. Lambda are hard to introspect (you can disassemble them...) plus they cannot be compared, which means that adding the same lambda twice to the hook will effectively run it twice. We could write macros to automatically name the functions, but automatic names don't really help telling what's inside the function, so we've got the same introspection problem. So here is my suggest: in their Example: (defun my-minibuffer-defaults (minibuffer)
(setf
(minibuffer-line-height minibuffer) "1.1em"
(minibuffer-font-size minibuffer) "1.1em"))
(defun my-interface-defaults ()
(push (search-engines *interface*) "https://foo.org...")
(hooks:add-hook (hooks:object-hook *interface* 'minibuffer-make-hook)
#'my-minibuffer-defaults))
(hooks:add-hook '*after-init-hook* #'my-interface-defaults) Pros:
Cons:
|
Is it required that the first |
You mean the configuration of minibuffer-hook? Yes, because the hook only exists once |
Closing this in favor of #419. |
Hooks could effectively supersede the setf-ability of
get-default
.The latter has multiple issues:
init.lisp
, every restart from the REPL will stack more of the same values.The text was updated successfully, but these errors were encountered: