<commit_before>;;; core-popup.el --- taming stray windows

;; I use a slew of hackery to get Emacs to treat 'pop-up' windows in a sane and "modern"
;; way (whatever that means). It goes through great lengths to tame helm, flycheck, help
;; buffers--*even* the beast that is org-mode.
;;
;; Be warned, an update could break any of this.

(use-package shackle
  :config
  (shackle-mode 1)
  (setq shackle-rules
        `(;; Util
          ("^\\*.+-Profiler-Report .+\\*$" :align below :size 0.3 :regexp t)
          ("*esup*"            :align below :size 0.4  :noselect t)
          ("*minor-modes*"     :align below :size 0.5 :noselect t)
          ("*eval*"            :align below :size 20)
          ;; Emacs
          ("*Pp Eval Output*"  :align below :size 0.3)
          ("*Apropos*"         :align below :size 0.3)
          ("*Backtrace*"       :align below :size 25  :noselect t)
          ("*Completions*"     :align below :size 20  :noselect t)
          ("*Help*"            :align below :size 16  :select t)
          ("*Messages*"        :align below :size 15  :select t)
          ("*Warnings*"        :align below :size 10  :noselect t)
          (compilation-mode    :align below :size 15  :noselect t)
          (eww-mode            :align below :size 30  :select t)
          ;; vcs
          ("*vc-diff*"         :align below :size 15  :noselect t)
          ("*vc-change-log*"   :align below :size 15  :select t)
          (vc-annotate-mode    :same t)))

  (defvar doom-popup-windows '()
    "A list of windows that have been opened via shackle. Do not touch this!")
  (defvar doom-last-popup nil
    "The last (important) popup buffer.")
  (defvar doom-prev-buffer nil
    "The buffer from which the popup was invoked.")
  (defvar-local doom-popup-protect nil
    "If non-nil, this popup buffer won't be killed when closed.")

  (defvar doom-popup-inescapable-modes
    '(compilation-mode comint-mode "^\\*doom.*\\*$")
    "A list of modes that should not be closeable with a single ESC.")
  (defvar doom-popup-protect-modes
    '(messages-buffer-mode esup-mode help-mode tabulated-list-mode comint-mode)
    "A list of modes that shouldn't be killed and can be revived.")

  ;; There is no shackle-popup hook, so I hacked one in
  (defvar doom-popup-pre-hook  '() "Hooks run after a popup is opened.")
  (defvar doom-popup-post-hook '() "Hooks run before a popup is opened.")
  (advice-add 'shackle-display-buffer :before 'doom*run-popup-pre-hooks)
  (advice-add 'shackle-display-buffer :after  'doom*run-popup-post-hooks)
  (add-hook 'doom-popup-post-hook 'doom|popup-init)     ; Keep track of popups
  (add-hook 'doom-popup-post-hook 'doom|hide-mode-line) ; No mode line in popups
  ;; Prevents popups from messaging with windows-moving functions
  (advice-add 'doom/evil-window-move :around 'doom*save-popups))


;;
;; Hacks
;;

(defun doom-popup-magit-hacks ()
  ;; Some wrassling must be done to get magit to kill itself, and trigger my
  ;; shackle popup hooks.
  (setq magit-bury-buffer-function
        (lambda (&rest _) (doom/popup-close (selected-window)))
        magit-display-buffer-function
        (lambda (b)
          (funcall (if (doom/popup-p (selected-window)) 'switch-to-buffer 'doom/popup-buffer) b)
          (get-buffer-window b))<commit_msg>Fix doom*save-popups typo<commit_after>;;; core-popup.el --- taming stray windows

;; I use a slew of hackery to get Emacs to treat 'pop-up' windows in a sane and "modern"
;; way (whatever that means). It goes through great lengths to tame helm, flycheck, help
;; buffers--*even* the beast that is org-mode.
;;
;; Be warned, an update could break any of this.

(use-package shackle
  :config
  (shackle-mode 1)
  (setq shackle-rules
        `(;; Util
          ("^\\*.+-Profiler-Report .+\\*$" :align below :size 0.3 :regexp t)
          ("*esup*"            :align below :size 0.4  :noselect t)
          ("*minor-modes*"     :align below :size 0.5 :noselect t)
          ("*eval*"            :align below :size 20)
          ;; Emacs
          ("*Pp Eval Output*"  :align below :size 0.3)
          ("*Apropos*"         :align below :size 0.3)
          ("*Backtrace*"       :align below :size 25  :noselect t)
          ("*Completions*"     :align below :size 20  :noselect t)
          ("*Help*"            :align below :size 16  :select t)
          ("*Messages*"        :align below :size 15  :select t)
          ("*Warnings*"        :align below :size 10  :noselect t)
          (compilation-mode    :align below :size 15  :noselect t)
          (eww-mode            :align below :size 30  :select t)
          ;; vcs
          ("*vc-diff*"         :align below :size 15  :noselect t)
          ("*vc-change-log*"   :align below :size 15  :select t)
          (vc-annotate-mode    :same t)))

  (defvar doom-popup-windows '()
    "A list of windows that have been opened via shackle. Do not touch this!")
  (defvar doom-last-popup nil
    "The last (important) popup buffer.")
  (defvar doom-prev-buffer nil
    "The buffer from which the popup was invoked.")
  (defvar-local doom-popup-protect nil
    "If non-nil, this popup buffer won't be killed when closed.")

  (defvar doom-popup-inescapable-modes
    '(compilation-mode comint-mode "^\\*doom.*\\*$")
    "A list of modes that should not be closeable with a single ESC.")
  (defvar doom-popup-protect-modes
    '(messages-buffer-mode esup-mode help-mode tabulated-list-mode comint-mode)
    "A list of modes that shouldn't be killed and can be revived.")

  ;; There is no shackle-popup hook, so I hacked one in
  (defvar doom-popup-pre-hook  '() "Hooks run after a popup is opened.")
  (defvar doom-popup-post-hook '() "Hooks run before a popup is opened.")
  (advice-add 'shackle-display-buffer :before 'doom*run-popup-pre-hooks)
  (advice-add 'shackle-display-buffer :after  'doom*run-popup-post-hooks)
  (add-hook 'doom-popup-post-hook 'doom|popup-init)     ; Keep track of popups
  (add-hook 'doom-popup-post-hook 'doom|hide-mode-line) ; No mode line in popups
  ;; Prevents popups from messaging with windows-moving functions
  (advice-add 'doom/evil-window-move :around 'doom*save-popup))


;;
;; Hacks
;;

(defun doom-popup-magit-hacks ()
  ;; Some wrassling must be done to get magit to kill itself, and trigger my
  ;; shackle popup hooks.
  (setq magit-bury-buffer-function
        (lambda (&rest _) (doom/popup-close (selected-window)))
        magit-display-buffer-function
        (lambda (b)
          (funcall (if (doom/popup-p (selected-window)) 'switch-to-buffer 'doom/popup-buffer) b)
          (get-buffer-window b))
{'fraction_non_alphanumeric': 0.1341222879684418, 'fraction_numerical': 0.009406766803216508, 'mean_word_length': 2.525133689839572, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5479134', 'n_tokens_mistral': 2297, 'n_tokens_neox': 2125, 'n_words': 703}