diff --git a/configs/base-functions.el b/configs/base-functions.el index bd3fc07..db46d50 100644 --- a/configs/base-functions.el +++ b/configs/base-functions.el @@ -7,39 +7,38 @@ ;;; 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)))) +;; Comentar línea o región +(defun comment-or-uncomment-region-or-line () + "Comments or uncomments the region or the current line if there's no active region." + (interactive) + (let (beg end) + (if (region-active-p) + (setq beg (region-beginning) end (region-end)) + (setq beg (line-beginning-position) end (line-end-position))) + (comment-or-uncomment-region beg end) + ;;(next-line) ;; saltar a la siguiente línea + )) -(add-hook 'isearch-mode-hook #'kj-isearch-with-region) +;; Duplicar la línea actual +(defun duplicate-current-line (&optional n) + "duplicate current line, make more than 1 copy given a numeric argument" + (interactive "p") + (save-excursion + (let ((nb (or n 1)) + (current-line (thing-at-point 'line))) + ;; when on last line, insert a newline first + (when (or (= 1 (forward-line 1)) (eq (point) (point-max))) + (insert "\n")) + + ;; now insert as many time as requested + (while (> n 0) + (insert current-line) + (decf n))))) ;; 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 ( ) 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)) - +;; Verifica si es está instalado alltheicons (útil para ver si se usa o no íconos) (defun icon-displayable-p () "Return non-nil if icons are displayable." (and (display-graphic-p) (daemonp) diff --git a/configs/base-keys.el b/configs/base-keys.el index b44a3ff..c0db331 100644 --- a/configs/base-keys.el +++ b/configs/base-keys.el @@ -15,11 +15,10 @@ (global-set-key (kbd "C-z") 'undo) ; Unbind C-z y hacerlo funcionar para deshacer cambios (global-set-key (kbd "C-S-z") 'undo-redo) ; Rehacer cambios con C-S-z (global-set-key (kbd "C-S-a") 'mark-whole-buffer) ; Seleccionar todo con CTRL+SHIFT+a. - -(global-set-key (kbd "C-x c c") - 'comment-or-uncomment-region) ; Comentar/descomentar en lote - +(global-set-key (kbd "C-S-c") + 'comment-or-uncomment-region-or-line) ; Comentar/descomentar línea o selección (global-set-key (kbd "C-") 'toggle-frame-maximized) ; Maximizar / restaurar +(global-set-key (kbd "C-S-d") 'duplicate-current-line) ; Duplicar línea ;; Cambios rápidos de major modes (global-set-key (kbd "C-x m") nil) ; Unbind mail on C-x m @@ -35,7 +34,7 @@ (global-set-key (kbd "C-x ") 'windmove-down) ;; Meta atajos (atajos de atajos) -(global-set-key (kbd "C-c l d") "\C-a\C- \C-n\M-w\C-y") ; Duplicar línea +;;(global-set-key (kbd "C-c l d") "\C-a\C- \C-n\M-w\C-y") ; Duplicar línea (provide 'base-keys) ;;; base-keys.el ends here