;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/kill-path.el (require 'dired-incal) (require 'window-incal) ;; kill (defun kill-line-number () (interactive) (kill-new (format "%s" (line-number-at-pos (point) t))) ) (defun kill-name () (interactive) (kill-new (file-name-nondirectory buffer-file-name)) ) (defun kill-path () (interactive) (let*((path (if (eq major-mode 'dired-mode) (dired-kill-path-dwim) buffer-file-name) ) (no-tilde-path (abbreviate-file-name path)) ) (kill-new (car (last (split-string no-tilde-path ":")))) )) ;; kill other (defun kill-line-number-other-window () (interactive) (apply-in-other-window #'kill-line-number) ) (defun kill-name-other-window () (interactive) (apply-in-other-window #'kill-name) ) (defun kill-path-other-window () (interactive) (apply-in-other-window #'kill-path) ) ;; yank (defun yank-line-number () (interactive) (kill-line-number) (yank) ) (defun yank-name () (interactive) (kill-name) (yank) ) (defun yank-path () (interactive) (kill-path) (yank) ) ;; yank other (defun yank-other-line-number () (interactive) (kill-line-number-other-window) (yank) ) (defun yank-other-name () (interactive) (kill-name-other-window) (yank) ) (defun yank-other-path () (interactive) (kill-path-other-window) (yank) ) (provide 'kill-path)