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

51 lines
1.6 KiB
EmacsLisp

;;; base-functions.el --- Configuración de org-mode -*- lexical-binding: t -*-
;; Author: kj <webmaster@outcontrol.net>
;; URL: https://git.kj2.me/kj/confi-emacs-actual
;;; Commentary:
;;; Code:
;; Buscar el texto actualmente seleccionado
(defun kj-isearch-with-region ()
"Use region as the isearch text."
(when mark-active
(let ((region (funcall region-extract-function nil)))
(deactivate-mark)
(isearch-push-state)
(isearch-yank-string region))))
(add-hook 'isearch-mode-hook #'kj-isearch-with-region)
;; Borrar espacios, tabs y saltos de línea innecesarios al guardar
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Hacer emacs transparente (no funciona perfecto, pero sirve)
(defun toggle-transparency ()
"Cambia la transparencia de Emacs (es un poco useless)."
(interactive)
(let ((alpha (frame-parameter nil 'alpha)))
(set-frame-parameter
nil 'alpha
(if (eql (cond ((numberp alpha) alpha)
((numberp (cdr alpha)) (cdr alpha))
;; Also handle undocumented (<active> <inactive>) form.
((numberp (cadr alpha)) (cadr alpha)))
100)
'(60 . 60) '(100 . 100)))))
(defun transparency (value)
"Set the transparency VALUE of the frame window. 0=transparent/100=opaque."
(interactive "nTransparency Value 0 - 100 opaque:")
(set-frame-parameter (selected-frame) 'alpha value))
(defun icon-displayable-p ()
"Return non-nil if icons are displayable."
(and (display-graphic-p) (daemonp)
(or (featurep 'all-the-icons)
(require 'all-the-icons nil t))))
(provide 'base-functions)
;;; base-functions.el ends here.