Big re-write :)

I reordered the code in a more clean an organized way. Also this improves a lot
the emacs startup time again, bucause after some updates it becomes a bit slow
with the old configuration, so i did it again in a new way.
This commit is contained in:
kj
2025-07-20 13:18:05 -03:00
parent 6ca3a756ad
commit dabaf86f28
29 changed files with 1426 additions and 838 deletions

View File

@ -43,9 +43,6 @@
(insert current-line)
(decf n)))))
;; Borrar espacios, tabs y saltos de línea innecesarios al guardar
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Mostrar y ocultar el diff de la línea de git-gutter
(defun git-gutter:toggle-popup-hunk ()
"Toggle 'git-gutter' hunk window."
@ -58,15 +55,15 @@
(defun kj/project-name (&optional project)
"Return the name for PROJECT.
If PROJECT is not specified, assume current project root."
(when-let (root (or project (kj/project-root)))
(when-let* ((root (or project (kj/project-root)))) ;; <-- ¡Aquí está el cambio!
(file-name-nondirectory
(directory-file-name
(file-name-directory root)))))
(directory-file-name
(file-name-directory root)))))
;; Obtener la raíz del proyecto desde project.el
(defun kj/project-root ()
"Return the current project root."
(when-let (project (project-current))
(when-let* ((project (project-current)))
(project-root project)))
;; Cambia entre ocultar o no la barra de título cuando está maximizado
@ -89,5 +86,52 @@ If PROJECT is not specified, assume current project root."
"Run `after-load-theme-hook'."
(run-hooks 'after-load-theme-hook))
;; Devuelve si el archivo es muy grande o no\
(defun too-long-file-p ()
"Check whether the file is too long."
(or (> (buffer-size) 500000)
(and (fboundp 'buffer-line-statistics)
(> (car (buffer-line-statistics)) 10000))))
;; Renombrar el archivo actual
(defun rename-this-file (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "sNew name: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(unless filename
(error "Buffer '%s' is not visiting a file!" name))
(progn
(when (file-exists-p filename)
(rename-file filename new-name 1))
(set-visited-file-name new-name)
(rename-buffer new-name))))
;; Copiar el nombre del archivo actual
(defun copy-file-name ()
"Copy the current buffer file name to the clipboard."
(interactive)
(let ((filename (if (equal major-mode 'dired-mode)
default-directory
(buffer-file-name))))
(if filename
(progn
(kill-new filename)
(message "Copied '%s'" filename))
(warn "Current buffer is not attached to a file!"))))
;; Verifica si se puede levantar un childframe
(defun childframe-workable-p ()
"Whether childframe is workable."
(and (not noninteractive)
(not emacs-basic-display)
(or (display-graphic-p)
(featurep 'tty-child-frames))
(eq (frame-parameter (selected-frame) 'minibuffer) 't)))
(defun font-installed-p (font-name)
"Check if font with FONT-NAME is available."
(find-font (font-spec :name font-name)))
(provide 'init-functions)
;;; init-functions.el ends here.