From 04ae06edcb334f9444adb6dc1172ecb296834059 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 10 Apr 2024 14:48:47 +0100 Subject: [PATCH] Move the activation of global modes to emacs-startup --- lisp/fg42/autocomplete.el | 4 +- lisp/fg42/editor.el | 81 +++++++++++++++++++++------------------ lisp/fg42/modeline.el | 3 +- nix/fg42.nix | 24 +++++++----- 4 files changed, 60 insertions(+), 52 deletions(-) diff --git a/lisp/fg42/autocomplete.el b/lisp/fg42/autocomplete.el index 283cbb8..81c33d2 100644 --- a/lisp/fg42/autocomplete.el +++ b/lisp/fg42/autocomplete.el @@ -44,8 +44,8 @@ :config (setq-default company-backends - '((company-capf :with company-yasnippet) :separate - (company-keywords company-dabbrev company-ispell) :separate + '((company-capf :with company-yasnippet :separate) + (company-keywords company-dabbrev company-ispell :separate) company-files)) (bind-key [remap completion-at-point] #'company-complete company-mode-map)) diff --git a/lisp/fg42/editor.el b/lisp/fg42/editor.el index b071028..ea4df65 100644 --- a/lisp/fg42/editor.el +++ b/lisp/fg42/editor.el @@ -36,10 +36,11 @@ (require 'fg42/wm) (require 'fg42/org) (require 'fg42/minibuffer) - (require 'fg42/graphics)) + (require 'fg42/graphics) + (require 'fg42/modeline)) (require 'server) -(require 'fg42/modeline) + (defvar fg42/font '("Fira Mono" 12) @@ -158,26 +159,26 @@ contextual information." "This cube controls the different aspect of buffer navigation" :bind ("C-" . ace-window)) - (when-not-wm + (when-not-wm - (use! flyspell - "Spell checking on the fly" - :commands (flyspell-mode flyspell-prog-mode) - :init - (setq-default ispell-program-name "aspell") - (setq-default ispell-extra-args '("--sug-mode=ultra" - "--lang=en_US" - "--camel-case"))) + (use! flyspell + "Spell checking on the fly" + :commands (flyspell-mode flyspell-prog-mode) + :init + (setq-default ispell-program-name "aspell") + (setq-default ispell-extra-args '("--sug-mode=ultra" + "--lang=en_US" + "--camel-case"))) - (use! savehist - "Persist history over Emacs restarts. Vertico sorts by history position." - :init - (savehist-mode)) + (use! savehist + "Persist history over Emacs restarts. Vertico sorts by history position." + :init + (savehist-mode)) - (use! display-line-numbers - "The builtin replacement of linum. It's is pretty fast." - :config - (global-display-line-numbers-mode 1))) + (use! display-line-numbers + "The builtin replacement of linum. It's is pretty fast." + :config + (global-display-line-numbers-mode 1))) (use! yasnippet @@ -240,12 +241,9 @@ shipped with Emacs." (setq tooltip-use-echo-area t) (setq x-gtk-use-system-tooltips nil) - ;; Switch from `dabbrev-expand' to `hippie-expand' - (global-set-key [remap dabbrev-expand] 'hippie-expand) ;; Global configurations (tool-bar-mode -1) (tooltip-mode nil) - (menu-bar-mode -1) (when (display-graphic-p) @@ -253,25 +251,32 @@ shipped with Emacs." (pixel-scroll-precision-mode) (scroll-bar-mode -1)) - (column-number-mode t) - (show-paren-mode t) - (electric-pair-mode 1) - (global-company-mode) - - ;; git changes in the fringe - (global-diff-hl-mode) - - (noether-global-mode) - - ;; Rectangular select - (cua-selection-mode t) - - ;; Yank the region on type - (delete-selection-mode 1) - (defalias 'yes-or-no-p 'y-or-n-p) ;; Hooks --- + (add-hook + 'emacs-startup-hook + (lambda () + ;; Switch from `dabbrev-expand' to `hippie-expand' + (global-set-key [remap dabbrev-expand] 'hippie-expand) + + (column-number-mode t) + (show-paren-mode t) + (electric-pair-mode 1) + (global-company-mode) + + ;; git changes in the fringe + (global-diff-hl-mode) + + ;; Modeline replacement + (noether-global-mode) + + ;; Rectangular select + (cua-selection-mode t) + + ;; Yank the region on type + (delete-selection-mode 1))) + ;; Deletel extra trailing white spaces on save (add-hook 'before-save-hook 'delete-trailing-whitespace) diff --git a/lisp/fg42/modeline.el b/lisp/fg42/modeline.el index 029784d..6a37397 100644 --- a/lisp/fg42/modeline.el +++ b/lisp/fg42/modeline.el @@ -54,9 +54,8 @@ "Smart mode line is a pretty simple yet fantastic alternative to Emacs modeline." :if (display-graphic-p) - :after projectile + ;;:after projectile :commands noether-global-mode - :config (require 'noether-views) diff --git a/nix/fg42.nix b/nix/fg42.nix index 4a123c2..874b6c2 100644 --- a/nix/fg42.nix +++ b/nix/fg42.nix @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . { lib, stdenv, elispPkgs, srcDir, emacsPackagesFor, ourPackages, direnv -, makeDesktopItem, nix +, makeFontsConf, nix , nil, # nix lsp server @@ -74,18 +74,19 @@ let pathsStr = lib.strings.concatStrings (lib.strings.intersperse ":" paths); mimes = import ./mimes.nix; + fontsConf = makeFontsConf { + fontDirectories = [ + vazir-fonts + fira-code + nerdfonts + fira-mono + noto-fonts + ]; + }; in stdenv.mkDerivation (final: rec { inherit version; pname = "fg42"; - - desktop = makeDesktopItem { - name = "FG42"; - desktopName = "FG42"; - exec = "${placeholder "out"}/bin/fg42 %F"; - comment = "Emacs Editor for advance users"; - }; - src = srcDir; outputs = [ "out" ]; @@ -98,6 +99,8 @@ in stdenv.mkDerivation (final: rec { cp -rv ${src}/lisp/ $LISPDIR cp -rv ${src}/share $out/ cp -rv ${src}/snippets $LISPDIR/snippets + cp "${fontsConf}" $LISPDIR/fonts.conf + export FONTCONFIG_FILE="$LISPDIR/fonts.conf" cat >> $out/share/applications/FG42.desktop << EOF [Desktop Entry] @@ -128,6 +131,7 @@ in stdenv.mkDerivation (final: rec { export FG42_EMACSD=~/.fg42/v4/emacs.d export FG42_USE_NIX=true; export PATH=${pathsStr}:$PATH + export FONTCONFIG_FILE="$LISPDIR/fonts.conf" LIBRARY_PATH="\$(${stdenv.cc}/bin/cc -print-file-name=libgccjit.so):\$LIBRARY_PATH" \ FG42_WM=fales ${emacsBundle}/bin/emacs \ @@ -145,6 +149,7 @@ in stdenv.mkDerivation (final: rec { export FG42_EMACSD=~/.fg42/v4/emacs.d export FG42_USE_NIX=true; export PATH=${pathsStr}:\$PATH + export FONTCONFIG_FILE="$LISPDIR/fonts.conf" # Disable access control for the current user. ${xorg.xhost}/bin/xhost +SI:localuser:\$USER @@ -179,7 +184,6 @@ in stdenv.mkDerivation (final: rec { ${nerdfonts} ${noto-fonts} ${lib.strings.concatLines paths} - ${desktop}/share/applications/FG42.desktop EOF runHook postBuild