uniquify override

This commit is contained in:
Nathan McCarty 2023-05-11 11:53:05 -04:00
parent 39f36f39ab
commit 98dbc34075
No known key found for this signature in database
1 changed files with 74 additions and 0 deletions

View File

@ -224,6 +224,80 @@ Now setup our theming
'(highlight-indent-guides-stack-character-face :foreground "#a580e2"))
#+end_src
** Uniquify
First, we need to work around an issue with perspective, using some code taken from [[https://github.com/Bad-ptr/persp-mode.el/issues/104#issuecomment-1038784878][persp-mode.el #104]]:
#+begin_src emacs-lisp
(with-eval-after-load "persp-mode"
(defun persp--wc-to-writable (wc)
(cl-labels
((wc-to-writable
(it)
(cond
((and it (listp it))
(cl-destructuring-bind (head . tail) it
(cond
;; ((listp head)
;; (cons (wc-to-writable head)
;; (wc-to-writable tail)))
((eq 'parameters head)
(let ((rw-params
(delq nil
(mapcar
#'(lambda (pc)
(when
(and
(alist-get (car pc) window-persistent-parameters)
(persp-elisp-object-readable-p (cdr pc)))
pc))
tail))))
(if rw-params
`(parameters
,@rw-params)
:delete)))
(t
(let ((new-head (wc-to-writable head))
(new-tail (wc-to-writable tail)))
(when (eq :delete new-tail)
(setq new-tail nil))
(if (eq :delete new-head)
new-tail
(cons new-head
new-tail)))))))
((bufferp it)
(if (buffer-live-p it)
(buffer-name it)
"*Messages*"))
((markerp it)
(marker-position it))
(t it))))
(wc-to-writable wc)))
(setq persp-window-state-get-function
#'(lambda (&optional frame rwin)
(when (or rwin (setq rwin (frame-root-window
(or frame (selected-frame)))))
(window-state-get rwin nil))))
(add-hook 'persp-before-save-state-to-file-functions
#'(lambda (_fname phash _rpfp)
(mapc
#'(lambda (persp)
(if persp
(setf (persp-window-conf persp)
(persp--wc-to-writable (persp-window-conf persp)))
(setq persp-nil-wconf
(persp--wc-to-writable persp-nil-wconf))))
(persp-persps phash)))))
#+end_src
Then we can override persp's override of uniquify:
#+begin_src emacs-lisp
;; doom's `persp-mode' activation disables uniquify, b/c it says it breaks it.
;; It doesn't cause big enough problems for me to worry about it, so we override
;; the override. `persp-mode' is activated in the `doom-init-ui-hook', so we add
;; another hook at the end of the list of hooks to set our uniquify values.
(add-hook! 'doom-init-ui-hook
:append ;; ensure it gets added to the end.
#'(lambda () (require 'uniquify) (setq uniquify-buffer-name-style 'forward)))
#+end_src
Include part of the path to uniquify buffer names
#+begin_src emacs-lisp
(setq uniquify-buffer-name-style 'forward)