From f27b43c3d0191e6da71180e54d398f506e972570 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Thu, 11 Apr 2024 15:39:22 +0100 Subject: [PATCH] Fix the modeline view to reposition on resize --- flake.lock | 11 +++++----- flake.nix | 4 +++- lisp/fg42/editor.el | 3 +++ lisp/fg42/init.el | 2 +- lisp/fg42/modeline/units.el | 4 ++-- lisp/fg42/modeline/views.el | 40 +++++++++++++++++++++++++------------ 6 files changed, 42 insertions(+), 22 deletions(-) diff --git a/flake.lock b/flake.lock index 6929eac..8c0e061 100644 --- a/flake.lock +++ b/flake.lock @@ -253,15 +253,16 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1712776989, - "narHash": "sha256-DiZoTYM8FptB4DkyrzdFDMDIMECNCdYpnthjhi0NaRs=", - "rev": "5241f9f243cb6099a185db12552a32f70509ada6", - "revCount": 48, + "lastModified": 1712846008, + "narHash": "sha256-0739q1QSpprLrlqdmQeSM9ynqmuqHagmRLnyMEy47Xc=", + "ref": "refs/tags/v0.1.8", + "rev": "e53688bcc79e5e3142bb2c912d59965c086dafe4", + "revCount": 49, "type": "git", "url": "https://devheroes.codes/lxsameer/noether" }, "original": { - "rev": "5241f9f243cb6099a185db12552a32f70509ada6", + "ref": "refs/tags/v0.1.8", "type": "git", "url": "https://devheroes.codes/lxsameer/noether" } diff --git a/flake.nix b/flake.nix index c6c57be..20fee02 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,8 @@ description = "FG42 - Emacs Editor for advance users"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/442d407992384ed9c0e6d352de75b69079904e4e"; - inputs.noether.url = "git+https://devheroes.codes/lxsameer/noether?rev=5241f9f243cb6099a185db12552a32f70509ada6"; + inputs.noether.url = "git+https://devheroes.codes/lxsameer/noether?ref=refs/tags/v0.1.8"; + inputs.emacs-overlay.url = "github:nix-community/emacs-overlay/0f7f3b39157419f3035a2dad39fbaf8a4ba0448d"; inputs.flake-parts.url = "github:hercules-ci/flake-parts"; @@ -50,6 +51,7 @@ gtk3 = (factory { emacsParams.withGTK3 = true; }).fg42; pgtk = (factory { emacsParams.withPgtk = true; }).fg42; gtk2 = (factory { emacsParams.withGTK2 = true; }).fg42; + none = (factory { emacsParams.toolkit = "no"; }).fg42; }); devShells.default = pkgs.mkShell { diff --git a/lisp/fg42/editor.el b/lisp/fg42/editor.el index 5375405..8c31207 100644 --- a/lisp/fg42/editor.el +++ b/lisp/fg42/editor.el @@ -256,6 +256,9 @@ shipped with Emacs." (add-hook 'emacs-startup-hook (lambda () + ;; It only applies to toolkit=no + (set-mouse-color (get-base16-color-or :base07 "#eeeeec")) + ;; Switch from `dabbrev-expand' to `hippie-expand' (global-set-key [remap dabbrev-expand] 'hippie-expand) diff --git a/lisp/fg42/init.el b/lisp/fg42/init.el index 0a83325..46a0f0e 100644 --- a/lisp/fg42/init.el +++ b/lisp/fg42/init.el @@ -67,7 +67,7 @@ (setq user-emacs-directory emacsd) (setq user-init-file (or (getenv "FG42_CONFIG_FILE") - (format "%s/.fg42.el" + (format "%s/.fg42.v4.el" (getenv "HOME"))))) diff --git a/lisp/fg42/modeline/units.el b/lisp/fg42/modeline/units.el index 94b93fd..3b4ea13 100644 --- a/lisp/fg42/modeline/units.el +++ b/lisp/fg42/modeline/units.el @@ -39,13 +39,13 @@ (defun fg42/-format-mode-icon (_ v _ _) "Format the icon V." - (nerd-icons-icon-for-mode v)) + (format " %s " (nerd-icons-icon-for-mode v))) (noether-defunit fg42/mode-icon "Draws an icon for the current major mode." :label "" - :len 1 + :len 3 :init (lambda () (add-hook 'post-command-hook #'fg42/-update-mode-icon)) diff --git a/lisp/fg42/modeline/views.el b/lisp/fg42/modeline/views.el index 2e55c11..54c7466 100644 --- a/lisp/fg42/modeline/views.el +++ b/lisp/fg42/modeline/views.el @@ -26,33 +26,47 @@ (require 'fg42/modeline/units) + +(defun fg42/--bottom-right (info) + "Keep the modeline at bottom right by using the data from INFO." + (cons -1 -1)) + + +(defun fg42/adjust-modeline (view) + "Adjust the VIEW after parent frame resize." + (noether-show view)) + + (noether-defview fg42/modeline "A simple and minimalist mode-line like status bar" :managed? t :binding (kbd "C-c 0") - :buffer "*modeline" + :buffer "*modeline*" :visible? t :timeout 0 - + :on-parent-resize #'fg42/adjust-modeline :frame (list - :position - (cons (- (frame-inner-width) 690) - (- (frame-outer-height) 20)) + :right-fringe 5 + :poshandler #'fg42/--bottom-right :border-width 0 + :font (format "%s %s" (car fg42/font) (- (cadr fg42/font) 1)) :border-color "#bd93f9") :units (list - (buffer-name-unit :label (format "%s " (nerd-icons-codicon "nf-cod-layers")) - :len 20) + (buffer-name-unit + :label (format "%s " (nerd-icons-codicon "nf-cod-layers")) + :len 20) ;; (mode-name-unit :label " " :len 4) - (projectile-project-unit :label (format "%s " (nerd-icons-octicon "nf-oct-project")) - :len 20) - (git-branch-unit :label (format "%s " (nerd-icons-devicon "nf-dev-git_branch")) - :len 20) + (projectile-project-unit + :label (format "%s " (nerd-icons-octicon "nf-oct-project")) + :len 20) + (git-branch-unit + :label (format "%s " (nerd-icons-devicon "nf-dev-git_branch")) + :len 20) (fg42/mode-icon) - (line-unit :label ""))) + (line-unit :label (format "%s " (nerd-icons-codicon "nf-cod-location"))))) (when-wm @@ -67,7 +81,7 @@ Appears on the center of the current window." (list ;; Such a big numbers for X and Y will cause the frame to appear on the ;; bottom right corner and covering the minibuffer - :position '(10000 . 10000) + :position '(-30 . -1) :border-width 0 :timeout 5 :border-color "#bd93f9")