diff --git a/core/cubes/editor.el b/core/cubes/editor.el index 20f4d73..e282c39 100644 --- a/core/cubes/editor.el +++ b/core/cubes/editor.el @@ -24,6 +24,9 @@ (require 'server) (require 'fpkg) (require 'fg42/cube) +(require 'fg42/utils) +(require 'fg42/modeline) +(require 'cubes/modeline) (defflag font-icons "Enable the support for font icones in FG42." t) @@ -234,10 +237,17 @@ (when-flag server (if (not (server-running-p)) + (when-wm + (setq server-name "fg42-wm")) (server-start))) ;; Call the editor related cubes. They will be run only if ;; their flag is active otherwise they will be skipped + (let ((mline (or (plist-get fg42/editor-cube-params :modeline) + fg42/default-modeline))) + (fg42/modeline-cube) + (fg42/setup-modeline-format mline)) + (fg42/font-cube) (fg42/pinentry-cube) (fg42/exec-path-cube) diff --git a/core/cubes/modeline.el b/core/cubes/modeline.el index 161390d..086372e 100644 --- a/core/cubes/modeline.el +++ b/core/cubes/modeline.el @@ -31,6 +31,10 @@ :flag smart-mode-line :flag-default t) + (defun fg42/mini-modeline-setter (def) + (setq mini-modeline-l-format (plist-get def :long)) + (setq mini-modeline-r-format (plist-get def :brief))) + (fpkg/use smart-mode-line :straight (smart-mode-line :source melpa) :defer nil @@ -40,14 +44,15 @@ (setq sml/no-confirm-load-theme t) (sml/setup))) - (fpkg/use mini-modeline :straight (mini-modeline :repo "kiennq/emacs-mini-modeline" :host github :type git) :after smart-mode-line :init - (setq mini-modeline-enhance-visual t) + (progn + (setq mini-modeline-enhance-visual t) + (setq fg42/modeline-setter #'fg42/mini-modeline-setter)) :defer nil :config (mini-modeline-mode t))) diff --git a/core/cubes/wm.el b/core/cubes/wm.el index 5bb1a8d..4ff62da 100644 --- a/core/cubes/wm.el +++ b/core/cubes/wm.el @@ -32,13 +32,6 @@ "The flag to enable WM mode in FG42.") -(defmacro when-wm (&rest body) - "Run the BODY only if in wm mode." - (if (string= (getenv "FG42_WM") "true") - `(progn ,@body) - nil)) - - (defcube fg42/wm-cube "This cube will setup *FG42* to act as a window manager." (:title "Window manager cube" diff --git a/core/fg42/modeline.el b/core/fg42/modeline.el new file mode 100644 index 0000000..8e33b64 --- /dev/null +++ b/core/fg42/modeline.el @@ -0,0 +1,43 @@ +;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2022 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.0 +;; +;; 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 fg42/modeline-setter #'fg42/default-mode-line-setter) +(defvar fg42/default-modeline '(:brief mode-line-format :long "")) + + +(defun fg42/default-mode-line-setter (_) + "Set the modeline definition in X to the `fg42-modeline'." + (setq mode-line-format (plist-get fg42/default-modeline :brief))) + + +(defun fg42/setup-modeline-format (definition) + "Setup the modeline by calling the setter function and passing the DEFINITION." + (funcall fg42/modeline-setter definition)) + + +(defmacro defmode-line (name body) + `(defvar ,name ,@body)) + +(provide 'fg42/modeline) +;;; modeline.el ends here diff --git a/core/fg42/utils.el b/core/fg42/utils.el index a30ee57..55a672c 100644 --- a/core/fg42/utils.el +++ b/core/fg42/utils.el @@ -171,5 +171,12 @@ is non-nil value it means that the function can be called interactively." ,docstring ,interactive)) +(defmacro when-wm (&rest body) + "Run the BODY only if in wm mode." + (if (string= (getenv "FG42_WM") "true") + `(progn ,@body) + nil)) + + (provide 'fg42/utils) ;;; utils.el ends here