emacs: Remove popper and related functions, add more harpoon bindings

This commit is contained in:
Joseph Ferano 2025-06-24 18:52:34 +07:00
parent 81ec6fa96c
commit 2e7c33bef4

View File

@ -918,6 +918,7 @@ Fill region is great, except when you don't need it...
(kbd "SPC p") project-prefix-map
(kbd "SPC q") 'kill-buffer-and-window
(kbd "SPC h") 'help-command
(kbd "SPC k") 'kill-this-buffer
(kbd "SPC hf") 'helpful-callable
(kbd "SPC hv") 'helpful-variable
(kbd "SPC hk") 'helpful-key
@ -995,20 +996,8 @@ Fill region is great, except when you don't need it...
#+end_src
** Buffers
#+begin_src emacs-lisp
(defun joe/kill-this-buffer-or-popup ()
(interactive)
"Kill the buffer normally, but if it's a popper popup, call the popper version"
(with-current-buffer (current-buffer)
(if (or (eq popper-popup-status nil)
(eq popper-popup-status 'raised))
(kill-this-buffer)
(popper-kill-latest-popup))))
(global-set-key (kbd "C-x k") #'joe/kill-this-buffer-or-popup)
(when (boundp 'evil-mode)
(evil-define-key 'normal joe/evil-space-mode-map
(kbd "SPC k") #'joe/kill-this-buffer-or-popup))
(global-set-key (kbd "C-x k") #'kill-this-buffer)
(global-set-key (kbd "C-x M-k") #'kill-buffer)
(require 'all-the-icons-ibuffer)
@ -1057,6 +1046,9 @@ Harpoon lets you quickly switch between bookmarked buffers
(global-set-key (kbd "M-3") 'harpoon-go-to-3)
(global-set-key (kbd "M-4") 'harpoon-go-to-4)
(global-set-key (kbd "M-5") 'harpoon-go-to-5)
(global-set-key (kbd "M-6") 'harpoon-go-to-6)
(global-set-key (kbd "M-7") 'harpoon-go-to-7)
(global-set-key (kbd "M-8") 'harpoon-go-to-8)
(global-set-key (kbd "C-c h 1") 'harpoon-go-to-1)
(global-set-key (kbd "C-c h 2") 'harpoon-go-to-2)
@ -1205,99 +1197,6 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really
(beframe-unassume-current-frame-buffers-selectively (list curr))))
(evil-global-set-key 'normal (kbd "SPC b f") #'joe/beframe-switch-and-unassume)
#+end_src
*** COMMENT Popper
#+begin_src emacs-lisp
(require 'popper)
(setq popper-reference-buffers
'("\\*compilation\\*" compilation-mode
"^\\*vterm\\*" vterm-mode
"^\\*Flymake.*" flymake-mode
"^\\*Flycheck.*" flycheck-error-list-mode
"^\\*Occur\\*$" occur-mode
"^\\*lsp-help\\*" lsp-help-mode
"^\\*eldoc\\*" special-mode
"^\\*godot.*" godot-mode
"^\\*ert\\*" ert-results-mode
"^\\*xref\\*" xref-mode
"^\\*HTTP Response\\*" javascript-mode
"^\\*SQL.*" sql-interactive-mode
"^\\*cargo-test\\*" cargo-test-mode
"^\\*cargo-run\\*" cargo-run-mode
"^\\*rustic-compilation\\*" rustic-compilation-mode
"^\\*ansi-term\\*$" term-mode
;; "^\\*Async Shell Command\\*$" shell-mode
"^\\*Async Shell Command\\*$"
("^\\*Warnings\\*$" . hide)
help-mode
helpful-mode))
(global-set-key (kbd "C-`") 'popper-toggle-latest)
(global-set-key (kbd "C-~") 'popper-cycle)
(global-set-key (kbd "C-M-`") 'popper-toggle-type)
(require 'popper-echo)
(popper-echo-mode t)
(defun joe/get-popper-dir ()
(with-current-buffer (current-buffer)
(if (or (> (window-width) 170) (eq olivetti-mode t))
joe/popper-side-toggle
'below)))
;; TODO Prot We need to revisit this function and change the rules; I
;; just saw that Popper uses side-window for it's internal popup at
;; the bottom function. I prefer the way Popper does it for anything
;; that is going to display horizontally at the bottom. However for
;; side splits I much prefer the functionality we have here where if
;; there's a window on the right, then overtake it and then when I
;; close it, keep whatever window was there open. The issue with
;; side-windows is that they keep the two window splits in tact and
;; that's not what I want. Sort of like how Magit does it, that's what
;; I want to copy. But like I have it here, it should respect my
;; "popper side" variable so I can toggle whether it appears at the
;; bottom or above.
(defun joe/popper-display-func (buffer &optional _alist)
(cond
((eq joe/popper-side-toggle 'below)
(popper-select-popup-at-bottom buffer _alist))
((when-let ((popup-buffer
(cl-find-if
#'popper-popup-p
(mapcar #'window-buffer (window-list)))))
(window--display-buffer
buffer (get-buffer-window popup-buffer) 'reuse
`((body-function . ,#'select-window)))))
((and (eq joe/popper-side-toggle 'right)
(window-in-direction 'left))
(window--display-buffer
buffer (get-buffer-window (current-buffer)) 'reuse))
((when-let ((right-window (window-in-direction 'right))
((eq joe/popper-side-toggle 'right)))
(window--display-buffer
buffer right-window 'reuse
`((body-function . ,#'select-window)))))
((and (not (window-in-direction 'right))
(not (window-in-direction 'left)))
(display-buffer-in-direction
buffer
`((window-height . 0.45)
(window-width . 0.45)
(direction . right)
(body-function . ,#'select-window))))
(t
(display-buffer-in-direction
buffer
`((window-height . 0.45)
(window-width . 0.45)
(direction . below)
(body-function . ,#'select-window))))))
(setq popper-display-function #'joe/popper-display-func)
(popper-mode t)
#+end_src
*** COMMENT Tab-bar & Tab-line
#+begin_src emacs-lisp