changes to emacs config

This commit is contained in:
gbcastro 2026-08-12 11:26:51 +01:00
parent 535b890d14
commit fb075b10a3
4 changed files with 85 additions and 13 deletions

View file

@ -1 +0,0 @@
gabi@gentoo.1525130935602846936

View file

@ -4,7 +4,7 @@ Configuração do Garbage Collector para acelerar o arranque.
(setq gc-cons-threshold (* 50 1024 1024)) (setq gc-cons-threshold (* 50 1024 1024))
(add-hook 'emacs-startup-hook (add-hook 'emacs-startup-hook
(lambda () (lambda ()
(setq gc-cons-threshold (* 2 1024 1024)))) (setq gc-cons-threshold (* 50 1024 1024))))
#+end_src #+end_src
* LIMPEZA VISUAL * LIMPEZA VISUAL
@ -18,13 +18,17 @@ Remover barras desnecessárias e ecrã de boas-vindas.
* DEFAULTS & COMPORTAMENTO BASE * DEFAULTS & COMPORTAMENTO BASE
#+begin_src elisp #+begin_src elisp
(setq make-backup-files nil) (setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
(setq auto-save-default nil) (setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))
(setq create-lockfiles nil)
(setq-default fill-column 80) (setq-default fill-column 80)
;; Desativa completamente o som de erro (não faz som nem pisca)
(setq ring-bell-function 'ignore)
(electric-pair-mode 1) (electric-pair-mode 1)
#+end_src #+end_src
* NÚMEROS DE LINHA * NÚMEROS DE LINHA
Ativa os números de linha relativos para facilitar a navegação, exceto em modos de leitura. Ativa os números de linha relativos para facilitar a navegação, exceto em modos de leitura.
#+begin_src elisp #+begin_src elisp
@ -203,6 +207,8 @@ Configurações essenciais para escrita e blocos de código.
(org-src-preserve-indentation nil) (org-src-preserve-indentation nil)
(org-edit-src-content-indentation 0) (org-edit-src-content-indentation 0)
(org-src-tab-acts-natively t) (org-src-tab-acts-natively t)
(org-startup-with-inline-images t)
(org-image-actual-width nil)
:config :config
(org-babel-do-load-languages (org-babel-do-load-languages
'org-babel-load-languages 'org-babel-load-languages
@ -225,7 +231,7 @@ Configurações essenciais para escrita e blocos de código.
:config :config
(org-download-enable) (org-download-enable)
(setq-default org-download-image-dir "./images") (setq-default org-download-image-dir "./images")
(setq org-download-screenshot-method "wl-paste -t image/png > %s")) (setq org-download-clipboard-command "wl-paste -t image/png > %s"))
#+end_src #+end_src
* VERIFICAÇÃO DE SINTAXE (FLYCHECK) * VERIFICAÇÃO DE SINTAXE (FLYCHECK)
@ -247,13 +253,15 @@ Motor de parsing moderno. C e C++ mantidos propositadamente no modo clássico (r
;; 1. Dizer ao Emacs a localização exata das gramáticas testadas ;; 1. Dizer ao Emacs a localização exata das gramáticas testadas
(setq treesit-language-source-alist (setq treesit-language-source-alist
'((bash "https://github.com/tree-sitter/tree-sitter-bash") '((bash "https://github.com/tree-sitter/tree-sitter-bash")
(c "https://github.com/tree-sitter/tree-sitter-c")
(cpp "https://github.com/tree-sitter/tree-sitter-cpp")
(python "https://github.com/tree-sitter/tree-sitter-python") (python "https://github.com/tree-sitter/tree-sitter-python")
(json "https://github.com/tree-sitter/tree-sitter-json") (json "https://github.com/tree-sitter/tree-sitter-json")
(yaml "https://github.com/ikatyang/tree-sitter-yaml") (yaml "https://github.com/ikatyang/tree-sitter-yaml")
(dockerfile "https://github.com/camdencheek/tree-sitter-dockerfile"))) (dockerfile "https://github.com/camdencheek/tree-sitter-dockerfile")))
;; 2. Instalar automaticamente as gramáticas ;; 2. Instalar automaticamente as gramáticas
(dolist (lang '(bash python json yaml dockerfile)) (dolist (lang '(bash c cpp python json yaml dockerfile))
(unless (treesit-language-available-p lang) (unless (treesit-language-available-p lang)
(treesit-install-language-grammar lang))) (treesit-install-language-grammar lang)))
@ -262,11 +270,29 @@ Motor de parsing moderno. C e C++ mantidos propositadamente no modo clássico (r
:custom :custom
(treesit-auto-install nil) (treesit-auto-install nil)
:config :config
(setq treesit-auto-langs '(python bash json yaml dockerfile)) (setq treesit-auto-langs '(c cpp python bash json yaml dockerfile))
(treesit-auto-add-to-auto-mode-alist 'all) (treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode)) (global-treesit-auto-mode))
#+end_src #+end_src
* LANGUAGE SERVER PROTOCOL (EGLOT + CLANGD)
Obrigatório para desenvolvimento bare-metal em C.
#+begin_src elisp
(use-package eglot
:ensure nil ; Built-in
:hook ((c-mode c-ts-mode c++-mode c++-ts-mode) . eglot-ensure)
:config
;; Desativa logs pesados que atrasam o Emacs
(fset #'jsonrpc--log-event #'ignore)
;; Configura o clangd para projetos embebidos
(add-to-list 'eglot-server-programs
'((c-mode c-ts-mode c++-mode c++-ts-mode)
. ("clangd"
"--background-index"
"--header-insertion=never" ; Evita que injete #includes indesejados
"--completion-style=detailed"))))
#+end_src
* ZETTELKASTEN (ORG-ROAM) * ZETTELKASTEN (ORG-ROAM)
O núcleo do sistema de notas. O núcleo do sistema de notas.
#+begin_src elisp #+begin_src elisp
@ -410,17 +436,57 @@ Integração offline com o servidor local do llama.cpp via Vulkan.
#+end_src #+end_src
* PESQUISA INTELIGENTE (KHOJ) * PESQUISA INTELIGENTE (KHOJ)
Integração com o servidor Khoj rodando no Raspberry Pi 5 para busca semântica nas notas. Integração com o servidor Khoj para busca semântica nas notas.
#+begin_src elisp #+begin_src elisp
(use-package khoj (use-package khoj
:ensure t :ensure t
:bind ("C-c n s" . khoj) ; Atalho: "Notes Search" :bind ("C-c n s" . khoj) ; Atalho: "Notes Search"
:config :config
;; Aponta o Emacs para o servidor no seu RPi5 ;; Aponta o Emacs para o servidor
(setq khoj-server-url "http://192.168.1.201:5000") (setq khoj-server-url "http://127.0.0.1:5000")
;; Opcional: Define a pasta padrão caso use a interface local do pacote ;; Opcional: Define a pasta padrão caso use a interface local do pacote
(setq khoj-notes-directory "~/org/roam")) (setq khoj-index-directories '("~/org/roam/")))
#+end_src
* O MEU PRIMEIRO AGENTE (RAG)
Integração direta entre a pesquisa semântica (Khoj) e a geração de texto (Llama).
#+begin_src elisp
(defun gabi/agente-notas (pesquisa pergunta)
"Agente RAG de 2 Fases: Pesquisa Cirúrgica + Resposta Estrita."
(interactive
(list (read-string "1. Palavras-chave para o Khoj (ex: gentoo instalação): ")
(read-string "2. O que queres perguntar ao Llama sobre isto?: ")))
(require 'gptel)
(message "Fase 1: A extrair as notas sobre '%s' do Khoj..." pesquisa)
(let* ((url (format "http://127.0.0.1:5000/api/search?q=%s&n=5" (url-hexify-string pesquisa)))
(comando (format "curl -s '%s'" url))
(resultados-khoj (shell-command-to-string comando))
(buffer-resposta (get-buffer-create "*Síntese do Agente*"))
;; PROMPT DE FERRO: Proibido inventar.
(prompt-sistema (concat "És um assistente técnico de extração de informação. "
"Vais receber dados JSON retirados das notas do utilizador.\n\n"
"REGRAS ABSOLUTAS:\n"
"1. Baseia a resposta EXCLUSIVAMENTE nos dados abaixo.\n"
"2. NÃO inventes conhecimento externo. Se não está nos dados, não escrevas.\n"
"3. Ignora o código JSON e foca-te apenas no texto org-mode que está lá dentro.\n\n"
"DADOS EXTRAÍDOS:\n"
resultados-khoj)))
(pop-to-buffer buffer-resposta)
(erase-buffer)
(org-mode)
(insert (format "#+TITLE: %s\n" pergunta))
(insert (format "#+SUBTITLE: Baseado na pesquisa por: %s\n" pesquisa))
(insert (format "#+DATE: %s\n\n" (format-time-string "%Y-%m-%d")))
(message "Fase 2: A analisar notas e a gerar resposta...")
(gptel-request pergunta
:system prompt-sistema
:stream t)))
#+end_src #+end_src
@ -441,6 +507,7 @@ Integração com o servidor Khoj rodando no Raspberry Pi 5 para busca semântica
(message "A descarregar o artigo completo...") (message "A descarregar o artigo completo...")
(eww link)))) (eww link))))
:config :config
(setq elfeed-use-curl t)
;; Atualiza o Elfeed a cada 30 minutos em background ;; Atualiza o Elfeed a cada 30 minutos em background
(run-at-time nil (* 30 60) #'elfeed-update)) (run-at-time nil (* 30 60) #'elfeed-update))

View file

@ -35,7 +35,7 @@ client.urgent #f38ba8 #1e1e2e #f38ba8 #f38ba8 #f38ba8
### Output configuration ### Output configuration
# #
# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/) # Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
output * bg /home/gabi/Pictures/Wallpapers/space.jpg fill output * bg /home/gabi/Pictures/Wallpapers/cars.jpg fill
# #
# Example configuration: # Example configuration:
# #
@ -237,6 +237,7 @@ bindsym $mod+r mode "resize"
include /etc/sway/config.d/* include /etc/sway/config.d/*
for_window [app_id="wofi"] floating enable, border pixel 0, move position center for_window [app_id="wofi"] floating enable, border pixel 0, move position center
for_window [app_id="nmtui-wifi"] floating enable, resize set width 500 height 600, move position center
# --- AUTORUN --- # --- AUTORUN ---
exec --no-startup-id mako exec --no-startup-id mako
@ -246,3 +247,4 @@ exec --no-startup-id pipewire &
exec --no-startup-id wireplumber & exec --no-startup-id wireplumber &
exec --no-startup-id pipewire-pulse exec --no-startup-id pipewire-pulse
exec --no-startup-id mako exec --no-startup-id mako
exec nm-applet --indicator

View file

@ -4,7 +4,7 @@
"height": 30, "height": 30,
"modules-left": ["sway/workspaces", "sway/mode"], "modules-left": ["sway/workspaces", "sway/mode"],
"modules-center": [], "modules-center": [],
"modules-right": ["pulseaudio", "cpu", "memory", "battery", "clock"], "modules-right": ["tray", "pulseaudio", "cpu", "memory", "battery", "clock"],
"sway/workspaces": { "sway/workspaces": {
"disable-scroll": true, "disable-scroll": true,
@ -25,5 +25,9 @@
"pulseaudio": { "pulseaudio": {
"format": "{volume}% ", "format": "{volume}% ",
"format-muted": "" "format-muted": ""
},
"tray": {
"icon-size": 18,
"spacing": 10
} }
} }