kj
5fa858af78
- Modify comment/uncomment region to comment current line and change to shortcut to C-S-c. - Change duplicate line shortcut to C-S-d.
50 lines
1.6 KiB
EmacsLisp
50 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:
|
|
|
|
;; 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
|
|
))
|
|
|
|
;; 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)
|
|
|
|
;; 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)
|
|
(or (featurep 'all-the-icons)
|
|
(require 'all-the-icons nil t))))
|
|
|
|
(provide 'base-functions)
|
|
;;; base-functions.el ends here.
|