(Emacs)~made :display use-package manager more idiomatic

When I originally programmed this function I was essentially acting as
a code-monkey i.e. "JUST WORK PLEASE".  Looking at the code now I see
there's a simple function to do essentially the same task, converting
from the iterative format I was using to the cleaner and more
functional ~mapcar~.
This commit is contained in:
2023-07-11 21:33:53 +01:00
parent d9712a799f
commit 46f38953c9

View File

@@ -939,12 +939,14 @@ pseudo language.
("lambda" . "λ") ("lambda" . "λ")
#+end_example #+end_example
** Window management ** Window management
Emacs' default window management is quite bad, eating other windows Emacs' default window management is quite bad, eating other windows on
and not particularly caring for the current window setup. Thankfully a whim and not particularly caring for the current window setup.
you can change this via the ~display-buffer-alist~ which matches Thankfully you can change this via the ~display-buffer-alist~ which
buffer names with how the window for the buffer should be displayed. matches buffer names with how the window for the buffer should be
I add a use-package keyword to make ~display-buffer-alist~ records displayed. I add a use-package keyword to make ~display-buffer-alist~
within use-package. records within use-package.
I have no idea whether it's optimal AT ALL, but it works for me.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package window (use-package window
:straight nil :straight nil
@@ -965,14 +967,11 @@ within use-package.
(defun use-package-handler/:display (name _keyword args rest state) (defun use-package-handler/:display (name _keyword args rest state)
(use-package-concat (use-package-concat
(use-package-process-keywords name rest state) (use-package-process-keywords name rest state)
(let ((arg args) (mapcar
forms) #'(lambda (arg)
(while arg
(add-to-list 'forms
`(add-to-list 'display-buffer-alist `(add-to-list 'display-buffer-alist
',(car arg))) ',arg))
(setq arg (cdr arg))) args)))))
forms)))))
#+end_src #+end_src
*** Some display records *** Some display records
Using the ~:display~ keyword, setup up some ~display-buffer-alist~ Using the ~:display~ keyword, setup up some ~display-buffer-alist~