434 lines
16 KiB
EmacsLisp
434 lines
16 KiB
EmacsLisp
;; PACKAGE
|
|
(require 'package)
|
|
|
|
(defun get-auth-key (host)
|
|
"Retrieve the Anthropics API key using 'auth-source'."
|
|
(require 'auth-source)
|
|
(let* ((auth-source-creation-prompts
|
|
'((secret . "API key for %u@%h: ")))
|
|
(found (nth 0 (auth-source-search
|
|
:max 1
|
|
:host host
|
|
:user "apikey"
|
|
:require '(:secret)
|
|
:create t)))
|
|
(secret (plist-get found :secret)))
|
|
(if (functionp secret)
|
|
(funcall secret)
|
|
secret)))
|
|
|
|
(use-package htmlize)
|
|
|
|
(use-package autoinsert
|
|
:ensure nil
|
|
:init (auto-insert-mode 1)
|
|
:config
|
|
(setq auto-insert-query nil)
|
|
(setq auto-insert-alist
|
|
(append '((("\\.lisp\\'" . "Lisp header")
|
|
nil
|
|
";;;; -*- mode: common-lisp; coding: utf-8; -*-\n"))
|
|
auto-insert-alist)))
|
|
|
|
(use-package tramp
|
|
:ensure nil
|
|
:config
|
|
(when (eq system-type 'windows-nt)
|
|
(setq tramp-default-method "sshx")))
|
|
|
|
(use-package shr
|
|
:custom
|
|
(shr-use-colors nil)
|
|
(shr-use-fonts nil)
|
|
(shr-inhibit-images t)
|
|
(shr-cookie-policy nil)
|
|
(shr-width nil))
|
|
|
|
(use-package shrface
|
|
:hook ((eww-after-render . shrface-mode)
|
|
(nov-mode . shrface-mode))
|
|
:custom
|
|
(shrface-href-versatile t)
|
|
(shrface-toggle-bullets t)
|
|
:config
|
|
(shrface-basic)
|
|
(shrface-trial)
|
|
(shrface-default-keybindings))
|
|
|
|
(use-package flyspell
|
|
:hook ((LaTeX-mode . flyspell-mode)
|
|
(org-mode . flyspell-mode)
|
|
(text-mode . flyspell-mode)
|
|
(prog-mode . flyspell-prog-mode)))
|
|
|
|
(defun mk/nov-font-settings ()
|
|
(setq-local line-spacing 2))
|
|
|
|
(use-package browse-url
|
|
:custom
|
|
(browse-url-browser-function 'eww-browse-url))
|
|
|
|
(use-package eww
|
|
:config
|
|
(require 'shrface))
|
|
|
|
(use-package nov
|
|
:hook ((nov-mode . visual-line-mode)
|
|
(nov-mode . mk/nov-font-settings))
|
|
:mode ("\\.epub\\'" . nov-mode)
|
|
:custom
|
|
(nov-header-line-format nil)
|
|
(nov-text-width 82)
|
|
(nov-variable-pitch nil)
|
|
:config
|
|
(require 'shrface)
|
|
(setq nov-shr-rendering-functions '((img . nov-render-img) (title . nov-render-title)))
|
|
(setq nov-shr-rendering-functions (append nov-shr-rendering-functions shr-external-rendering-functions)))
|
|
;; (when (eq system-type 'windows-nt)
|
|
;; (setq nov-unzip-program "c:/msys64/usr/bin/unzip.exe")))
|
|
|
|
(use-package eglot
|
|
:hook ((typescript-mode . eglot-ensure)
|
|
(js2-mode . eglot-ensure))
|
|
:config
|
|
(if (eq system-name 'windows-nt)
|
|
;; %USERPROFILE%\AppData\Local\Programs\clangd-windows-17.0.3\clangd_17.0.3\bin
|
|
(add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd"))
|
|
(add-to-list 'eglot-server-programs '((c++-mode c-mode) "ccls"))))
|
|
|
|
(use-package sql
|
|
:config
|
|
(setq sql-connection-alist
|
|
'((finance-db
|
|
(sql-product 'sqlite)
|
|
(sql-database "~/Documents/org/data/FINANCE.db"))))
|
|
(when (eq system-type 'windows-nt)
|
|
(setq sql-postgres-program "C:/Program Files/PostgreSQL/16/bin/psql.exe")
|
|
(setq sql-sqlite-options '("-interactive"))
|
|
(setq sql-mariadb-options '("-C" "-t" "-f" "-n"))
|
|
(setq sql-mysql-options '("-C" "-t" "-f" "-n"))))
|
|
|
|
;; (defun me/c-mode-style-hook ()
|
|
;; ;; https://www.gnu.org/prep/standards/html_node/Writing-C.html
|
|
;; ;; if linux kernel source use linux style, else use gnu style
|
|
;; (c-set-style
|
|
;; (if (and (buffer-file-name)
|
|
;; (string-match "/usr/src/linux" (buffer-file-name)))
|
|
;; "linux"
|
|
;; "gnu")))
|
|
|
|
;; (use-package cc-mode
|
|
;; :defer t
|
|
;; :ensure nil
|
|
;; :hook ((c-mode-common . c-toggle-auto-newline)
|
|
;; (c-mode-common . me/c-mode-style-hook))
|
|
;; :custom
|
|
;; (fill-column 79)
|
|
;; (c-basic-offset 2)
|
|
;; (indent-tabs-mode nil)
|
|
;; :config
|
|
;; (define-key c-mode-base-map (kbd "RET") 'newline-and-indent))
|
|
|
|
;; (defun me/c-mode-compile-command-hook ()
|
|
;; ;; if no makefile use gcc for compile command
|
|
;; (unless (or (file-exists-p "makefile")
|
|
;; (file-exists-p "Makefile"))
|
|
;; (set (make-local-variable 'compile-command)
|
|
;; (concat "gcc " "-Wall " "-g " buffer-file-name " -o "
|
|
;; (file-name-sans-extension buffer-file-name)))))
|
|
|
|
;; (add-hook 'c-mode-common-hook 'me/c-mode-compile-command-hook)
|
|
|
|
;; (defun me/c-mode-compile-on-save ()
|
|
;; ;; compile on save hook
|
|
;; (make-local-variable 'after-save-hook)
|
|
;; (add-hook 'after-save-hook (lambda () (compile compile-command))))
|
|
|
|
;; (add-hook 'c-mode-common-hook 'me/c-mode-compile-on-save)
|
|
|
|
;; (use-package js-mode
|
|
;; :ensure nil
|
|
;; :hook (js-mode . eglot-ensure)
|
|
;; :mode (("\\.webmanifest\\'" . js-mode)
|
|
;; ("\\.js\\'" . js-mode)
|
|
;; ("\\.mjs\\'" . js-mode)
|
|
;; ("\\.cjs\\'" . js-mode)))
|
|
|
|
(use-package js2-mode
|
|
:mode
|
|
(("\\.webmanifest\\'" . js2-mode)
|
|
("\\.js\\'" . js2-mode)
|
|
("\\.mjs\\'" . js2-mode)
|
|
("\\.cjs\\'" . js2-mode))
|
|
:config
|
|
(add-to-list 'interpreter-mode-alist '("node" . js2-mode)))
|
|
|
|
;; (use-package go-mode
|
|
;; :defer t
|
|
;; :mode ("\\.go\\'" . go-mode)
|
|
;; :hook ((before-save . gofmt-before-save)
|
|
;; (go-mode . eglot-ensure))
|
|
;; :config
|
|
;; (defun me/go-mode-compile-command-hook ()
|
|
;; ;; if no makefile use go vet for compile command
|
|
;; (unless (or (file-exists-p "makefile")
|
|
;; (file-exists-p "Makefile"))
|
|
;; (set (make-local-variable 'compile-command)
|
|
;; (concat "go " "vet " buffer-file-name))))
|
|
;; (add-hook 'go-mode-hook 'me/go-mode-compile-command-hook)
|
|
;; (defun me/go-mode-compile-on-save ()
|
|
;; ;; compile on save hook
|
|
;; (make-local-variable 'after-save-hook)
|
|
;; (add-hook 'after-save-hook (lambda () (compile compile-command)))))
|
|
;; ;; (add-hook 'go-mode-hook 'me/go-mode-compile-on-save)))
|
|
|
|
(use-package web-mode
|
|
;; :hook html-mode
|
|
:mode (("\\.html?\\'" . web-mode)
|
|
("\\.xhtml?\\'" . web-mode)
|
|
("\\.tmpl\\'" . web-mode)
|
|
("\\.hbs\\'" . web-mode)
|
|
("\\.handlebars\\'" . web-mode))
|
|
:custom
|
|
(web-mode-markup-indent-offset 2)
|
|
(web-mode-css-indent-offset 2)
|
|
(web-mode-code-indent-offset 2)
|
|
(web-mode-enable-auto-pairing nil)
|
|
(web-mode-enable-auto-closing t)
|
|
(web-mode-enable-current-element-highlight t)
|
|
(web-mode-enable-current-column-highlight t))
|
|
|
|
(use-package python
|
|
:mode (("\\.py\\'" . python-mode)
|
|
("\\.wsgi$" . python-mode)
|
|
("\\.j2" . python-mode))
|
|
:hook (python-mode . abbrev-mode)
|
|
:init
|
|
(setq python-indent-guess-indent-offset nil)
|
|
(setq python-indent-offset 4)
|
|
(setq python-shell-interpreter "ipython")
|
|
(setq python-shell-interpreter-args "-i --simple-prompt --InteractiveShell.display_page=True")
|
|
:custom
|
|
(fill-column 79))
|
|
|
|
;; (use-package simple-httpd
|
|
;; :defer t)
|
|
|
|
(use-package go-translate
|
|
:bind (("C-c t" . gt-do-translate))
|
|
:config
|
|
(setq gt-langs '(en de))
|
|
(setq gt-default-translator
|
|
(gt-translator
|
|
:taker (gt-taker :text 'word)
|
|
:engines (gt-google-engine)
|
|
:render (gt-buffer-render))))
|
|
|
|
(use-package magit
|
|
:bind ("C-x g" . magit-status)
|
|
:init
|
|
(when (eq system-type 'windows-nt)
|
|
(setq magit-git-executable "C:/Program Files/Git/mingw64/libexec/git-core/git.exe"))
|
|
:custom
|
|
(magit-diff-refine-hunk 'all)
|
|
(magit-display-buffer-function 'magit-display-buffer-fullcolumn-most-v1)
|
|
(magit-ediff-dwim-show-on-hunks t)
|
|
(magit-log-arguments '("--graph" "--color" "--decorate" "--show-signature" "--follow" "-n256"))
|
|
(magit-log-margin-show-committer-date t)
|
|
(magit-log-remove-graph-args '("--follow" "--grep" "-G" "-S" "-L"))
|
|
(magit-todos-insert-after '(bottom))
|
|
:config
|
|
(global-set-key (kbd "C-x M-g") 'magit-dispatch))
|
|
|
|
(use-package yaml-mode
|
|
:mode "\\.yml\\'"
|
|
:hook
|
|
(yaml-mode . (lambda () (auto-fill-mode -1))))
|
|
|
|
(use-package csv-mode
|
|
:mode "\\.csv\\'")
|
|
|
|
(use-package markdown-mode
|
|
:mode "\\.md\\'")
|
|
|
|
;; (use-package typescript-mode
|
|
;; :defer t
|
|
;; :mode "\\.ts\\'"
|
|
;; :hook (typescript-mode . eglot-ensure)
|
|
;; :config (setq typescript-indent-level 2))
|
|
|
|
(when (eq system-type 'gnu/linux)
|
|
(use-package spotify :bind ("S-<pause>" . spotify-playpause))
|
|
;; (use-package clojure-mode)
|
|
;; (use-package cider)
|
|
)
|
|
|
|
(use-package mastodon
|
|
:defer t
|
|
:custom
|
|
(mastodon-instance-url "https://emacs.ch")
|
|
(mastodon-active-user "qhBidG3d"))
|
|
|
|
(use-package jabber
|
|
:defer t
|
|
:custom
|
|
(jabber-activity-mode nil)
|
|
(jabber-account-list
|
|
'(("marcus.kammer@mailbox.org")))
|
|
(jabber-muc-autojoin
|
|
'("lisp@conference.a3.pm"
|
|
"emacs@conference.conversations.im"
|
|
"community@conference.jabber.fsfe.org"
|
|
"ml-survey@conference.mailbox.org"))
|
|
(jabber-muc-default-nicknames
|
|
'(("lisp@conference.a3.pm" . "marcus")
|
|
("community@conference.jabber.fsfe.org". "marcus")
|
|
("emacs@conference.conversations.im" . "marcus")
|
|
("ml-survey@conference.mailbox.org" . "marcus"))))
|
|
|
|
;; (use-package hyperbole
|
|
;; :config
|
|
;; (setq hyrolo-date-format "%Y-%m-%d %H:%M:%S")
|
|
;; (add-hook 'hyperbole-init-hook
|
|
;; (lambda ()
|
|
;; (setq hyrolo-file-list
|
|
;; (append (hyrolo-initialize-file-list)
|
|
;; (cons "~/.rolo.otl"
|
|
;; (directory-files-recursively org-directory (rx "." (or "org" "otl") eos))))))))
|
|
|
|
(use-package ispell
|
|
:ensure nil
|
|
:config
|
|
;; On windows: Copy *.aff and *.dic files to C:\msys64\ucrt64\share\hunspell
|
|
;; `hunspell -D`, the program will display the dictionaries and affix files it
|
|
;; finds and loads.
|
|
;; (when (eq system-type 'windows-nt)
|
|
;; (setq ispell-program-name "c:/msys64/ucrt64/bin/hunspell.exe"))
|
|
(setq ispell-dictionary "german,english")
|
|
(setq ispell-local-dictionary-alist
|
|
'(("german" "[[:alpha:]]" "[^[:alpha:]]" "[']" t ("-d" "de_DE_frami,de_AT_frami,de_CH_frami") nil utf-8)
|
|
("english" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US,en_GB") nil utf-8)
|
|
("german,english" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "de_DE_frami,en_US") nil utf-8)))
|
|
(setq ispell-hunspell-dictionary-alist ispell-local-dictionary-alist))
|
|
|
|
(use-package plantuml-mode
|
|
:mode ("\\.puml\\'" "\\.plantuml\\'")
|
|
:custom
|
|
(plantuml-default-exec-mode 'jar)
|
|
(plantuml-jar-path "~/plantuml.jar")
|
|
(org-plantuml-jar-path "~/plantuml.jar")
|
|
(plantuml-java-args '("-DPLANTUML_DPI=300" "-Djava.awt.headless=true" "-jar" "--illegal-access=deny")))
|
|
|
|
(use-package tex-mode
|
|
:defer t
|
|
:ensure auctex
|
|
:config
|
|
;; TeX mode settings for editing .tex files
|
|
(setq TeX-auto-save t) ; Enable auto-save
|
|
(setq TeX-electric-math (cons "$" "$")) ; Shortcut for math mode
|
|
(if (eq system-type 'windows-nt)
|
|
(progn
|
|
(setq TeX-view-program-list '(("SumatraPDF" "~/AppData/Local/SumatraPDF/SumatraPDF.exe %o")))
|
|
(setq TeX-view-program-selection '((output-pdf "SumatraPDF"))))
|
|
(setq TeX-view-program-selection '((output-pdf "Evince"))))
|
|
(setq TeX-source-correlate-start-server t) ; Enable source-correlate
|
|
(setq TeX-master nil) ; Default master file
|
|
(setq TeX-engine 'luatex) ; Set engine to XeTeX
|
|
(setq TeX-command-extra-options "-shell-escape")) ; Allow shell escape
|
|
|
|
(use-package auctex
|
|
:hook ((LaTeX-mode . turn-on-reftex)
|
|
(LaTeX-mode . LaTeX-math-mode))
|
|
:custom
|
|
(LaTeX-indent-level 4)
|
|
(LaTeX-item-indent 0))
|
|
|
|
(use-package epg
|
|
:ensure nil
|
|
:config
|
|
(when (eq system-type 'windows-nt)
|
|
(setq epg-gpg-home-directory "~/AppData/Roaming/gnupg"
|
|
epg-gpg-program "c:/Program Files (x86)/GnuPG/bin/gpg.exe"
|
|
epg-gpgconf-program "c:/Program Files (x86)/GnuPG/bin/gpgconf.exe")))
|
|
|
|
(use-package which-key
|
|
:init (which-key-mode))
|
|
|
|
(use-package ssh-config-mode
|
|
:mode ("/sshd_config\\'" . ssh-config-mode)
|
|
:config
|
|
(add-hook 'ssh-config-mode-hook 'turn-on-font-lock))
|
|
|
|
(use-package nginx-mode
|
|
:mode ("/nginx/.*\\'" . nginx-mode))
|
|
|
|
(use-package dashboard
|
|
:config
|
|
(dashboard-setup-startup-hook))
|
|
|
|
;; (use-package flymake-json)
|
|
|
|
;; (use-package json-mode
|
|
;; :ensure nil
|
|
;; :mode "\\.json\\'"
|
|
;; :hook (json-mode . flymake-json-load))
|
|
|
|
;; (use-package json-navigator
|
|
;; :defer t
|
|
;; :after json-mode)
|
|
|
|
;; (use-package jq-format
|
|
;; :defer t
|
|
;; :after json-mode)
|
|
|
|
(use-package gptel
|
|
:bind (("C-c g" . gptel-menu)
|
|
("C-c G" . gptel)
|
|
("C-c M-g" . gptel-send)
|
|
:map gptel-mode-map
|
|
("C-c C-c" . gptel-send)
|
|
("C-c C-k" . gptel-abort))
|
|
:config
|
|
(when (eq system-type 'windows-nt)
|
|
(setq gptel-use-curl t))
|
|
(setq gptel-default-mode 'org-mode)
|
|
(setq gptel-backend
|
|
(gptel-make-anthropic "Claude"
|
|
:stream t
|
|
:key gptel-api-key))
|
|
(setq gptel-prompt
|
|
"You are an expert Common Lisp developer specializing in web development with Hunchentoot and functional programming. Provide guidance on:
|
|
1. Setting up Hunchentoot servers and defining routes
|
|
2. Handling requests and serving static files
|
|
3. Generating dynamic HTML content
|
|
4. Implementing session management
|
|
5. Error handling and debugging
|
|
6. Database integration (CRUD operations)
|
|
7. Security best practices
|
|
8. Deployment processes
|
|
|
|
Emphasize functional programming principles throughout, including pure functions, immutability, and higher-order functions. Provide concise code examples and best practices for each topic.")
|
|
(setq gptel-directives
|
|
'((default . "You are an experienced Common Lisp developer specializing in web development using the Hunchentoot library, with a strong emphasis on functional programming principles. I need your support in building and maintaining web applications. Please provide detailed guidance, examples, and best practices for the following tasks: Explain how to install and configure Hunchentoot in a Common Lisp environment. Provide a sample code snippet to set up a basic Hunchentoot web server. Highlight any functional programming techniques used in the setup. Demonstrate how to define routes in Hunchentoot. Show examples of handling GET and POST requests using functional programming principles, such as pure functions and immutability. Explain how to manage query parameters and request bodies in a functional style. Illustrate how to serve static files (HTML, CSS, JS, images) using Hunchentoot. Provide tips for organizing static files within a project. Discuss how to use functional programming to manage static file serving efficiently. Explain how to generate and return HTML content from handlers. Include examples using Common Lisp templating libraries or techniques to render dynamic content. Emphasize the use of functional programming concepts in rendering and templating. Describe how to implement session management in a Hunchentoot application. Provide code examples for setting, retrieving, and destroying session data using functional approaches. Discuss the benefits of immutability and pure functions in managing sessions. Show how to implement error handling and custom error pages in Hunchentoot. Include examples of logging errors and debugging tips. Explain how functional programming can improve error handling and logging. Explain how to connect a Hunchentoot application to a database (e.g., PostgreSQL, SQLite). Provide a sample CRUD (Create, Read, Update, Delete) application demonstrating database interaction. Highlight functional programming techniques in database operations, such as using higher-order functions and maintaining immutability. Offer advice on securing a Hunchentoot application (e.g., input validation, CSRF protection, HTTPS setup). Include examples and code snippets where applicable. Discuss how functional programming principles can enhance application security. Discuss the deployment process for Hunchentoot applications. Recommend hosting options and provide a basic deployment guide. Emphasize functional programming practices in the deployment process to ensure reliability and maintainability. Feel free to ask for clarification or additional details on any of these topics. Let's get started!.")
|
|
(bash . "You are an experienced Bash scripting teacher. I want to learn how to write Bash scripts. Please explain concepts clearly, provide examples, and guide me through writing scripts step-by-step. Let's start with the basics and gradually move to more advanced topics. If I have questions or need further clarification, help me understand the material thoroughly."))))
|
|
|
|
(use-package gnuplot
|
|
:defer t)
|
|
|
|
(use-package docker)
|
|
|
|
(use-package dockerfile-mode
|
|
:mode ("\\.dockerfile\\'" . dockerfile-mode))
|
|
|
|
(use-package terraform-mode
|
|
:defer t
|
|
:custom
|
|
(terraform-format-on-save t))
|
|
|
|
(use-package auto-complete
|
|
:init
|
|
(ac-config-default)
|
|
:config
|
|
(setq ac-use-menu-map t)
|
|
(setq ac-ignore-case nil)
|
|
(add-hook 'prog-mode-hook 'auto-complete-mode))
|