dotfiles/emacs/.emacs.d/config/init-files.el

44 lines
1.2 KiB
EmacsLisp

;; -*- lexical-binding: t; -*-
;; File-related configuration
(defun my/delete-file (file)
(interactive (list (read-file-name "Delete file: "
nil
nil
t
(file-name-nondirectory (buffer-file-name)))))
(let ((file (expand-file-name file)))
(delete-file file)
(when (string-equal (buffer-file-name) file)
(quit-window))))
(defun rename-this-file (new-name)
(interactive (list (read-file-name "Rename file: "
nil
nil
nil
(buffer-file-name))))
(rename-file (buffer-file-name) new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil))
(use-package sudo-edit
:commands (sudo-edit
sudo-edit-find-file))
;; Optimized editing of very large files
(use-package vlf
:commands (vlf))
(leader-def-key
"f" '(nil :which-key "file")
"ff" #'find-file
"fs" #'save-buffer
"fD" '(my/delete-file :which-key "delete")
"fr" '(rename-this-file :which-key "rename")
"fd" #'dired)
(provide 'init-files)