From 1455d6609b246f09303653debb355f748013b070 Mon Sep 17 00:00:00 2001 From: Benson Chu Date: Sun, 12 Apr 2026 10:55:39 -0500 Subject: [PATCH] Compilation mode locus should use the same window --- lisp/hacks/comp-mode-locus-override.el | 53 ++++++++++++++++++++++++++ lisp/llvm-lib/my-comp-minor-mode.el | 1 + 2 files changed, 54 insertions(+) create mode 100644 lisp/hacks/comp-mode-locus-override.el diff --git a/lisp/hacks/comp-mode-locus-override.el b/lisp/hacks/comp-mode-locus-override.el new file mode 100644 index 0000000..e12eda2 --- /dev/null +++ b/lisp/hacks/comp-mode-locus-override.el @@ -0,0 +1,53 @@ +;;; comp-mode-locus-override.el --- -*- lexical-binding: t -*- + +;; Copyright (C) 2026 Benson Chu + +;; Author: Benson Chu +;; Created: [2026-04-12 10:41] + +;; This file is not part of GNU Emacs + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: + +(defvar compile-locus-display-window nil) +(make-variable-buffer-local 'compile-locus-display-window) + +(defun my/compile-locus-some-window (buffer) + `(lambda (buffer alist) + (if (and compile-locus-display-window + (window-live-p compile-locus-display-window)) + compile-locus-display-window + (setq + compile-locus-display-window + (let ((win (window-in-direction 'left (get-buffer-window ,buffer)))) + (split-window-horizontally nil win)))))) + +(defun my/compilation-goto-locus (orig &rest args) + (save-selected-window + (let ((display-buffer-overriding-action + `(display-buffer-use-some-window + (inhibit-same-window . t) + (some-window . ,(my/compile-locus-some-window (current-buffer)))))) + (apply orig args)))) + +(advice-add #'compilation-goto-locus + :around + #'my/compilation-goto-locus) + +(provide 'comp-mode-locus-override) +;;; comp-mode-locus-override.el ends here diff --git a/lisp/llvm-lib/my-comp-minor-mode.el b/lisp/llvm-lib/my-comp-minor-mode.el index 4ef1838..1fb5557 100644 --- a/lisp/llvm-lib/my-comp-minor-mode.el +++ b/lisp/llvm-lib/my-comp-minor-mode.el @@ -25,6 +25,7 @@ ;;; Code: (require 'anaphora) (require 'llvm-buffer-chain) +(require 'comp-mode-locus-override) (define-minor-mode compilation-minor-mode "Toggle Compilation minor mode.