2020-04-14 20:09:47 +01:00
|
|
|
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
|
|
|
;;
|
2024-02-18 16:08:02 +00:00
|
|
|
;; Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
|
2020-04-14 20:09:47 +01:00
|
|
|
;;
|
|
|
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
2022-12-19 21:07:48 +00:00
|
|
|
;; URL: https://devheroes.codes/FG42/FG42
|
2024-04-05 21:04:36 +01:00
|
|
|
;; Version: 4.0.0
|
2020-04-14 20:09:47 +01:00
|
|
|
;;
|
|
|
|
;; 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 <http://www.gnu.org/licenses/>.
|
|
|
|
;;
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
2021-03-05 16:30:30 +00:00
|
|
|
(require 'fg42/core)
|
2021-01-29 00:16:46 +00:00
|
|
|
(require 'fg42/utils)
|
|
|
|
|
2020-04-14 20:09:47 +01:00
|
|
|
|
2023-06-10 20:47:55 +01:00
|
|
|
(defvar fg42/-gc-cons-threshold 16777216
|
|
|
|
"Value of GC threshold of FG42.")
|
|
|
|
|
2023-06-11 12:47:00 +01:00
|
|
|
(defvar fg42/initialized nil
|
|
|
|
"A variable that indicates whether FG42 is passed initialization.")
|
|
|
|
|
2023-06-10 20:47:55 +01:00
|
|
|
(defun defer-garbage-collection ()
|
|
|
|
"Disable garbage collection."
|
|
|
|
(setq gc-cons-threshold fg42/-gc-cons-threshold))
|
|
|
|
|
|
|
|
|
|
|
|
(defun restore-garbage-collection ()
|
|
|
|
"Restore garbage collection to it's default value."
|
|
|
|
(run-at-time
|
|
|
|
1 nil (lambda () (setq gc-cons-threshold most-positive-fixnum))))
|
2021-03-06 18:40:57 +00:00
|
|
|
|
|
|
|
|
2021-03-05 16:30:30 +00:00
|
|
|
(defun fg42/initialize ()
|
2021-03-06 18:40:57 +00:00
|
|
|
"Initialize FG42 after the Emacs window is rendered by loading the user init file."
|
2023-10-17 10:44:18 +01:00
|
|
|
;; (fg42/-startup-optimization)
|
2023-06-10 20:47:55 +01:00
|
|
|
(require 'fpkg/core)
|
|
|
|
(fpkg/initialize)
|
2024-02-20 14:53:50 +00:00
|
|
|
|
2021-04-21 11:45:33 +01:00
|
|
|
(when (file-exists-p user-init-file)
|
2023-06-10 20:47:55 +01:00
|
|
|
(require 'fg42/cube)
|
2024-02-22 14:19:57 +00:00
|
|
|
(require 'fg42/flags)
|
|
|
|
(require 'fg42/cubes/fg42)
|
|
|
|
|
2023-06-10 20:47:55 +01:00
|
|
|
(load user-init-file))
|
2024-02-20 14:53:50 +00:00
|
|
|
|
2023-06-10 20:47:55 +01:00
|
|
|
(add-hook 'emacs-startup-hook
|
|
|
|
(lambda ()
|
|
|
|
(run-hooks 'fg42/-cubes-body-hook)
|
|
|
|
(run-hooks 'fg42/after-cubes-setup-hook)
|
|
|
|
(run-hooks 'fg42/after-init-hook)
|
|
|
|
(run-hooks 'fg42/after-initializing-theme-hook)
|
2023-06-11 12:47:00 +01:00
|
|
|
(run-hooks 'fg42/ui-hook)
|
|
|
|
(setq fg42/initialized t))))
|
2023-06-10 20:47:55 +01:00
|
|
|
|
|
|
|
|
2024-03-21 19:37:50 +00:00
|
|
|
(defun fg42/initialize-v4 ()
|
|
|
|
"Initialize FG42 after the Emacs window is rendered by loading the user init file."
|
|
|
|
;; (fg42/-startup-optimization)
|
|
|
|
(require 'fg42/editor)
|
|
|
|
|
|
|
|
(when (file-exists-p user-init-file)
|
|
|
|
(load user-init-file))
|
|
|
|
|
2024-03-21 20:21:23 +00:00
|
|
|
(fg42/setup-editor)
|
|
|
|
|
2024-03-21 19:37:50 +00:00
|
|
|
(add-hook 'emacs-startup-hook
|
|
|
|
(lambda ()
|
|
|
|
(run-hooks 'fg42/after-init-hook)
|
|
|
|
(run-hooks 'fg42/after-initializing-theme-hook)
|
|
|
|
(run-hooks 'fg42/ui-hook)
|
|
|
|
(setq fg42/initialized t))))
|
|
|
|
|
|
|
|
|
2023-06-10 20:47:55 +01:00
|
|
|
(defun fg42/-startup-optimization ()
|
|
|
|
"Optimized FG42 startup."
|
|
|
|
;; by setting gc threshold to the largest number
|
|
|
|
;; Emacs can understand we are basically disabling it :).
|
|
|
|
(setq gc-cons-threshold most-positive-fixnum
|
|
|
|
gc-cons-percentage 0.6)
|
|
|
|
;; after initilization phase restore cons threshold to normal
|
|
|
|
(add-hook 'emacs-startup-hook
|
|
|
|
(lambda ()
|
|
|
|
(setq gc-cons-threshold fg42/-gc-cons-threshold ; 16mb
|
|
|
|
gc-cons-percentage 0.1)))
|
|
|
|
|
|
|
|
;; disable auto initilization of package.el
|
|
|
|
(setq package-enable-at-startup nil)
|
|
|
|
;; disable gc when we are in minibuffer using the same method we
|
|
|
|
;; use for initilization time
|
|
|
|
(add-hook 'minibuffer-setup-hook #'defer-garbage-collection)
|
|
|
|
;; just enable gc when exiting minibuffer
|
|
|
|
(add-hook 'minibuffer-exit-hook #'restore-garbage-collection)
|
|
|
|
;; we dont need Emacs to check every file type and look for file
|
|
|
|
;; handlers when we are initializing so we backup the original
|
|
|
|
;; value and set it to nil
|
|
|
|
(setq --file-name-handler-alist file-name-handler-alist)
|
|
|
|
|
|
|
|
(setq file-name-handler-alist nil)
|
|
|
|
;; after initialization we can restore that file-name-handler-alist
|
|
|
|
;; to original value.
|
|
|
|
(add-hook 'emacs-startup-hook
|
|
|
|
(lambda ()
|
|
|
|
(setq file-name-handler-alist
|
|
|
|
--file-name-handler-alist)))
|
|
|
|
;; initial mode for emacs can be fundamental mode we have nothing to lose
|
|
|
|
(setq initial-major-mode 'fundamental-mode))
|
2020-04-14 20:09:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
(provide 'fg42)
|
|
|
|
;;; fg42.el ends here
|