diff --git a/.gitignore b/.gitignore index 344390c..521ab2d 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ website/.*.swp website/*~ #*# +emacs.d/ \ No newline at end of file diff --git a/core/fg42.el b/core/fg42.el index e2d4611..2ad1dc5 100644 --- a/core/fg42.el +++ b/core/fg42.el @@ -21,27 +21,17 @@ ;; ;;; Commentary: ;;; Code: -(require 'fg42/cube) +(require 'fg42/core) (require 'fg42/utils) -(require 'fg42/system/core) -(defvar fg42-home (getenv "FG42_HOME") - "The pass to fg42-home.") - -(defvar fg42-tmp (concat fg42-home "/tmp")) - - -(autoload 'fg42/system-start "fg42/system" - "Starts the given SYSTEM.") - - -(defun fg42/start! (system) - "Start the given SYSTEM description." +(defun fg42/initialize () + "Initialize the FG42 instance." (add-hook 'window-setup-hook (lambda () - (require 'fg42/system) - (fg42/system-start system)))) + (require 'fpkg) + (fpkg/initialize) + (message "DONE")))) (provide 'fg42) diff --git a/core/fpkg.el b/core/fpkg.el index 272d3fc..a8816ab 100644 --- a/core/fpkg.el +++ b/core/fpkg.el @@ -24,9 +24,18 @@ ;; Simple package manager for FG42 ;; ;;; Code: + (require 'seq) (require 'cl-lib) (require 'package) +(require 'fg42/core) + +(defvar bootstrap-version 5) + +(defcustom fpkg-package-directory (concat fg42-home "/.fpkg") + "Specify the directory to store all the dependencies." + :group 'fpkg + :type 'string) (defun fpkg/->package-el-version (version) @@ -71,9 +80,8 @@ (funcall install-func pkg))) -(defun fpkg/initialize (system) +(defun fpkg/initialize1 (system) "Initilize the `package.el' for the given SYSTEM." - (message "KKKKKKKKKKKKKKKKKKKKKKKKKKK") ;; TODO: Grap any extra repo from the system (sympol-plist) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t) @@ -83,5 +91,21 @@ +(defun fpkg/initialize () + "Initialize FPKG." + + (let ((bootstrap-file + (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))) + + (unless (file-exists-p bootstrap-file) + (with-current-buffer + (url-retrieve-synchronously + "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" + 'silent 'inhibit-cookies) + (goto-char (point-max)) + (eval-print-last-sexp))) + (load bootstrap-file nil 'nomessage))) + + (provide 'fpkg) ;;; fpkg.el ends here diff --git a/dev.org b/dev.org index eda6f49..fac60c2 100644 --- a/dev.org +++ b/dev.org @@ -17,13 +17,13 @@ part of the development process. * Development Goals In the past we tried many different ideas and features but since we didn't have a clear goal set, - we couldn't really make it work and differenciate good ideas from bad ones. - + we couldn't really make it work and differentiate good ideas from bad ones. ** Who are the target audience? - +On the first level, I should feel comfortable with it. ** What set of features are important to us? + * Tools ** Straight @@ -34,6 +34,27 @@ part of the development process. ** Midnight mode It's a cool library that run some action every midnight, we can use it to clean up old buffers - or other maintainance jobs + or other maintenance jobs * Tasks +** TODO Reformat the modeline + +* Things that didn't work out +- rbenv +- helm +- linum +- tabbar +- ido +- ivy +- spaceline +- doom-modeline +- smart-mode-line +- desktop-mode +- jedi +- file-browser +- dired+ +- guru +- emoji +- elpy +- github +- versioned-backup diff --git a/fg42-config.el b/fg42-config.el index 5cfaf44..6134715 100644 --- a/fg42-config.el +++ b/fg42-config.el @@ -24,51 +24,30 @@ (defvar fg42-v3 (or (getenv "FG42_V3") '())) + + (if fg42-v3 (add-to-list 'load-path (concat (getenv "FG42_HOME") "/core")) (add-to-list 'load-path (concat (getenv "FG42_HOME") "/lib"))) -;; DEBUG -;; ===== -;; Uncomment the below code to trigger stacktraces in case of any errors -;; (toggle-debug-on-error) +;; Prevent package.el to install anything at startup +(setq package-enable-at-startup nil) + +(setq custom-file (format "%s/.fg42.custom.el" (getenv "HOME"))) +(setq user-emacs-directory "~/.fg42/emacs.d") + +(setq user-init-file + (format "%s/.fg42.%s" + (getenv "HOME") + (if fg42-v3 + "v3.el" + "el"))) + +(if (file-exists-p custom-file) + (load custom-file)) (require 'fg42) -;; THEME -;; ===== -;; Load the default theme -;; Other options are: -;; (theme themes/color-theme-spacemacs-monokai) -;; (theme themes/color-theme-spacemacs-light) -;; (theme themes/color-theme-doom-one) -;; (theme themes/color-theme-doom-molokai) -;;(theme themes/color-theme-spacemacs-dark) - -;; ABILITIES -;; ========= -;; Disable abilities which you don't want. -;; (disable 'rbenv 'helm 'spell 'linum 'smart-mode-line) - -;; EXTENSIONS -;; ========== -;; Uncomment extensions that you may need. -;; (activate-extensions 'editor -;; 'development -;; 'web -;; 'editor-theme -;; ;'arduino -;; 'javascript -;; ;'php -;; 'clojure -;; ;'python -;; 'ruby -;; ) - -;; USER CONFIGS -;; ============ -;; Load user config file in ~/.fg42.el - (load-user-config (if fg42-v3 "~/.fg42.v3.el" @@ -77,8 +56,9 @@ ;; NOTE: It's important to use ~/.fg42.el instead of this file ;; because updating fg42 will discard your changes in ;; this file. -(when (not fg42-v3) - (fg42-initialize)) +(if (not fg42-v3) + (fg42-initialize) + (fg42/initialize)) (provide 'fg42-config) diff --git a/lib/extensions/editor/init.el b/lib/extensions/editor/init.el index 3e36232..a235bbc 100644 --- a/lib/extensions/editor/init.el +++ b/lib/extensions/editor/init.el @@ -1,8 +1,31 @@ +;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2021 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: (require 'extensions/editor/buffers) ;; Customizations -------------------------------------------- (defcustom fg42-todo-file "~/.TODO.org" - "Path to your TODO file. You can use a tramp address here as well." + "Path to your todo file. You can use a tramp address here as well." :type 'string :group 'fg42) @@ -137,35 +160,6 @@ (add-hook 'prog-mode-hook 'global-flycheck-mode) (add-hook 'after-init-hook 'global-flycheck-mode)) - (ability spaceline (flycheck) - "A really cool mode line alternative which borrowed from awesome spacemacs" - (require 'spaceline-config) - (require 'extensions/editor/spaceline-alt) - - ;; TODO: Move this to somewhere propriate - ;; Modeline indicator for lxdrive - (spaceline-define-segment lxdrive - "lxdrive indicator on spaceline." - (if (and (boundp 'lxdrive-minor-mode) lxdrive-minor-mode) - (all-the-icons-faicon "arrows" :height 0.8 :v-adjust 0.15 :face 'all-the-icons-lgreen) - (all-the-icons-faicon "pencil" :height 0.8 :v-adjust 0.15)) - :tight t) - - (spaceline-compile - "ati" - '(((lxdrive) :face highlight-face :skip-alternate t) - ((ati-projectile ati-mode-icon ati-buffer-id) :face default-face) - ((ati-process ati-region-info) :face highlight-face :separator " | ") - ((ati-modified ati-window-numbering ati-buffer-size ati-position) :face highlight-face :skip-alternate t) - ((ati-flycheck-status ati-(point)ackage-updates purpose) :separator " | " :face other-face)) - ;; ((minor-modes) :face default-face) - - - '(((ati-vc-icon " ") :face default-face :skip-alternate t :tight t))) - - (setq-default mode-line-format '("%e" (:eval (spaceline-ml-ati))))) - - ;;(spaceline-emacs-theme)) ;; ACE Window @@ -436,3 +430,4 @@ (message "'editor' extension has been initialized.")) (provide 'extensions/editor/init) +;;; init.el ends here diff --git a/lib/extensions/editor/lxmodeline.el b/lib/extensions/editor/lxmodeline.el index 78e7acb..fd3ed13 100644 --- a/lib/extensions/editor/lxmodeline.el +++ b/lib/extensions/editor/lxmodeline.el @@ -1,33 +1,33 @@ ;;; lxmode-line --- A small utility library to toggle the modeline. ;;; Commentary: ;;; Code: -(require 'doom-modeline) +;; (require 'doom-modeline) -(doom-modeline-def-segment lxdrive-info - "Show the status of lxdrive mode" - (if (and (boundp 'lxdrive-minor-mode) lxdrive-minor-mode) - (list " " (all-the-icons-faicon "arrows" :height 0.8 :v-adjust 0.15 :face 'all-the-icons-lgreen)) - (list " " (all-the-icons-faicon "pencil" :height 0.8 :v-adjust 0.15)))) +;; (doom-modeline-def-segment lxdrive-info +;; "Show the status of lxdrive mode" +;; (if (and (boundp 'lxdrive-minor-mode) lxdrive-minor-mode) +;; (list " " (all-the-icons-faicon "arrows" :height 0.8 :v-adjust 0.15 :face 'all-the-icons-lgreen)) +;; (list " " (all-the-icons-faicon "pencil" :height 0.8 :v-adjust 0.15)))) -(doom-modeline-def-modeline 'fg42-mode-line - '(bar lxdrive-info matches buffer-info buffer-position parrot selection-info) - '(process vcs checker)) +;; (doom-modeline-def-modeline 'fg42-mode-line +;; '(bar lxdrive-info matches buffer-info buffer-position parrot selection-info) +;; '(process vcs checker)) -(defun setup-custom-doom-modeline () - "Setup fg42 modeline." - (doom-modeline-set-modeline 'fg42-mode-line 'default)) +;; (defun setup-custom-doom-modeline () +;; "Setup fg42 modeline." +;; (doom-modeline-set-modeline 'fg42-mode-line 'default)) -(with-ability doom-modeline - (add-hook 'doom-modeline-mode-hook 'setup-custom-doom-modeline) - (setq doom-modeline-height 15) - (setq doom-modeline-buffer-encoding nil) - (setq doom-modeline-lsp nil) - (setq doom-modeline-mu4e nil) - (setq doom-modeline-irc nil) - (setq doom-modeline-buffer-file-name-style 'truncate-with-project) - (doom-modeline-mode t)) +;; (with-ability doom-modeline +;; (add-hook 'doom-modeline-mode-hook 'setup-custom-doom-modeline) +;; (setq doom-modeline-height 15) +;; (setq doom-modeline-buffer-encoding nil) +;; (setq doom-modeline-lsp nil) +;; (setq doom-modeline-mu4e nil) +;; (setq doom-modeline-irc nil) +;; (setq doom-modeline-buffer-file-name-style 'truncate-with-project) +;; (doom-modeline-mode t)) (provide 'extensions/editor/lxmodeline) ;;; lxmodeline ends here diff --git a/lib/extensions/editor/spaceline-alt.el b/lib/extensions/editor/spaceline-alt.el deleted file mode 100644 index ecc366b..0000000 --- a/lib/extensions/editor/spaceline-alt.el +++ /dev/null @@ -1,380 +0,0 @@ -;;; spaceline-alt.el --- Custom install for all the icons Spaceline - -;; Copyright (C) 2016 Dominic Charlesworth - -;; Author: Dominic Charlesworth -;; Keywords: lisp - -;; 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: - -(require 'spaceline) -(require 'spaceline-config) -(require 'all-the-icons) - -;;---------------;; -;; First Segment ;; -;;---------------;; - -(spaceline-define-segment - ati-modified "An `all-the-icons' modified segment" - (let* ((config-alist - '(("*" all-the-icons-faicon-family all-the-icons-faicon "chain-broken" :height 1.2 :v-adjust -0.0) - ("-" all-the-icons-faicon-family all-the-icons-faicon "link" :height 1.2 :v-adjust -0.0) - ("%" all-the-icons-octicon-family all-the-icons-octicon "lock" :height 1.2 :v-adjust 0.1))) - (result (cdr (assoc (format-mode-line "%*") config-alist)))) - - (propertize (format "%s" (apply (cadr result) (cddr result))) 'face `(:family ,(funcall (car result)) :inherit ))) - :tight t) - -(spaceline-define-segment - ati-window-numbering "An `all-the-icons' window numbering segment" - (propertize (format "%c" (+ 9311 (window-numbering-get-number))) - 'face `(:height 1.3 :inherit) - 'display '(raise -0.0)) - :tight t :when (fboundp 'window-numbering-mode)) - -(spaceline-define-segment - ati-projectile "An `all-the-icons' segment for current `projectile' project" - (concat - (propertize "" 'face '(:height 1.1 :inherit)) - " " - (if (and (fboundp 'projectile-project-name) - (projectile-project-name)) - (propertize (format "%s" (concat (projectile-project-name) )) - 'face '(:height 0.8 :inherit) - 'display '(raise 0.2) - 'help-echo "Switch Project" - 'mouse-face '(:box 1) - 'local-map (make-mode-line-mouse-map - 'mouse-1 (lambda () (interactive) (projectile-switch-project)))) - (propertize "×" 'face '(:height 0.8 :inherit))) - " " - (propertize "|" 'face '(:height 1.1 :inherit))) - :tight t) - -(spaceline-define-segment - ati-mode-icon "An `all-the-icons' segment for the current buffer mode" - (let ((icon (all-the-icons-icon-for-buffer))) - (unless (symbolp icon) ;; This implies it's the major mode - (propertize icon - 'help-echo (format "Major-mode: `%s`" major-mode) - 'display '(raise 0.0) - 'face `(:height 1.0 :family ,(all-the-icons-icon-family-for-buffer) :inherit))))) - -(spaceline-define-segment - ati-buffer-id "An `all-the-icons' segment for the current buffer id" - (if (fboundp 'projectile-project-root) - (let* ((buf (or (buffer-file-name) (buffer-name))) - (proj (ignore-errors (projectile-project-root)) ) - (name (if (buffer-file-name) - (or (cadr (split-string buf proj)) - (format-mode-line "%b")) - (format-mode-line "%b")))) - (propertize (format "%s" name) - 'face `(:height 0.8 :inherit) - 'display '(raise 0.2) - 'help-echo (format "Major-mode: `%s`" major-mode))) - (propertize (format-mode-line "%b ") 'face '(:height 0.8 :inherit) 'display '(raise 0.1))) - :tight t) - -;;----------------;; -;; Second Segment ;; -;;----------------;; - -(spaceline-define-segment - ati-process "An `all-the-icons' segment for the current process" - (let ((icon (all-the-icons-icon-for-buffer))) - (concat - (when (or (symbolp icon) mode-line-process) - (propertize (format-mode-line "%m") 'face `(:height 0.8 :inherit) 'display '(raise 0.2))) - (when mode-line-process - (propertize (format-mode-line mode-line-process) 'face '(:height 0.7 :inherit) 'display '(raise 0.2))))) - :tight t) - -(spaceline-define-segment - ati-position "An `all-the-icons' segment for the Row and Column of the current point" - (propertize (format-mode-line "%l:%c") 'face `(:height 0.9 :inherit) 'display '(raise 0.1))) - -(spaceline-define-segment - ati-region-info "An `all-the-icons' segment for the currently marked region" - (when mark-active - (let ((words (count-lines (region-beginning) (region-end))) - (chars (count-words (region-end) (region-beginning)))) - (concat - (propertize (format "%s " (all-the-icons-octicon "pencil") words chars) - 'face `(:family ,(all-the-icons-octicon-family) :inherit) 'display '(raise 0.1)) - (propertize (format "(%s, %s)" words chars) - 'face `(:height 0.9 :inherit)))))) - -(spaceline-define-segment - ati-color-control "An `all-the-icons' segment for the currently marked region" "") - - -;;----------------;; -;; Third Segement ;; -;;----------------;; - -(defun spaceline---github-vc () - "Function to return the Spaceline formatted GIT Version Control text." - (let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-"))) - (concat - (propertize (all-the-icons-alltheicon "git") 'face '(:height 1.1 :inherit) 'display '(raise 0.1)) - (propertize " ") - (propertize (format "%s" (all-the-icons-octicon "git-branch")) - 'face `(:family ,(all-the-icons-octicon-family) :height 1.0 :inherit) - 'display '(raise 0.2)) - (propertize (format " %s" branch) 'face `(:height 0.9 :inherit) 'display '(raise 0.2))))) - -(defun spaceline---svn-vc () - "Function to return the Spaceline formatted SVN Version Control text." - (let ((revision (cadr (split-string vc-mode "-")))) - (concat - (propertize (format " %s" (all-the-icons-faicon "cloud")) 'face `(:height 1.2) 'display '(raise -0.1)) - (propertize (format " %s" revision) 'face `(:height 0.9))))) - - -(spaceline-define-segment - ati-vc-icon "An `all-the-icons' segment for the current Version Control icon" - (when vc-mode - (cond ((string-match "Git[:-]" vc-mode) (spaceline---github-vc)) - ((string-match "SVN-" vc-mode) (spaceline---svn-vc)) - (t (propertize (format "%s" vc-mode))))) - :when active) - -(spaceline-define-segment - ati-flycheck-status "An `all-the-icons' representaiton of `flycheck-status'" - (let* ((text - (pcase flycheck-last-status-change - (`finished (if flycheck-current-errors - (let ((count (let-alist (flycheck-count-errors flycheck-current-errors) - (+ (or .warning 0) (or .error 0))))) - (format "✖ %s Issue%s" count (if (eq 1 count) "" "s"))) - "✔ No Issues")) - (`running "⟲ Running") - (`no-checker "⚠ No Checker") - (`not-checked "✖ Disabled") - (`errored "⚠ Error") - (`interrupted "⛔ Interrupted") - (`suspicious ""))) - (f (cond - ((string-match "⚠" text) `(:height 0.9 :foreground ,(face-attribute 'spaceline-flycheck-warning :foreground))) - ((string-match "✖ [0-9]" text) `(:height 0.9 :foreground ,(face-attribute 'spaceline-flycheck-error :foreground))) - ((string-match "✖ Disabled" text) `(:height 0.9 :foreground ,(face-attribute 'font-lock-comment-face :foreground))) - (t '(:height 0.9 :inherit))))) - (propertize (format "%s" text) - 'face f - 'help-echo "Show Flycheck Errors" - 'display '(raise 0.2) - 'mouse-face '(:box 1) - 'local-map (make-mode-line-mouse-map 'mouse-1 (lambda () (interactive) (flycheck-list-errors))))) - :when active :tight t ) - -(defvar spaceline--upgrades nil) -(defun spaceline--count-upgrades () - "Function to count the number of package upgrades needed." - (let ((buf (current-buffer))) - (package-list-packages-no-fetch) - (with-current-buffer "*Packages*" - (setq spaceline--upgrades (length (package-menu--find-upgrades)))) - (switch-to-buffer buf))) -(advice-add 'package-menu-execute :after 'spaceline--count-upgrades) - -(spaceline-define-segment - ati-package-updates "An `all-the-icons' spaceline segment to indicate number of package updates needed" - (let ((num (or spaceline--upgrades (spaceline--count-upgrades)))) - (propertize - (concat - (propertize (format "%s" (all-the-icons-octicon "package")) - 'face `(:family ,(all-the-icons-octicon-family) :height 1.1 :inherit) - 'display '(raise 0.1)) - (propertize (format " %d updates " num) 'face `(:height 0.9 :inherit) 'display '(raise 0.2))) - 'help-echo "Open Packages Menu" - 'mouse-face '(:box 1) - 'local-map (make-mode-line-mouse-map - 'mouse-1 (lambda () (interactive) (package-list-packages))))) - :when (and active (> (or spaceline--upgrades (spaceline--count-upgrades)) 0))) - -;;---------------------;; -;; Right First Segment ;; -;;---------------------;; -(defun spaceline--get-temp () - "Function to return the Temperature formatted for ATI Spacline." - (let ((temp (yahoo-weather-info-format yahoo-weather-info "%(temperature)"))) - (unless (string= "" temp) (format "%s°C" (round (string-to-number temp)))))) - -(spaceline-define-segment - ati-weather "Weather" - (let* ((weather (yahoo-weather-info-format yahoo-weather-info "%(weather)")) - (temp (spaceline--get-temp)) - (help (concat "Weather is '" weather "' and the temperature is " temp)) - (icon (all-the-icons-icon-for-weather (downcase weather)))) - (concat - (if (> (length icon) 1) - (propertize icon 'help-echo help 'face `(:height 0.9 :inherit) 'display '(raise 0.1)) - (propertize icon - 'help-echo help - 'face `(:height 0.9 :family ,(all-the-icons-wicon-family) :inherit) - 'display '(raise 0.0))) - (propertize " " 'help-echo help) - (propertize (spaceline--get-temp) 'face '(:height 0.9 :inherit) 'help-echo help))) - :when (and active (boundp 'yahoo-weather-info) yahoo-weather-mode) - :enabled nil - :tight t) - -(spaceline-define-segment - ati-suntime "Suntime" - (let ((help (yahoo-weather-info-format yahoo-weather-info "Sunrise at %(sunrise-time), Sunset at %(sunset-time)"))) - (concat - (propertize (yahoo-weather-info-format yahoo-weather-info "%(sunrise-time) ") - 'face '(:height 0.9 :inherit) 'display '(raise 0.1) 'help-echo help) - (propertize (format "%s" (all-the-icons-wicon "sunrise" :v-adjust 0.1)) - 'face `(:height 0.8 :family ,(all-the-icons-wicon-family) :inherit) 'help-echo help) - (propertize " · " 'help-echo help) - (propertize (yahoo-weather-info-format yahoo-weather-info "%(sunset-time) ") - 'face '(:height 0.9 :inherit) 'display '(raise 0.1) 'help-echo help) - (propertize (format "%s" (all-the-icons-wicon "sunset" :v-adjust 0.1)) - 'face `(:height 0.8 :family ,(all-the-icons-wicon-family) :inherit) 'help-echo help))) - :when (and active (boundp 'yahoo-weather-info) yahoo-weather-mode) - :enabled nil - :tight t ) - -(spaceline-define-segment - ati-time "Time" - (let* ((hour (string-to-number (format-time-string "%I"))) - (icon (all-the-icons-wicon (format "time-%s" hour) :v-adjust 0.0))) - (concat - (propertize (format-time-string "%H:%M ") 'face `(:height 0.9 :inherit) 'display '(raise 0.1)) - (propertize (format "%s" icon) - 'face `(:height 0.8 :family ,(all-the-icons-wicon-family) :inherit) - 'display '(raise 0.1)))) - :tight t) - -(spaceline-define-segment - ati-height-modifier "Modifies the height of inactive buffers" - (propertize " " 'face '(:height 1.3 :inherit)) - :tight t :when (not active)) - -(spaceline-define-segment - ati-buffer-size "Buffer Size" - (propertize (format-mode-line "%I") 'face `(:height 0.9 :inherit) 'display '(raise 0.1)) - :tight t) - -(spaceline-define-segment - ati-battery-status "Show battery information" - (let* ((charging? (equal "AC" (cdr (assoc ?L fancy-battery-last-status)))) - (percentage (string-to-int (cdr (assoc ?p fancy-battery-last-status)))) - (time (format "%s" (cdr (assoc ?t fancy-battery-last-status)))) - (icon-set (if charging? 'alltheicon 'faicon)) - (icon-alist - (cond - (charging? '((icon . "charging") (inherit . success) (height . 1.3) (raise . -0.1))) - ((> percentage 95) '((icon . "full") (inherit . success))) - ((> percentage 70) '((icon . "three-quarters"))) - ((> percentage 35) '((icon . "half"))) - ((> percentage 15) '((icon . "quarter") (inherit . warning))) - (t '((icon . "empty") (inherit . error))))) - (icon-f (all-the-icons--function-name icon-set)) - (family (funcall (all-the-icons--family-name icon-set)))) - (let-alist icon-alist - (concat - (if .inherit - (let ((fg (face-attribute .inherit :foreground))) - (propertize (funcall icon-f (format "battery-%s" .icon)) - 'face `(:height ,(or .height 1.0) :family ,family :foreground ,fg) - 'display `(raise ,(or .raise 0.0)))) - (propertize (funcall icon-f (format "battery-%s" .icon)) - 'face `(:family ,family :inherit) - 'display '(raise 0.0))) - " " - (if .inherit - (let ((fg (face-attribute .inherit :foreground))) - (propertize (if charging? (format "%s%%%%" percentage) time) 'face `(:height 0.9 :foreground ,fg))) - (propertize time 'face '(:height 0.9 :inherit))) - ))) - :global-override fancy-battery-mode-line :when (and active (fboundp 'fancy-battery-mode) fancy-battery-mode)) - -(defun spaceline--direction (dir) - "Inverts DIR from right to left & vice versa." - (if spaceline-invert-direction (if (equal dir "right") "left" "right") dir)) - -(defun spaceline--separator-type () - "Static function to return the separator type." - spaceline-separator-type) - -(defmacro define-separator (name dir start-face end-face &optional invert) - "Macro to defined a NAME separator in DIR direction. -Provide the START-FACE and END-FACE to describe the way it should -fade between segmeents. When INVERT is non-nil, it will invert -the directions of the separator." - `(progn - (spaceline-define-segment - ,(intern (format "ati-%s-separator" name)) - (let ((dir (if spaceline-invert-direction (spaceline--direction ,dir) ,dir)) - (sep (spaceline--separator-type))) - (propertize (all-the-icons-alltheicon (format "%s-%s" sep dir) :v-adjust 0.0) - 'face `(:height 1.5 - :family - ,(all-the-icons-alltheicon-family) - :foreground - ,(face-attribute ,start-face :background) - :background - ,(face-attribute ,end-face :background)))) - :skip-alternate t :tight t :when (if ,invert (not active) active)))) - -(defvar spaceline-invert-direction t) -(defvar spaceline-separator-type "slant") - -(define-separator "left-inactive" "right" 'powerline-inactive1 'powerline-inactive2 t) -(define-separator "right-inactive" "left" 'powerline-inactive2 'mode-line-inactive t) - -(define-separator "left-1" "right" 'spaceline-highlight-face 'powerline-active1) -(define-separator "left-2" "right" 'powerline-active1 'spaceline-highlight-face) -(define-separator "left-3" "right" 'spaceline-highlight-face 'mode-line) -(define-separator "left-4" "right" 'mode-line 'powerline-active2) - -(define-separator "right-1" "left" 'powerline-active2 'powerline-active1) -(define-separator "right-2" "left" 'powerline-active1 'mode-line) - -;; (spaceline-compile -;; "ati" -;; '( -;; ((ati-modified ati-window-numbering ati-buffer-size) :face highlight-face :skip-alternate t) -;; ;; left-active-3 -;; ati-left-1-separator -;; ((ati-projectile ati-mode-icon ati-buffer-id) :face default-face) -;; ati-left-2-separator -;; ((ati-process ati-position ati-region-info) :face highlight-face :separator " | ") -;; ati-left-3-separator -;; ati-left-inactive-separator -;; ((ati-vc-icon ati-flycheck-status ati-package-updates purpose) :separator " · " :face other-face) -;; ati-left-4-separator) - -;; '(ati-right-1-separator -;; ((ati-suntime ati-weather) :separator " · " :face other-face) -;; ati-right-2-separator -;; ati-right-inactive-separator -;; ((ati-battery-status ati-time) :separator " | " :face other-face) -;; )) - -;; (setq mode-line-format '("%e" (:eval (spaceline-ml-main)))) - -(provide 'extensions/editor/spaceline-alt) -;;; spaceline-alt.el ends here -;; Local Variables: -;; indent-tabs-mode: nil -;; End: