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: ;;; Code:
;; Buscar el texto actualmente seleccionado ;; Comentar línea o región
(defun kj-isearch-with-region () (defun comment-or-uncomment-region-or-line ()
"Use region as the isearch text." "Comments or uncomments the region or the current line if there's no active region."
(when mark-active (interactive)
(let ((region (funcall region-extract-function nil))) (let (beg end)
(deactivate-mark) (if (region-active-p)
(isearch-push-state) (setq beg (region-beginning) end (region-end))
(isearch-yank-string region)))) (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 ;; Borrar espacios, tabs y saltos de línea innecesarios al guardar
(add-hook 'before-save-hook 'delete-trailing-whitespace) (add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Hacer emacs transparente (no funciona perfecto, pero sirve) ;; Verifica si es está instalado alltheicons (útil para ver si se usa o no íconos)
(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 () (defun icon-displayable-p ()
"Return non-nil if icons are displayable." "Return non-nil if icons are displayable."
(and (display-graphic-p) (daemonp) (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-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-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-S-a") 'mark-whole-buffer) ; Seleccionar todo con CTRL+SHIFT+a.
(global-set-key (kbd "C-S-c")
(global-set-key (kbd "C-x c c") 'comment-or-uncomment-region-or-line) ; Comentar/descomentar línea o selección
'comment-or-uncomment-region) ; Comentar/descomentar en lote
(global-set-key (kbd "C-<f11>") 'toggle-frame-maximized) ; Maximizar / restaurar (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 ;; Cambios rápidos de major modes
(global-set-key (kbd "C-x m") nil) ; Unbind mail on C-x m (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) (global-set-key (kbd "C-x <down>") 'windmove-down)
;; Meta atajos (atajos de atajos) ;; 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) (provide 'base-keys)
;;; base-keys.el ends here ;;; base-keys.el ends here