diff --git a/README.org b/README.org index ab6c0a9..bbe953e 100644 --- a/README.org +++ b/README.org @@ -1,5 +1,186 @@ * How To Use #+begin_src sh :results output scalar -ln -sf ~/.emacs.d +cp -r ~/.emacs.d +chown -R ~/.emacs.d +# ln -sf ~/.emacs.d +#+end_src + +* Introduction + +*"Original" EMACS:* +- 1976 +- David A. Moon & Guy L. Steele Jr. +- Set of macros for the TECO editor (char based editor) + +*Gosling Emacs:* +- 1981 +- James Gosling (the Java® guy) + +*GNU Emacs:* +- 1984 +- Richard Stallman aka. [[http://stallman.org/saint.html][Saint IGNUcius]] /(saint in the Church of Emacs)/ + +*Latest Release*: Emacs 30.1 +*Released:* February, 2025 + +Emacs uses ~emacs-lisp~: +- lisp dialect +- functional (not pure though) +- specially developed to configure Emacs + +** Variables + +#+begin_src emacs-lisp :results output scalar +(defvar my/var nil "My very own variable") +(setq my/var "Hey Emacs!") +(print my/var) +;; There are more... (setq-local, setq-default) +#+end_src + +#+RESULTS: +: " +: \"Hey Emacs!\" +: " + +** Functions + +#+begin_src emacs-lisp :results output scalar +(defun test () + "Docstring" + (interactive) + (print my/var)) + +(test) +#+end_src + +#+begin_src emacs-lisp :results output scalar +(defun more (a b &optional c d &rest e) + (interactive) + ; 'a 'b 'c 'd '(...) + (print (concat a b c d (mapconcat #'identity e "")))) + +(more "1" "2" "3" "4" "5" "6" "7") +(more "1" "2" "3") +#+end_src + +#+RESULTS: +: " +: \"1234567\" +: +: \"123\" +: " + +#+begin_src emacs-lisp :results output scalar +(defun print-name (&rest args) + (interactive) + (let ((first (plist-get args :first)) + (last (or (plist-get args :last) "?"))) + (princ last) + (when first + (princ ", ") + (princ first)))) + +(print-name :first "Philip" :last "B1") +#+end_src + +#+RESULTS: +: "B1, Philip" + +** Let Bindings + +#+begin_src emacs-lisp :results output scalar +(defun another-test (a b) + "Multiplies `A' times `B' and adds them afterwards" + (interactive) + (let* ((x a) + (y (* x b))) + (+ x y))) + +(print (another-test 2 4)) +#+end_src + +#+RESULTS: +: " +: 10 +: " + +** Hooks + +#+begin_src emacs-lisp :results output scalar +(defun my/fun () (message "Emacs is cool!")) +(add-hook 'after-save-hook #'my/fun) +;; (remove-hook 'after-save-hook 'my/fun) +#+end_src + +** Package Management & Configuration + +*Package Manager* +- https://github.com/radian-software/straight.el + +#+begin_src emacs-lisp :results output scalar +; Standard is package.el +(straight-use-package 'nix-mode) +#+end_src + +#+RESULTS: +: "" + +*Configuration Macro* +- https://github.com/jwiegley/use-package + +#+begin_src emacs-lisp :results output scalar +(straight-use-package 'use-package) + +;; Macro that provides syntactic sugar +(use-package color-moccur + ;; Creates autoloads for these commands + ;; Defers loading of the module until command is used + :commands (isearch-moccur isearch-all) + ;; Keybindings + :bind (("M-s O" . moccur) + :map isearch-mode-map + ("M-o" . isearch-moccur) + ("M-O" . isearch-moccur-all)) + ;; Before package is loaded + :init + (setq isearch-lazy-highlight t) + ;; After package is loaded + :config + (use-package moccur-edit)) +#+end_src + +** Tour de Emacs Config + +.emacs.d/ +├── early-init.el +├── init.el +└── cnf/ + ├── app + └── lang + +** Tasks +*** Keybinding + +- Create a new keybinding for the ~emacs-lisp-mode~ that executes ~eval-last-sexp~ with the binding ~SPC x e~ while in ~normal~ mode + +**** Possible Solution + +#+begin_src emacs-lisp :results output scalar +(my-leader + :keymaps 'emacs-lisp-mode-map + :states 'normal + "x" '(:ignore t :which-key "Eval") + "x e" 'eval-last-sexp + "x b" 'eval-buffer) +#+end_src + +*** Package + +- Install a new package using straight, e.g. ~swiper~ (or something else) + +**** Possible Solution + +#+begin_src emacs-lisp :results output scalar +(straight-use-package 'swiper) #+end_src diff --git a/cnf/additionals.el b/cnf/additionals.el index a3e85fa..1e7dbdc 100644 --- a/cnf/additionals.el +++ b/cnf/additionals.el @@ -5,21 +5,7 @@ ;; ORD-MODE: Basically jupiter notebooks/markdown on steroids (with-eval-after-load 'org (require 'a-orgmode)) -;; MAGIT: A nice git frontend -(straight-use-package 'magit) -(setq magit-bury-buffer-function #'quit-window - magit-display-buffer-function #'display-buffer) - -(with-eval-after-load 'magit - (transient-append-suffix 'magit-push "-u" - '(1 "=s" "Skip gitlab pipeline" "--push-option=ci.skip")) - (transient-append-suffix 'magit-push "=s" - '(1 "=D" "DEBUG" "--push-option=ci.variable=DEBUG=1")) ;; no special meaning for gitlab - (transient-append-suffix 'magit-push "=D" - '(1 "=V" "Set CI variable" "--push-option=ci.variable=")) ;; Will prompt, can only set one extra variable - (transient-append-suffix 'magit-push "=V" - '(1 "=O" "Set push option" "--push-option=")) - ) +(require 'a-magit) ;; YASNIPPET: snippets (straight-use-package 'yasnippet) @@ -144,4 +130,4 @@ modified and not saved. `ARGS' is the rest of the arguments." ;; Width used to draw the column indicator + used in fill-paragraph (setq-default fill-column 90) -(provide 'additionals) \ No newline at end of file +(provide 'additionals) diff --git a/cnf/app/a-dired.el b/cnf/app/a-dired.el index 5229c0b..c1dc3ef 100644 --- a/cnf/app/a-dired.el +++ b/cnf/app/a-dired.el @@ -5,32 +5,7 @@ (setq dired-listing-switches "-lFahv --group-directories-first" dired-dwim-target t delete-by-moving-to-trash t - dired-ls-F-marks-symlinks t - dired-compress-files-alist '(("\\.tar\\.gz\\'" . "tar -cf - %i | gzip -c9 > %o") - ("\\.tar\\.bz2\\'" . "tar -cf - %i | bzip2 -c9 > %o") - ("\\.tar\\.xz\\'" . "tar -cf - %i | xz -c9 > %o") - ("\\.tar\\.zst\\'" . "tar -cf - %i | zstd -19 -o %o") - ("\\.tar\\.lz\\'" . "tar -cf - %i | lzip -c9 > %o") - ("\\.tar\\.lzo\\'" . "tar -cf - %i | lzop -c9 > %o") - ("\\.zip\\'" . "zip %o -r --filesync %i") - ("\\.pax\\'" . "pax -wf %o %i")) - dired-compress-file-suffixes '(("\\.tar\\.gz\\'" #1="" "gzip -dc %i | tar -xf -") - ("\\.tar\\.xz\\'" #1# "xz -dc %i | tar -xf -") - ("\\.tgz\\'" #1# "gzip -dc %i | tar -xf -") - ("\\.gz\\'" #1# "gzip -d") - ("\\.lz\\'" #1# "lzip -d") - ("\\.Z\\'" #1# "uncompress") - ("\\.z\\'" #1# "gzip -d") - ("\\.dz\\'" #1# "dictunzip") - ("\\.tbz\\'" ".tar" "bunzip2") - ("\\.bz2\\'" #1# "bunzip2") - ("\\.xz\\'" #1# "unxz") - ("\\.zip\\'" #1# "7z x -aoa -o%o %i") - ("\\.tar\\.zst\\'" #1# "unzstd -c %i | tar -xf -") - ("\\.tzst\\'" #1# "unzstd -c %i | tar -xf -") - ("\\.zst\\'" #1# "unzstd --rm") - ("\\.7z\\'" #1# "7z x -aoa -o%o %i") - ("\\.tar\\'" ".tgz" nil))) + dired-ls-F-marks-symlinks t) (add-hook 'dired-mode-hook (lambda () @@ -68,8 +43,7 @@ (straight-use-package 'dired-launch) (setq dired-launch-command '("xdg-open")) (setf dired-launch-extensions-map - '(;; xml files with bpmn in it - ("xopp" ("xournalpp")) + '(("xopp" ("xournalpp")) ("drawio.html" ("drawio")) ("drawio" ("drawio")))) @@ -80,4 +54,4 @@ :keymaps 'dired-mode-map "W" 'dired-launch-command))) -(provide 'a-dired) \ No newline at end of file +(provide 'a-dired) diff --git a/cnf/app/a-orgmode.el b/cnf/app/a-orgmode.el index 1cab134..80eda60 100644 --- a/cnf/app/a-orgmode.el +++ b/cnf/app/a-orgmode.el @@ -2,6 +2,9 @@ ;; NOTE: org-mode is required in essentials.el so we use the git instead of the shipped version ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; FIXME: A recent org version introduced this feature which currently breaks stuff +(setq org-element-cache-persistent nil) + ;; HTMLIZE: html export for orgmode (straight-use-package 'htmlize) @@ -87,7 +90,7 @@ modified here." org-export-in-background nil org-html-htmlize-output-type 'inline-css - ;; REQUIRES: y -S plantuml graphviz + ;; REQUIRES: plantuml graphviz ;; org-plantuml-jar-path (expand-file-name "/usr/share/java/plantuml/plantuml.jar") ;; Visuals like nice looking headings, fontification (bold, italic, etc.) @@ -234,11 +237,11 @@ modified here." ;; ORG-DOWNLOAD ;; TODO: Setup for seemless insertion of screenshots -(setq org-download-screenshot-file "~/sync/screenshots/tmp/orgcapture.png" - org-download-screenshot-method "grim -g $(slurp -b '#000000a0' -c '#00000000') -o %s" - org-download-image-attr-list '("#+ATTR_ORG: :width 600") - org-download-annotate-function (lambda(link) "")) -(setq-default org-download-image-dir "./ORGPICS") +;; (setq org-download-screenshot-file "~/sync/screenshots/tmp/orgcapture.png" +;; org-download-screenshot-method "grim -g $(slurp -b '#000000a0' -c '#00000000') -o %s" +;; org-download-image-attr-list '("#+ATTR_ORG: :width 600") +;; org-download-annotate-function (lambda(link) "")) +;; (setq-default org-download-image-dir "./ORGPICS") ;; KEYBINDINGS (my-leader diff --git a/cnf/global-keybindings.el b/cnf/global-keybindings.el index 25a7235..8cb848c 100644 --- a/cnf/global-keybindings.el +++ b/cnf/global-keybindings.el @@ -14,83 +14,87 @@ ;; "" 'evil-scroll-down ;; "" 'evil-scroll-up ) - ;; This is a reference to the leader key defined in essentials.el ;; It basically means: + whatever is configured below ;; E.g. "SPC SPC" actually means "SPC SPC SPC" because it is prefix with `my-leader' (my-leader - ;; These are the states for which the keybinding should work - :states '(normal visual emacs) - ;; This is the keymap for which the keybinding should work. - ;; Override is the GLOBAL keymap but there are specific ones for each mode - :keymaps 'override + ;; These are the states for which the keybinding should work + :states '(normal visual emacs) + ;; This is the keymap for which the keybinding should work. + ;; Override is the GLOBAL keymap but there are specific ones for each mode + :keymaps 'override - ;; This ignores the sole keybinding of "SPC SPC" to use this "namespace" for mode specific bindings - "SPC" '(:ignore t :which-key "Mode Specific Binds") - "SPC SPC" 'counsel-M-x + ;; This ignores the sole keybinding of "SPC SPC" to use this "namespace" for mode specific bindings + "SPC" '(:ignore t :which-key "Mode Specific Binds") + "SPC SPC" 'counsel-M-x - "f" 'counsel-find-file - "g" 'magit-status - "h" 'evil-avy-goto-line - "i" 'counsel-imenu - "y" 'counsel-yank-pop - ";" 'evilnc-comment-or-uncomment-lines - "." 'save-buffer + "u" '(lambda () + (interactive) + (let ((current-prefix-arg 1)) + (call-interactively #'eval-last-sexp))) - ;; window stuff - "w" '(:ignore t :which-key "Window") - ;; quick switch to other window - "a" 'ace-window - "w v" 'split-window-right - "w h" 'split-window-below - "w f" 'toggle-maximize-buffer - "w L" 'windsize-right - "w H" 'windsize-left - "w J" 'windsize-down - "w K" 'windsize-up + "f" 'counsel-find-file + "g" 'magit-status + "h" 'evil-avy-goto-line + "i" 'counsel-imenu + "y" 'counsel-yank-pop + ";" 'evilnc-comment-or-uncomment-lines + "." 'save-buffer - ;; switch stuff - "s" '(:ignore t :which-key "Switch") - "s b" 'switch-to-buffer - "s n" 'switch-to-next-buffer - "s p" 'switch-to-prev-buffer - "s s" 'counsel-switch-buffer - "s a" 'ace-swap-window - ;; kill stuff - "k" '(:ignore t :which-key "Kill") - "k b" 'kill-buffer - "k w" 'delete-window - "k W" 'kill-buffer-and-window - "k o b" 'kill-some-buffers - "k o w" 'delete-other-windows - "k q q" 'kill-emacs - "k k" 'kill-current-buffer + ;; window stuff + "w" '(:ignore t :which-key "Window") + ;; quick switch to other window + "a" 'ace-window + "w v" 'split-window-right + "w h" 'split-window-below + "w f" 'toggle-maximize-buffer + "w L" 'windsize-right + "w H" 'windsize-left + "w J" 'windsize-down + "w K" 'windsize-up - ;; buffer stuff - "b" '(:ignore t :which-key "Buffer (revert)") - "b r" 'revert-buffer - "b a r" 'auto-revert-mode + ;; switch stuff + "s" '(:ignore t :which-key "Switch") + "s b" 'switch-to-buffer + "s n" 'switch-to-next-buffer + "s p" 'switch-to-prev-buffer + "s s" 'counsel-switch-buffer + "s a" 'ace-swap-window + ;; kill stuff + "k" '(:ignore t :which-key "Kill") + "k b" 'kill-buffer + "k w" 'delete-window + "k W" 'kill-buffer-and-window + "k o b" 'kill-some-buffers + "k o w" 'delete-other-windows + "k q q" 'kill-emacs + "k k" 'kill-current-buffer - ;; edit stuff - "e" '(:ignore t :which-key "Edit") - "e c" '((lambda() (interactive) (dired my/emacsconf)) :which-key "edit emacs config") + ;; buffer stuff + "b" '(:ignore t :which-key "Buffer (revert)") + "b r" 'revert-buffer + "b a r" 'auto-revert-mode - ;; ui stuff - "q" '(:ignore t :which-key "Quality :)") - "q t" 'phga/cycle-themes - "q =" 'phga/text-scale-adjust + ;; edit stuff + "e" '(:ignore t :which-key "Edit") + "e c" '((lambda() (interactive) (dired (concat user-emacs-directory))) :which-key "edit emacs config") - ;; tools - "t u" 'vundo + ;; ui stuff + "q" '(:ignore t :which-key "Quality :)") + "q t" 'phga/cycle-themes + "q =" 'phga/text-scale-adjust - ;; describe stuff - "?" '(:ignore t :which-key "Describe") - "? v" 'describe-variable - "? f" 'describe-function - "? c" 'describe-char - "? m" 'describe-mode - "? k" 'describe-key - "? F" 'describe-face -) + ;; tools + "t u" 'vundo -(provide 'global-keybindings) \ No newline at end of file + ;; describe stuff + "?" '(:ignore t :which-key "Describe") + "? v" 'describe-variable + "? f" 'describe-function + "? c" 'describe-char + "? m" 'describe-mode + "? k" 'describe-key + "? F" 'describe-face + ) + +(provide 'global-keybindings) diff --git a/early-init.el b/early-init.el index 91e0bbd..3a05a4a 100644 --- a/early-init.el +++ b/early-init.el @@ -6,8 +6,7 @@ ;; Defer garbage collection further back in the startup process (setq gc-cons-threshold most-positive-fixnum) ;; In Emacs 27+, package initialization occurs before `user-init-file' is -;; loaded, but after `early-init-file'. Doom handles package initialization, so -;; we must prevent Emacs from doing it early! +;; loaded, but after `early-init-file'. We use `straight' as our package manager (setq package-enable-at-startup nil) (advice-add #'package--ensure-init-file :override #'ignore) diff --git a/init.el b/init.el index efc8dc4..6818c1a 100644 --- a/init.el +++ b/init.el @@ -26,6 +26,7 @@ (require 'additionals) (require 'global-keybindings) (require 'functions) +(require 'programming) ;; set gc values back to smth reasonable (setq gc-cons-threshold 104857600) ;; 100 MegaByte (LSP) diff --git a/snippets/org-mode/clocktable b/snippets/org-mode/clocktable deleted file mode 100644 index 4956f01..0000000 --- a/snippets/org-mode/clocktable +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# name: clocktable -# key: