;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/file-incal.el (require 'sudo-user-path) (require 'tramp) (defun delete-current-file () (interactive) (let*((file (buffer-file-name)) (prompt (format "delete %s on disk? " file))) (when (yes-or-no-p prompt) (kill-buffer) (delete-file file)))) (defalias 'delete-this-file #'delete-current-file) (defun make-executable () (interactive) (shell-command (format "chmod +x %s" buffer-file-name))) (defun message-permissions () (interactive) (message "%s" (tramp-file-mode-from-int (file-modes buffer-file-name)))) (defun find-file-at-line (&optional other-window) (interactive "P") (let ((possible-filename (thing-at-point 'filename t)) ; NO-PROPERTIES (find-fun (if other-window #'find-file-other-window #'find-file))) (if (and possible-filename (file-exists-p possible-filename)) (apply find-fun (list possible-filename)) (forward-char) (find-file-at-line)))) (provide 'file-incal)