From 5241f9f243cb6099a185db12552a32f70509ada6 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 10 Apr 2024 20:23:09 +0100 Subject: [PATCH] Fix the parent frame resize issue --- flake.nix | 7 ++++++- noether-views.el | 1 - noether.el | 16 +++++++++++++++- test-noether.el | 12 +++++++++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index b6af18d..b93f73f 100644 --- a/flake.nix +++ b/flake.nix @@ -53,7 +53,7 @@ noether = pkgs.emacsPackages.trivialBuild { pname = "noether-mode"; - version = "0.1.6"; + version = "0.1.7"; buildInputs = [ pkgs.emacsPackages.posframe ]; src = ./.; @@ -81,6 +81,11 @@ buildInputs = [ noether emacsPkgs ]; }; + apps.default = { + type = "app"; + program = "${test-noether}/bin/test-noether"; + }; + }; }); diff --git a/noether-views.el b/noether-views.el index 02d2e79..61bbe2f 100644 --- a/noether-views.el +++ b/noether-views.el @@ -28,7 +28,6 @@ (require 'noether) (require 'noether-units) - (noether-defview noether-minimal-mode-line "A simple and minimalist mode-line like status bar" :managed? t diff --git a/noether.el b/noether.el index ed02fbd..b94280d 100644 --- a/noether.el +++ b/noether.el @@ -318,6 +318,14 @@ It removes any possible watch function." (funcall deinit))) +(defun noether-refresh (&optional _) + "Refresh views. +We need to call this function when ever Emacs resized +or the font size changed." + (interactive) + (mapc #'noether--setup-views noether-views)) + + (defun noether--teardown-views (view) "Tear down the given VIEW to avoid any zombie watcher or timer n stuff." (let ((name (noether--view-get view :name))) @@ -333,13 +341,19 @@ It removes any possible watch function." "Enable noether by setting up each view and necessary hooks." (add-to-list 'window-buffer-change-functions #'noether--buffer-focus-change-runner) (add-to-list 'window-selection-change-functions #'noether--buffer-focus-change-runner) - (mapc #'noether--setup-views noether-views)) + (add-to-list 'window-size-change-functions #'noether-refresh) + + ;; Technically the argument to the refresh function should be a `frame' + ;; but since we are not using it and we have to keep it cuz + ;; `window-size-change-functions' expects it, We just pass true. + (noether-refresh t)) (defun noether--disable () "Disable noether and clean up after it." (delete #'noether--buffer-focus-change-runner window-buffer-change-functions) (delete #'noether--buffer-focus-change-runner window-selection-change-functions) + (delete #'noether-refresh window-size-change-functions) (mapc #'noether--teardown-views noether-views)) diff --git a/test-noether.el b/test-noether.el index 50a720f..ba092ab 100644 --- a/test-noether.el +++ b/test-noether.el @@ -34,6 +34,11 @@ (require 'noether-units) (require 'noether-views) +(defun noether--bottom-right (info) + (cons (- (frame-outer-width) 10) + (- (frame-outer-height) 40)) + ) + (noether-defview mode-line "A simple and minimalist mode-line like status bar" :managed? t @@ -44,10 +49,11 @@ :visible? t :frame (list - :position (cons (- (frame-outer-width) 10) - (- (frame-outer-height) 40)) - ;;:poshandler #'posframe-poshandler-frame-top-center + ;; :position (cons (- (frame-outer-width) 10) + ;; (- (frame-outer-height) 40)) + :poshandler #'noether--bottom-right :border-width 0 + :border-color "#bd93f9") :units