Hi define-word developers,
Thanks very much for an extremely useful addition to emacs. I have a slight problem in that my messages buffer at present is a bit crowded (treemacs woes, but that's for another issue), and so I keep missing my define-word
text. I thought I would do a quick hack and place them on a dedicated buffer (akin to what is desired in [1]), but sadly I failed miserably; my elisp is rather limited, I'm afraid. At any rate, here's what I tried.
I started by defining a function that I thought could do the displaying:
(defun my/display-word (&rest args)
"Create a buffer for display word instead of using messages."
(interactive)
(let
((buffer (generate-new-buffer "Define Word")))
(set-buffer buffer)
(set-buffer-major-mode buffer)
(apply 'insert args)
(display-buffer buffer))
)
This seems to work vaguely correctly, i.e.:
(my/display-word "ab" "ba")
Produces the intended result. I then tried to map this via define-word-displayfn-alist
but this is where I got stuck. I tried a few variations:
(setq define-word-displayfn-alist
'((define-word-default-service . 'my/display-word)))
(add-to-list 'define-word-displayfn-alist
'("wordnik" . 'my/display-word))
(add-to-list 'define-word-displayfn-alist
'(define-word-default-service . 'my/display-word))
But on all cases, if I call:
(cdr (assoc define-word-default-service define-word-displayfn-alist))
I keep getting nil
. I also tested this by calling:
(define-word-displayfn define-word-default-service)
Which seems to always return message
, ignoring my alist
association. I think I am somehow incorrectly setting up the alist
; I wonder if I am passing a "reference" to the variable define-word-default-service
rather than its value. Also, I don't understand why adding the string directly has no effect. A bit lost as you can see :-) Could you please shed some light on what I am doing wrong?
Many thanks for your time.
[1] https://emacs.stackexchange.com/questions/45490/changing-display-function-in-define-word-package