Remove unused functions and change 2 shortcuts.

- Modify comment/uncomment region to comment current line and change
to shortcut to C-S-c.
- Change duplicate line shortcut to C-S-d.
This commit is contained in:
kj 2022-06-27 23:52:52 -04:00
parent ee4c9c351f
commit 5fa858af78
2 changed files with 31 additions and 33 deletions

View File

@ -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 (<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))
;; 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)

View File

@ -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-<f11>") '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 <down>") '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