Refactor the defcube macro to start the body with the splated props

This commit is contained in:
Sameer Rahmani 2023-06-10 22:47:07 +01:00
parent d65037f57f
commit fa0c5765eb
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
39 changed files with 364 additions and 410 deletions

View File

@ -27,9 +27,9 @@
(defcube fg42/agda-cube
"Integrate Agda-mode with Fg42"
(:title "Agda cube"
:flag-default t
:flag agda)
:title "Agda cube"
:flag-default t
:flag agda
(load-file
(let* ((coding-system-for-read 'utf-8)
(home (getenv "HOME"))

View File

@ -26,9 +26,9 @@
(defcube fg42/flycheck-cube
"This cube adds the `flycheck' support to fg42."
(:title "Flycheck cube"
:flag flycheck
:flag-default t)
:title "Flycheck cube"
:flag flycheck
:flag-default t
(fpkg/use flycheck
:defer ()
:init
@ -37,16 +37,16 @@
(defcube fg42/yaml-cube
"Yaml Support"
(:title "Yaml Support"
:no-flag t)
:title "Yaml Support"
:no-flag t
(fpkg/use yaml-mode))
(defcube fg42/lsp-cube
"LSP cube"
(:title "LSP cube"
:flag lsp
:flag-default t)
:title "LSP cube"
:flag lsp
:flag-default t
(fpkg/use lsp-mode
:commands lsp
@ -66,9 +66,9 @@
(defcube fg42/company-cube
"Auto complete using company mode"
(:title "Company cube"
:flag company
:flag-default t)
:title "Company cube"
:flag company
:flag-default t
(fpkg/use company
:bind (:map company-active-map

View File

@ -31,9 +31,9 @@
(defcube fg42/bookmark-cube
"bookmark cube"
(:title "cubes/fg42/bookmark-cube.org"
:flag bookmark
:flag-default t)
:title "cubes/fg42/bookmark-cube.org"
:flag bookmark
:flag-default t
(let* ((bnext (or (plist-get fg42/bookmark-cube-params :bm-next-key) "M-]"))
(bprev (or (plist-get fg42/bookmark-cube-params :bm-previous-key) "M-["))

View File

@ -31,9 +31,9 @@
"Clojure support cube for fg42.
Installs and activates clojure-mode, cider, paredit and rainbow-delimiters.
Also activates LSP and converts `fn` to λ."
(:title "Clojure cube"
:flag clojure
:flag-default t)
:title "Clojure cube"
:flag clojure
:flag-default t
(fpkg/use aggressive-indent-mode
:config (paredit-mode +1))

View File

@ -27,9 +27,9 @@
(defcube fg42/cmake-cube
"This cube enables CMake integration with FG42"
(:title "CMake cube"
:flag-default t
:flag cmake)
:title "CMake cube"
:flag-default t
:flag cmake
(fpkg/use cmake-mode)
(fpkg/use eldoc-cmake))
@ -39,16 +39,17 @@
(defcube fg42/ninja-cube
"This cube enables Ninja integration with FG42. For more info checkout:
https://github.com/ninja-build/ninja/blob/master/misc/ninja-mode.el"
(:title "Ninja cube"
:flag-default t
:flag ninja)
:title "Ninja cube"
:flag-default t
:flag ninja
(fpkg/use ninja-mode))
(defcube fg42/c++-cube
"C++ cube"
(:title "C++ cube"
:no-flag t)
:title "C++ cube"
:no-flag t
(fg42/cmake-cube)
(fg42/ninja-cube)
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))

View File

@ -41,9 +41,9 @@
"This cube install ~origami~ which let you collapse and expand regions of text.
For more info checkout [[https://github.com/gregsexton/origami.el]]"
(:title "Folding cube"
:flag folding
:flag-default t)
:title "Folding cube"
:flag folding
:flag-default t
(fpkg/use origami
:bind
(("C-c TAB" . origami-toggle-node))
@ -89,9 +89,9 @@ contextual information."
(defcube fg42/pinentry-cube
"Pinentry cube with setup the =pinentry= program to be used within FG42."
(:title "Pinentry cube"
:flag pinentry
:flag-default t)
:title "Pinentry cube"
:flag pinentry
:flag-default t
(fpkg/use pinentry
:init
(progn
@ -101,9 +101,9 @@ contextual information."
(defcube fg42/imenu-cube
"Imenu support"
(:title "Imenu cube"
:flag imenu
:flag-default t)
:title "Imenu cube"
:flag imenu
:flag-default t
(fpkg/use imenu-list
:init
(global-set-key (kbd "C-'") #'imenu-list-smart-toggle)))
@ -111,34 +111,34 @@ contextual information."
(defcube fg42/alert-cube
"alert support"
(:title "Alert cube"
:flag alert
:flag-default t)
:title "Alert cube"
:flag alert
:flag-default t
(fpkg/use alert))
(defcube fg42/emojify-cube
"Adds support for emojis to *FG42*"
(:title "Emojify cube"
:flag emoji
:flag-default t)
:title "Emojify cube"
:flag emoji
:flag-default t
(fpkg/use emojify
:hook (after-init . global-emojify-mode)))
(defcube fg42/discover-cube
"Adds support for the [[https://github.com/mickeynp/discover.el][discover]]"
(:title "Discover cube"
:flag discover
:flag-default t)
:title "Discover cube"
:flag discover
:flag-default t
(fpkg/use discover))
(defcube fg42/exec-path-cube
"This cube fixes the =exec-path-from-shell= issue on MacOS."
(:title "Exec path cube"
:flag exec-path-from-shell
:flag-default t)
:title "Exec path cube"
:flag exec-path-from-shell
:flag-default t
(fpkg/use exec-path-from-shell
:init
(when (memq window-system '(mac ns x))
@ -147,9 +147,9 @@ contextual information."
(defcube fg42/hl-cube
"This cube highlight the curret line."
(:title "Current line highlight cube"
:flag hl-line
:flag-default t)
:title "Current line highlight cube"
:flag hl-line
:flag-default t
(require 'hl-line)
(global-hl-line-mode))
@ -160,9 +160,9 @@ such as parentheses, brackets or braces according to their depth. Each successiv
is highlighted in a different color. This makes it easy to spot matching delimiters,
orient yourself in the code, and tell which statements are at a given depth."
(:title "Rainbow Delimiters Cube"
:flag rainbow-delimiters
:flag-default t)
:title "Rainbow Delimiters Cube"
:flag rainbow-delimiters
:flag-default t
(fpkg/use rainbow-delimiters
;; It doesn't work due to a problem/conflict in rainbow-delimiters
@ -174,9 +174,9 @@ orient yourself in the code, and tell which statements are at a given depth."
"=paredit= is a minor mode for performing structured editing of S-expression
data. The typical example of this would be Lisp or Scheme source code."
(:title "Paredit Cube"
:flag paredit
:flag-default t)
:title "Paredit Cube"
:flag paredit
:flag-default t
(fpkg/use paredit
:hook ((emacs-lisp-mode . paredit-mode)
(clojure-mode . paredit-mode)
@ -185,9 +185,9 @@ data. The typical example of this would be Lisp or Scheme source code."
(defcube fg42/cursor-cube
"This cube controls the shape of the cursor."
(:title "Cursor cube"
:flag cursor-type
:flag-default t)
:title "Cursor cube"
:flag cursor-type
:flag-default t
(let ((ctype (or (plist-get fg42/cursor-cube-params :type) 'box))
(ccolor (or (plist-get fg42/cursor-cube-params :color) "#aa0000")))
@ -198,9 +198,9 @@ data. The typical example of this would be Lisp or Scheme source code."
(defcube fg42/buffer-navigation-cube
"This cube controls the different aspect of buffer navigation"
(:title "Buffer navigation cube"
:flag buffer-navigation
:flag-default t)
:title "Buffer navigation cube"
:flag buffer-navigation
:flag-default t
(fpkg/use avy
:bind ("M-1" . avy-goto-word-1)))
@ -208,9 +208,9 @@ data. The typical example of this would be Lisp or Scheme source code."
(defcube fg42/window-navigation-cube
"This cube controls the different aspect of buffer navigation"
(:title "Window navigation cube"
:flag window-navigation
:flag-default t)
:title "Window navigation cube"
:flag window-navigation
:flag-default t
(fpkg/use ace-window
:bind ("C-<tab>" . ace-window)))
@ -218,9 +218,9 @@ data. The typical example of this would be Lisp or Scheme source code."
(defcube fg42/font-cube
"This cube controls the font configuration of *FG42*"
(:title "Font Cube"
:no-flag t
:flag-default t)
:title "Font Cube"
:no-flag t
:flag-default t
(let ((font (or (plist-get fg42/font-cube-params :font-name)
"Fira Mono"))
(size (or (plist-get fg42/font-cube-params :font-size)
@ -236,28 +236,28 @@ data. The typical example of this would be Lisp or Scheme source code."
;TODO: Replace this cube with a `theme-cube'
(defcube fg42/dracula-theme-cube
"Replace this with a theme cube"
(:title "Dracula theme"
:no-flag t
:ui-hook (lambda ()
(fpkg/use dracula-theme
:init
(fg42/setup-theme
(load-theme 'dracula t)
(custom-theme-set-faces
'dracula
'(match ((t (:background "#44475a"))))
'(all-the-icons-lgreen ((t (:background "#bd93f9"))))
'(all-the-icons-faicon ((t (:background "#bd93f9"))))
'(font-lock-comment-face ((t (:foreground "#8B9298"))))
'(font-lock-comment-delimiter-face ((t (:foreground "#5B6268")))))
(enable-theme 'dracula)
(set-face-attribute 'region nil :background "#888"))))))
:title "Dracula theme"
:no-flag t
:ui-hook (lambda ()
(fpkg/use dracula-theme
:init
(fg42/setup-theme
(load-theme 'dracula t)
(custom-theme-set-faces
'dracula
'(match ((t (:background "#44475a"))))
'(all-the-icons-lgreen ((t (:background "#bd93f9"))))
'(all-the-icons-faicon ((t (:background "#bd93f9"))))
'(font-lock-comment-face ((t (:foreground "#8B9298"))))
'(font-lock-comment-delimiter-face ((t (:foreground "#5B6268")))))
(enable-theme 'dracula)
(set-face-attribute 'region nil :background "#888")))))
(defcube fg42/badwolf-theme-cube
"Badwolf theme cube. An Emacs port of Bad Wolf theme for Vim.
https://emacsthemes.com/themes/badwolf-theme.html"
(:title "Badwolf theme"
:no-flag t)
:title "Badwolf theme"
:no-flag t
(require 'fg42/themes)
(fpkg/use badwolf-theme
@ -271,9 +271,9 @@ https://emacsthemes.com/themes/badwolf-theme.html"
(defcube fg42/selectrum-cube
"This cube adds support for `selectrum' to FG42"
(:title "Selectrum cube"
:flag selectrum
:flag-default t)
:title "Selectrum cube"
:flag selectrum
:flag-default t
(fpkg/use selectrum
:defer nil
:init
@ -296,8 +296,8 @@ https://emacsthemes.com/themes/badwolf-theme.html"
(defcube fg42/editor-cube
"This is a meta cube that sets up the basic functionalities of an Editor"
(:title "Editor cube"
:no-flag t)
:title "Editor cube"
:no-flag t
(fpkg/use rainbow-delimiters
;; It doesn't work due to a problem/conflict in rainbow-delimiters

View File

@ -32,10 +32,10 @@
(defcube fg42/eldoc-box-cube
"This cube sets up the =eldoc-box= system to show documentations on demand in
a box."
(:title "Eldoc box Cube"
:flag eldoc-box
:flag-default t
:modes '(eldoc-box-hover-mode eldoc-box-hover-at-point-mode))
:title "Eldoc box Cube"
:flag eldoc-box
:flag-default t
:modes '(eldoc-box-hover-mode eldoc-box-hover-at-point-mode)
(fpkg/use eldoc-box
:config
(add-hook 'eldoc-mode-hook 'eldoc-box-hover-at-point-mode)))

View File

@ -28,8 +28,8 @@
(defcube fg42/elisp-cube
"Elisp cube"
(:title "cubes/fg42/elisp-cube.org"
:no-flag t)
:title "cubes/fg42/elisp-cube.org"
:no-flag t
(fg42/rainbow-delimiters-cube)
(fg42/paredit-cube)

View File

@ -59,19 +59,19 @@
"A meta cube that contains all the cubes in the system. Calling
This cube is enough to load everything and control what cube to execute
via flags."
(:title "Editor cube"
:flag-default t
:flag fg42-editor-cube
:init-hook (lambda (params)
(mapc
(lambda (cube)
(when (not (string= (symbol-name cube)
"fg42/editor"))
(let ((cube-params (plist-get
params
(intern (concat ":" (symbol-name cube))))))
(eval `(funcall #',cube ,@cube-params)))))
fg42/available-cubes))))
:title "Editor cube"
:flag-default t
:flag fg42-editor-cube
:init-hook (lambda (params)
(mapc
(lambda (cube)
(when (not (string= (symbol-name cube)
"fg42/editor"))
(let ((cube-params (plist-get
params
(intern (concat ":" (symbol-name cube))))))
(eval `(funcall #',cube ,@cube-params)))))
fg42/available-cubes)))

View File

@ -1,68 +0,0 @@
;;; FMCubes --- The file manager cubes for FG42 -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2022 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://devheroes.codes/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 <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;; Code:
(require 'fpkg)
(require 'fg42/cube)
;; TODO: Move this to an autoload file
(defun fg42/dired-external-open ()
"In dired, open the file named on this line."
(interactive)
(let ((file (dired-get-filename nil t)))
(call-process "xdg-open" nil 0 nil file)))
(defcube fg42/fm-cube
"file manager"
(:title "cubes/fg42/fm-cube.org"
:flag fm
:flag-default t)
;; Linux only
;; TODO: change this to support OS X
(setq dired-listing-switches "-lFaGh1v --group-directories-first")
;; Show directories first
(setq ls-lisp-dirs-first t)
(setq dired-recursive-copies 'always)
(setq dired-recursive-deletes 'always)
(define-key dired-mode-map (kbd "E") 'fg42/dired-external-open)
(fpkg/use dired+)
(add-to-list 'dired-mode-hook
(lambda ()
(require 'dired-x)
(require 'dired-aux)))
(when-flag async
(dired-async-mode 1))
(fpkg/use dired-narrow
:bind (:map dired-mode-map
("/" . dired-narrow))))
(provide 'cubes/fm)
;;; fm.el ends here

View File

@ -36,9 +36,9 @@ and you've made some changes to the current buffer that are not commited
yet it will highlihgt them for you.
For more info check out [[https://github.com/dgutov/diff-hl][diff-hl]] 's page."
(:title "Diff Highlight Cube"
:flag diff-hl
:flag-default t)
:title "Diff Highlight Cube"
:flag diff-hl
:flag-default t
(fpkg/use diff-hl
:init
@ -51,9 +51,9 @@ For more info check out [[https://github.com/dgutov/diff-hl][diff-hl]] 's page."
(defcube fg42/git-cube
"This cube integrates *git* into *FG42*."
(:title "Git Cube"
:flag git
:flag-default t)
:title "Git Cube"
:flag git
:flag-default t
(fpkg/use magit
:bind (("C-x g" . magit-status)))

View File

@ -28,9 +28,9 @@
(defcube fg42/godot-cube
"Godot3d integration for FG42."
(:title "Godot3d cube"
:flag-default t
:flag godot3d)
:title "Godot3d cube"
:flag-default t
:flag godot3d
(fpkg/use gdscript-mode
:mode "\\.gd\\'"))

View File

@ -29,8 +29,8 @@
(defcube fg42/golang-cube
"Golang support cube for fg42."
(:title "Golang cube" :flag golang
:flag-default t)
:title "Golang cube" :flag golang
:flag-default t
(fpkg/use go-mode
:defer t

View File

@ -35,10 +35,10 @@ be able to edit =dot= files and use =C-c C-p= to see a preview of your =dot=
file. Use =C-c C-c= to compile the =dot= file.
If =company= flag is enabled then =dot= autocomplete will be enabled as well."
(:title "Graphviz Cube"
:flag graphviz
:flag-default t
:modes 'graphviz-dot-mode)
:title "Graphviz Cube"
:flag graphviz
:flag-default t
:modes 'graphviz-dot-mode
(let ((indent-size (or (plist-get fg42/graphviz-cube-params :indent-size) 4)))
(fg42/after-cubes

View File

@ -28,9 +28,9 @@
(defcube fg42/groovy-cube
"Groovy support for FG42."
(:title "Groovy cube"
:flag groovy
:flag-default t)
:title "Groovy cube"
:flag groovy
:flag-default t
(fpkg/use groovy-emacs-mode
:defer t))

View File

@ -28,10 +28,9 @@
(defcube fg42/haml-cube
"This cube provides syntax highlighting and syntax-aware indentation
for haml files"
(:title "Haml Cube"
:flag haml
:flag-default t)
:title "Haml Cube"
:flag haml
:flag-default t
(fpkg/use haml-mode
:mode "\\.haml\\'"))

View File

@ -29,9 +29,9 @@
(defcube fg42/all-the-icons-cube
"Install the [[https://github.com/domtronn/all-the-icons.el][all-the-icons.el]]
package."
(:title "All the icons cube"
:flag all-the-icons
:flag-default t)
:title "All the icons cube"
:flag all-the-icons
:flag-default t
(fpkg/use all-the-icons
:if (display-graphic-p)))

View File

@ -27,8 +27,9 @@
(defcube fg42/rcirc-cube
"IRC cube"
(:title "cubes/fg42/rcirc-cube.org"
:flag rcirc)
:title "RCIRC Cube"
:flag rcirc
(autoload-cube 'fg42/rcirc-connect "irc/core.el" "Connect to IRC via RCIRC." t)
(defun fg42/connect-to-irc ()
(interactive)

View File

@ -27,9 +27,9 @@
(defcube fg42/gradle-cube
"Gradle support"
(:title "cubes/fg42/java-cube.org"
:flag gradle
:flag-default t)
:title "Gradle Cube"
:flag gradle
:flag-default t
(fpkg/use groovy-mode
:mode "\\.gradle\\'")
@ -43,9 +43,9 @@
(defcube fg42/java-cube
"Java cube"
(:title "cubes/fg42/java-cube.org"
:flag java
:flag-default t)
:title "Java Cube"
:flag java
:flag-default t
(add-hook 'java-mode-hook
(lambda()

View File

@ -31,9 +31,9 @@
(defcube fg42/langtool-cube
"A Language Server for LanguageTool with support for LaTeX, Markdown,
and others. For more info checkout [[https://github.com/emacs-languagetool/lsp-ltex]]"
(:title "Language tool Cube"
:flag language-tool
:flag-default t)
:title "Language tool Cube"
:flag language-tool
:flag-default t
(let ((user (plist-get fg42/langtool-cube-params :username))
(apikey (plist-get fg42/langtool-cube-params :api-key)))

View File

@ -39,9 +39,9 @@ cube.
For more info on check out [[https://codeberg.org/martianh/mastodon.el]]"
(:title "Mastodone Cube"
:flag mastodon
:flag-default nil)
:title "Mastodone Cube"
:flag mastodon
:flag-default nil
(let ((url (or (plist-get fg42/mastodon-cube-params :instance-url)
(error "Instance url is empty set the `:instance-url' key")))

View File

@ -28,9 +28,9 @@
(defcube fg42/meissa-cube
"Integrate FG42 with Meissa"
(:title "Meissa cube"
:flag-default t
:flag meissa)
:title "Meissa cube"
:flag-default t
:flag meissa
(fpkg/use msgpack)

View File

@ -29,9 +29,9 @@
"This cube enables support for meson build files.
For more info checkout [[https://github.com/wentasah/meson-mode]]"
(:title "Meson cube"
:flag mesonbuild
:flag-default t)
:title "Meson cube"
:flag mesonbuild
:flag-default t
(fpkg/use meson-mode
:config
(progn

View File

@ -33,10 +33,10 @@
;; TODO: Break this into two cubes
(defcube fg42/modeline-cube
"Modeline cube"
(:title "Mini modeline"
:flag mini-mode-line
:group modeline
:flag-default t)
:title "Mini modeline"
:flag mini-mode-line
:group modeline
:flag-default t
(defun fg42/mini-modeline-setter (def)
(if (null def)
@ -94,10 +94,10 @@
"Status bar replaces the default mode line aned merges with
the mini buffer to provide a minimal interface for displaying
valuable information."
(:title "Status bar cube"
:flag status-bar
:group modeline
:flag-default nil)
:title "Status bar cube"
:flag status-bar
:group modeline
:flag-default nil
(fg42/all-the-icons-cube)

View File

@ -28,9 +28,9 @@
(defcube fg42/ednc-cube
"Notifications support for FG42."
(:title "Notifications cube"
:flag ednc
:flag-default t)
:title "Notifications cube"
:flag ednc
:flag-default t
(fpkg/use ednc
:defer t

View File

@ -50,9 +50,10 @@ be used as a backend for other tools. The libraries ~org-ql-search~ and
After installation, you can use the commands without additional configuration.
To use the functions and macros in your own Elisp code, use libraries ~org-ql~
and ~org-ql-view~."
(:title "Org Qurey Language"
:flag org-ql
:flag-default t)
:title "Org Qurey Language"
:flag org-ql
:flag-default t
(fpkg/use org-ql
:after org))
@ -69,9 +70,9 @@ You can set your groups via the ~:groups~ parameter. Check out the code
for more parameters.
For more information checkout [[https://github.com/alphapapa/org-super-agenda]]"
(:title "Org Super Agenda"
:flag org-super-agenda
:flag-default t)
:title "Org Super Agenda"
:flag org-super-agenda
:flag-default t
(defconst fg42/org-super-agenda-groups
nil)
@ -104,9 +105,9 @@ current buffer (similar to the Org agenda, but without all its features) at the
a list of all other non-done to-do items below. If the buffer is narrowed, the sidebar only
shows items in the narrowed portion; this allows seeing an overview of tasks in a subtree."
(:title "Org Sidebar"
:flag org-sidebar
:flag-default t)
:title "Org Sidebar"
:flag org-sidebar
:flag-default t
(let ((default-file (or (plist-get fg42/org-sidebar-params :default-file) "~/orgs/main.org"))
(fns (plist-get fg42/org-sidebar-params :sidebar-fns)))
@ -143,9 +144,9 @@ cubes and you can pass parameters to them via ~:super-agenda~, ~:ql~ and ~:sideb
For more info on ~org-mode~ check out [[https://orgmode.org/]]"
(:title "Org-mode"
:flag org
:flag-default t)
:title "Org-mode"
:flag org
:flag-default t
(let ((capture-key (or (plist-get fg42/org-cube-params :capture-key)
(kbd "<f6>")))

View File

@ -28,9 +28,9 @@
(defcube fg42/projectile-cube
"Projectile Cube"
(:title "cubes/fg42/projectile-cube.org"
:flag projectile
:flag-default t)
:title "cubes/fg42/projectile-cube.org"
:flag projectile
:flag-default t
(let ((project-dirs (or (plist-get fg42/projectile-cube-params :project-dirs)
())))

View File

@ -28,9 +28,9 @@
(defcube fg42/proof-general-cube
"Integrate Proof General with Fg42"
(:title "Proof General cube"
:flag-default t
:flag proof-general)
:title "Proof General cube"
:flag-default t
:flag proof-general
(fpkg/use proof-general)
(fpkg/use company-coq

View File

@ -56,9 +56,9 @@ interactive `pyvenv-workon' function before `lsp'"
(defcube fg42/python-black-cube
"This cube reformats python code using black formatter tool."
(:title "Python lang server via pyls"
:flag python-black
:flag-default t)
:title "Python lang server via pyls"
:flag python-black
:flag-default t
(fpkg/use python-black
:demand t
@ -68,9 +68,9 @@ interactive `pyvenv-workon' function before `lsp'"
(defcube fg42/python-cube-pyls
"Python language server using pyls"
(:title "Python lang server via pyls"
:flag python-pyls
:flag-default nil)
:title "Python lang server via pyls"
:flag python-pyls
:flag-default nil
(when-flag lsp
(with-eval-after-load "lsp"
@ -85,9 +85,9 @@ interactive `pyvenv-workon' function before `lsp'"
(defcube fg42/python-cube-pyright
"Python language server using pyright."
(:title "Python lang server via pyright"
:flag python-pyright
:flag-default t)
:title "Python lang server via pyright"
:flag python-pyright
:flag-default t
(fpkg/use lsp-pyright
:ensure t
@ -103,9 +103,10 @@ interactive `pyvenv-workon' function before `lsp'"
(defcube fg42/poetry-cube
"Poetry support for FG42. To use it, just use `M-x poetry'."
(:title "Python cube"
:flag poetry
:flag-default t)
:title "Poetry cube"
:flag poetry
:flag-default t
(fpkg/use poetry
:config
(poetry-tracking-mode 1)))
@ -113,9 +114,9 @@ interactive `pyvenv-workon' function before `lsp'"
(defcube fg42/python-cube
"Python support cube."
(:title "Python cube"
:flag python
:flag-default t)
:title "Python cube"
:flag python
:flag-default t
(fpkg/use pyvenv
:defer t

View File

@ -27,7 +27,7 @@
(defcube fg42/region-expansion-cube
"RE cube"
(:title "cubes/fg42/region-expansion.org")
:title "Region Expansion Cube"
(fpkg/use expand-region
:bind ("C-=" . er/expand-region)))

View File

@ -31,9 +31,9 @@ for *FG42*. Refer to *Rigel* docs to set it up.
This cube exposes few functions that interact with regel. Checkout the docstrings of
functions in `fg42/rigel/` namespace. For example `fg42/rigel/read` function."
(:title "rigel Cube"
:flag rigel
:flag-default t)
:title "rigel Cube"
:flag rigel
:flag-default t
(autoload-cube

View File

@ -35,10 +35,10 @@ If the =lsp= flag is set it is going to use the =rust-analyzer=
as the LSP server so it has to be installed on the host OS.
For more info on check out [[https://rust-analyzer.github.io]]"
:title "Rust Cube"
:flag rust
:flag-default t
(:title "Rust Cube"
:flag rust
:flag-default t)
(fpkg/use rustic
:bind (:map rustic-mode-map
("M-j" . lsp-ui-imenu)

View File

@ -32,9 +32,9 @@
(defcube fg42/guile-cube
"This cube adds supports for GNU Guile Scheme via =emacs-lsp-scheme= library.
For more info checkout [[https://codeberg.org/rgherdt/emacs-lsp-scheme]]"
(:title "Scheme Cube"
:flag scheme
:flag-default t)
:title "Scheme Cube"
:flag scheme
:flag-default t
(fg42/rainbow-delimiters-cube)
(fg42/paredit-cube)

View File

@ -26,9 +26,9 @@
(defcube fg42/yasnippet-cube
"Yasnippet cube"
(:title "cubes/fg42/yasnippet-cube.org"
:flag yasnippet
:flag-default t)
:title "cubes/fg42/yasnippet-cube.org"
:flag yasnippet
:flag-default t
(fpkg/use yasnippet-snippets)

View File

@ -26,8 +26,8 @@
(defcube fg42/vterm-cube
"Vterm cube"
(:title "cubes/fg42/vterm-cube.org"
:flag vterm)
:title "VTerm Cube"
:flag vterm
(let ((_shell (or (plist-get fg42/vterm-cube-params :shell)
(getenv "SHELL"))))
(fpkg/use vterm

View File

@ -31,9 +31,9 @@
(defcube fg42/terraform-cube
"terraform cube"
(:title "cubes/fg42/terraform-cube.org"
:flag terraform
:flag-default t)
:title "cubes/fg42/terraform-cube.org"
:flag terraform
:flag-default t
;; https://github.com/juliosueiras/terraform-lsp is required
(let ((terraform-lsp (or (plist-get fg42/terraform-cube-params :terraform-lsp-path) "terraform-lsp"))

View File

@ -34,8 +34,8 @@
(defcube fg42/wm-cube
"This cube will setup *FG42* to act as a window manager."
(:title "Window manager cube"
:no-flag t)
:title "Window manager cube"
:no-flag t
(if-flag wm
(when-wm

View File

@ -27,9 +27,9 @@
(defcube fg42/zig-cube
"This cube integrates *zig* into *FG42*."
(:title "Zig Cube"
:flag zig
:flag-default t)
:title "Zig Cube"
:flag zig
:flag-default t
(fpkg/use zig-mode
:mode ("\\.zig?\\'" . zig-mode))

View File

@ -46,8 +46,24 @@ it is to use `fg42/after-cubes' macro.")
The execution happens after Emacs is initialized.")
(defmacro defcube (cube-name docs props &rest body)
"Define a cube with the given CUBE-NAME, a list of PROPS, DOCS and a BODY."
(defun fg42/extract-props (body-list &optional acc)
"Extract the props pairs from BODY-LIST with an optional accumulator ACC.
It will returen a pair in form of (body . props)."
(let ((k (car body-list))
(rest (cdr body-list)))
(if (and k (keywordp k))
(fg42/extract-props
(cdr rest)
(cons (cdr rest) (plist-put (cdr acc) k (car rest))))
(cons body-list (cdr acc)))))
(defmacro defcube (cube-name docs &rest props-n-body)
"Define a cube with the given CUBE-NAME, DOCS and a PROPS-N-BODY.
TODO: Docs"
(declare (indent defun) (doc-string 2))
;; Make sure that props is a plist and contains the `:docs' key
@ -55,130 +71,133 @@ The execution happens after Emacs is initialized.")
(when (not (stringp docs))
(error "Missing docstring for '%s' cube" cube-name))
(when (not (plist-get props :title))
(error "Missing :titel key for '%s' cube" cube-name))
(let* ((parsed-body (fg42/extract-props props-n-body))
(body (car parsed-body))
(props (cdr parsed-body)))
(let ((complete-props (plist-put props :docs docs))
(cube-name-internal (intern (format "%s-internal" cube-name)))
;; prop hooks
(init-hook (plist-get props :init-hook))
(ui-hook (plist-get props :ui-hook))
(when (not (plist-get props :title))
(error "Missing :titel key for '%s' cube" cube-name))
(let ((complete-props (plist-put props :docs docs))
(cube-name-internal (intern (format "%s-internal" cube-name)))
;; prop hooks
(init-hook (plist-get props :init-hook))
(ui-hook (plist-get props :ui-hook))
(params-var (intern (format "%s-params" cube-name)))
(active-var (intern (format "%s-active-p" cube-name)))
(pre-lang-server-up-hook (intern (format "%s-pre-lang-server-up-hook" cube-name)))
(post-lang-server-up-hook (intern (format "%s-post-lang-server-up-hook" cube-name)))
(pre-lang-server-down-hook (intern (format "%s-pre-lang-server-down-hook" cube-name)))
(post-lang-server-down-hook (intern (format "%s-post-lang-server-down-hook" cube-name)))
(pre-init-hook (intern (format "%s-pre-init-hook" cube-name)))
(post-init-hook (intern (format "%s-post-init-hook" cube-name)))
(post-init-hook (intern (format "%s-post-init-hook" cube-name)))
(flag-var (or (plist-get props :flag) cube-name))
(flag-docstring-var (or (plist-get props :flag-doc)
(format "The flag to enable/disable the '%s' cube." cube-name)))
(flag-default (plist-get props :flag-default))
(flag-conflict (plist-get props :conflicts-with))
(no-flag? (or (plist-get props :no-flag) ())))
(add-to-list 'fg42/available-cubes cube-name)
`(progn
;; Create a new flag for each cube to control the cubes systemwide.
(when (not ,no-flag?)
(defflag ,flag-var ,flag-docstring-var ,flag-default))
;; Params variable contains the list of params the is passed to
;; the current cube call
(defvar ,params-var nil
,(format "Parameters for the '%s' cube." cube-name))
;; * Hooks
;; This hook can be used by others to run code just before running that
;; cube's body
(defvar ,pre-init-hook nil
,(format "The hook that runs befor the '%s' cube initialization." cube-name))
(params-var (intern (format "%s-params" cube-name)))
(active-var (intern (format "%s-active-p" cube-name)))
(pre-lang-server-up-hook (intern (format "%s-pre-lang-server-up-hook" cube-name)))
(post-lang-server-up-hook (intern (format "%s-post-lang-server-up-hook" cube-name)))
(pre-lang-server-down-hook (intern (format "%s-pre-lang-server-down-hook" cube-name)))
(post-lang-server-down-hook (intern (format "%s-post-lang-server-down-hook" cube-name)))
(pre-init-hook (intern (format "%s-pre-init-hook" cube-name)))
(post-init-hook (intern (format "%s-post-init-hook" cube-name)))
(post-init-hook (intern (format "%s-post-init-hook" cube-name)))
;; This hook can be used by others to run code just after the body of
;; the cube
(defvar ,post-init-hook nil
,(format "The hook that runs after the '%s' cube initialization." cube-name))
(flag-var (or (plist-get props :flag) cube-name))
(flag-docstring-var (or (plist-get props :flag-doc)
(format "The flag to enable/disable the '%s' cube." cube-name)))
(flag-default (plist-get props :flag-default))
(flag-conflict (plist-get props :conflicts-with))
(no-flag? (or (plist-get props :no-flag) ())))
;; TODO: Move language server related hooks to lang-server
;; TODO: Provide a way to let different parts of the
;; codebase to create cube hooks
(add-to-list 'fg42/available-cubes cube-name)
;; ** Language Server
;;; The hook that enables users to change the language server configuration
;;; of the current cube before activating the server
(defvar ,pre-lang-server-up-hook nil
,(format "The hook that runs befor the '%s' cube's language server activates ." cube-name))
`(progn
;;; The hook to do any post configuration for the lang server of the cube
(defvar ,post-lang-server-up-hook nil
,(format "The hook that runs after the '%s' cube's language server activates." cube-name))
;; Create a new flag for each cube to control the cubes systemwide.
(when (not ,no-flag?)
(defflag ,flag-var ,flag-docstring-var ,flag-default))
;;; The hook to run code just before the language server is about to shutdown
(defvar ,pre-lang-server-down-hook nil
,(format "The hook that runs befor the '%s' cube's language server shuts down." cube-name))
;; Params variable contains the list of params the is passed to
;; the current cube call
(defvar ,params-var nil
,(format "Parameters for the '%s' cube." cube-name))
;;; The hook to run code after the language server successfully shuts down
(defvar ,post-lang-server-down-hook nil
,(format "The hook that runs after the '%s' cube's language server shuts down." cube-name))
;; * Hooks
;; This hook can be used by others to run code just before running that
;; cube's body
(defvar ,pre-init-hook nil
,(format "The hook that runs befor the '%s' cube initialization." cube-name))
;; This hook can be used by others to run code just after the body of
;; the cube
(defvar ,post-init-hook nil
,(format "The hook that runs after the '%s' cube initialization." cube-name))
;; TODO: Move language server related hooks to lang-server
;; TODO: Provide a way to let different parts of the
;; codebase to create cube hooks
;; ** Language Server
;;; The hook that enables users to change the language server configuration
;;; of the current cube before activating the server
(defvar ,pre-lang-server-up-hook nil
,(format "The hook that runs befor the '%s' cube's language server activates ." cube-name))
;;; The hook to do any post configuration for the lang server of the cube
(defvar ,post-lang-server-up-hook nil
,(format "The hook that runs after the '%s' cube's language server activates." cube-name))
;;; The hook to run code just before the language server is about to shutdown
(defvar ,pre-lang-server-down-hook nil
,(format "The hook that runs befor the '%s' cube's language server shuts down." cube-name))
;;; The hook to run code after the language server successfully shuts down
(defvar ,post-lang-server-down-hook nil
,(format "The hook that runs after the '%s' cube's language server shuts down." cube-name))
;; This way we can bypass the flag system if we really really want to.
(defun ,cube-name-internal (params)
(if (or (not (boundp (quote ,active-var)))
(not ,active-var))
(progn
;; Mark this cube as active
(setq ,active-var t)
;; Set the parameters in CUBE-NAME-params to be accessable
;; in the body
(setq ,params-var params)
;; Run the pre init hook
(run-hooks (quote ,pre-init-hook))
(fg42/info "Initializing '%s' cube." (quote ,cube-name))
;; Run the body
(let ((result (progn ,@body)))
;; Run the post init hook
(run-hooks (quote ,post-init-hook))
result))
(fg42/info "The '%s' cube is already active." ',cube-name)))
(defun ,cube-name (&rest params)
(interactive)
(let ((ui-hook ,ui-hook)
(init-hook ,init-hook))
(if ,no-flag?
;; This way we can bypass the flag system if we really really want to.
(defun ,cube-name-internal (params)
(if (or (not (boundp (quote ,active-var)))
(not ,active-var))
(progn
(when (not (null ui-hook))
(add-hook 'fg42/ui-hook ui-hook))
;; If no flag is need to control this cube
(when (not (null init-hook))
(funcall init-hook params))
(add-hook 'fg42/-cubes-body-hook (lambda ()
(,cube-name-internal params))))
;; Otherwise check for the flag to be active
(if-flag ,flag-var
(progn
(when (not (null ui-hook))
(add-hook 'fg42/ui-hook ,ui-hook))
(when (not (null init-hook))
(funcall init-hook params))
(add-hook 'fg42/-cubes-body-hook (lambda ()
(,cube-name-internal params))))
(fg42/info "The flag for '%s' cube is disabled. Skiping." ,(symbol-name cube-name))))))
;; Mark this cube as active
(setq ,active-var t)
;; Set the symbol-plist of the cube-name to its props
(setplist ',cube-name ',complete-props))))
;; Set the parameters in CUBE-NAME-params to be accessable
;; in the body
(setq ,params-var params)
;; Run the pre init hook
(run-hooks (quote ,pre-init-hook))
(fg42/info "Initializing '%s' cube." (quote ,cube-name))
;; Run the body
(let ((result (progn ,@body)))
;; Run the post init hook
(run-hooks (quote ,post-init-hook))
result))
(fg42/info "The '%s' cube is already active." ',cube-name)))
(defun ,cube-name (&rest params)
(interactive)
(let ((ui-hook ,ui-hook)
(init-hook ,init-hook))
(if ,no-flag?
(progn
(when (not (null ui-hook))
(add-hook 'fg42/ui-hook ui-hook))
;; If no flag is need to control this cube
(when (not (null init-hook))
(funcall init-hook params))
(add-hook 'fg42/-cubes-body-hook (lambda ()
(,cube-name-internal params))))
;; Otherwise check for the flag to be active
(if-flag ,flag-var
(progn
(when (not (null ui-hook))
(add-hook 'fg42/ui-hook ,ui-hook))
(when (not (null init-hook))
(funcall init-hook params))
(add-hook 'fg42/-cubes-body-hook (lambda ()
(,cube-name-internal params))))
(fg42/info "The flag for '%s' cube is disabled. Skiping." ,(symbol-name cube-name))))))
;; Set the symbol-plist of the cube-name to its props
(setplist ',cube-name ',complete-props)))))
(defmacro fg42/after-cubes (&rest body)
@ -195,9 +214,9 @@ It passes the BODY to `fpkg/use'."
(declare (indent defun) (doc-string 2))
`(defcube ,(intern (format "fg42/%s-cube" pkg))
,docs
(:title ,(format "%s cube" pkg)
:flag ,pkg
:flag-default t)
:title ,(format "%s cube" pkg)
:flag ,pkg
:flag-default t
(fpkg/use ,pkg ,@body)))