confi-emacs-actual/configs/init-base.el

155 lines
6.4 KiB
EmacsLisp
Raw Normal View History

2022-11-19 04:33:22 +01:00
;;; init-base.el --- Configuración base de emacs -*- lexical-binding: t -*-
2022-03-30 01:21:13 +02:00
;; Author: kj <webmaster@outcontrol.net>
;; URL: https://git.kj2.me/kj/confi-emacs-actual
;;; Commentary:
2023-04-14 18:39:19 +02:00
;; Configuración general de Emacs.
;; No incluye paquetes/extensiones, solo configuraciones generales.
2022-03-30 01:21:13 +02:00
;;; Code:
;; Native compilation
(when (and (fboundp 'native-comp-available-p)
(native-comp-available-p))
(progn
(setq native-comp-async-report-warnings-errors nil)
(setq comp-deferred-compilation t)
(setq package-native-compile t)
))
2022-05-27 23:04:28 +02:00
;; Instalar straight.el (reemplpazando package.el)
(defvar elpaca-installer-version 0.5)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil
:files (:defaults (:exclude "extensions"))
:build (:not elpaca--activate-package)))
(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (< emacs-major-version 28) (require 'subr-x))
(condition-case-unless-debug err
(if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
((zerop (call-process "git" nil buffer t "clone"
(plist-get order :repo) repo)))
((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))
(emacs (concat invocation-directory invocation-name))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
"--eval" "(byte-recompile-directory \".\" 0 'force)")))
((require 'elpaca))
((elpaca-generate-autoloads "elpaca" repo)))
(progn (message "%s" (buffer-string)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(load "./elpaca-autoloads")))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))
2022-05-27 23:04:28 +02:00
2022-03-30 01:21:13 +02:00
;; Instalar use-package si no está instalado
(elpaca elpaca-use-package
;; Enable :elpaca use-package keyword.
(elpaca-use-package-mode)
;; Assume :elpaca t unless otherwise specified.
(setq elpaca-use-package-by-default t))
;; Block until current queue processed.
(elpaca-wait)
2022-03-30 01:21:13 +02:00
;; Theme
(use-package dracula-theme
2023-04-18 07:21:36 +02:00
:defer t
:init
(load-theme 'dracula t)
:config
(set-face-attribute 'default nil :font "Fira Code Retina" :height 112) ; Font
2023-04-18 07:21:36 +02:00
)
2022-03-30 01:21:13 +02:00
(defconst private-dir (expand-file-name "private" user-emacs-directory))
(defconst temp-dir (format "%s/cache" private-dir)
"Hostname-based elisp temp directories.")
;; UTF-8 please
(set-charset-priority 'unicode)
(setq locale-coding-system 'utf-8) ; pretty
(set-terminal-coding-system 'utf-8) ; pretty
(set-keyboard-coding-system 'utf-8) ; pretty
(set-selection-coding-system 'utf-8) ; please
(prefer-coding-system 'utf-8) ; with sugar on top
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
;; Emacs customizations
2023-04-18 21:49:07 +02:00
(scroll-bar-mode -1) ; Quitar scrollbar.
(tooltip-mode -1) ; Disable tooltips.
(global-display-line-numbers-mode) ; Mostar número de línea.
(show-paren-mode 1) ; Habilitar resaltado de brackets.
(pending-delete-mode t) ; Cuando selecciono un texto y escribo, el texto se borra (emacs por defecto solo escribe donde está el cursor).
;; (global-hl-line-mode) ; Resaltar línea actual por defecto.
2022-03-30 01:21:13 +02:00
(setq-default
cursor-type 'bar ; Usar la barrita como cursor
cursor-in-non-selected-windows nil ; Desaparecer el cursor en frames no activos.
indent-tabs-mode nil ; Cambiar tabs por espacios.
2022-04-07 05:29:52 +02:00
inhibit-startup-message t ; Eliminar el mensaje de inicio.
2022-03-30 01:21:13 +02:00
)
(setq
2023-04-18 21:49:07 +02:00
custom-file (concat private-dir "/.custom.el") ; Cabiar la ruta del código que se genera al isntalar un theme o package
2022-03-30 01:21:13 +02:00
ac-ignore-case nil ; Desactivar el autocapitalizado.
ac-disable-faces nil ; Auto-complete hablitado incluso entre comillas (fuente: https://bit.ly/3a9wCB4).
tags-revert-without-query 1 ; Recargar tags (ctags) sin pedir confirmación.
)
;; Leve transparencia en emacs por defecto.
2023-09-09 07:11:51 +02:00
;; (set-frame-parameter nil 'alpha-background 95)
2022-03-30 01:21:13 +02:00
;; Backups enabled, use nil to disable
(setq
history-length 1000
backup-inhibited nil
make-backup-files nil
auto-save-default nil
auto-save-list-file-name (concat temp-dir "/autosave")
create-lockfiles nil
backup-directory-alist `((".*" . ,(concat temp-dir "/backup/")))
auto-save-file-name-transforms `((".*" ,(concat temp-dir "/auto-save-list/") t)))
;; Configuración cuando es un server
(defun setup-daemon ()
"Carga la configuración del modo daemon."
2022-03-30 01:21:13 +02:00
(message "Corriendo en modo daemon.")
2022-04-13 06:41:13 +02:00
(set-face-attribute 'default nil :font "Fira Code Retina" :height 112)
2022-03-30 01:21:13 +02:00
;; Abrir primero el dashboard
2023-05-18 16:11:24 +02:00
(setq initial-buffer-choice (lambda ()
(get-buffer "*dashboard*")
(dashboard-refresh-buffer)))
2022-03-30 01:21:13 +02:00
;; Cerrar buffers al cerrar emacsclient
(add-hook 'delete-frame-functions
(lambda (frame)
(mapc 'kill-buffer (delq (get-buffer "*dashboard*") (buffer-list)))
))
)
2022-03-30 01:21:13 +02:00
(if (daemonp)
(add-hook 'after-make-frame-functions
(lambda (frame)
(with-selected-frame frame
(setup-daemon))))
(message "Corriendo en modo normal."))
(add-hook 'elpaca-after-init-hook (lambda () (load custom-file 'noerror)))
2022-03-30 01:21:13 +02:00
2022-11-19 04:33:22 +01:00
(provide 'init-base)
;;; init-base.el ends here