diff options
| author | TCCQ <thomasmulmer02@gmail.com> | 2025-04-09 19:53:47 -0700 |
|---|---|---|
| committer | TCCQ <thomasmulmer02@gmail.com> | 2025-04-09 19:53:47 -0700 |
| commit | aacd40d6adbf9bfb510e40b7ddb93678e7cecbcd (patch) | |
| tree | 4efb7ef976d7e6fd1a9c72647f2b40cf6b804565 /emacs/site-lisp/my-funcs.el | |
| parent | 729e4d189c2d25a551a77a77276c75f42fbc4faa (diff) | |
emacs to add single top header and move some (global) info there
Diffstat (limited to 'emacs/site-lisp/my-funcs.el')
| -rw-r--r-- | emacs/site-lisp/my-funcs.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/emacs/site-lisp/my-funcs.el b/emacs/site-lisp/my-funcs.el index 8bed290..01bf5cc 100644 --- a/emacs/site-lisp/my-funcs.el +++ b/emacs/site-lisp/my-funcs.el @@ -143,3 +143,16 @@ BEG and END define the region." (defun dired-do-find-marked-files () (interactive) (seq-do 'find-file (dired-get-marked-files))) + +(defun shorten-path (path) + "Shortens each directory in PATH except for the last directory to its first character." + (let* ((components (split-string path "/")) ; Split the path into components + (last-component (-last (lambda (s) (not (string-empty-p s))) components)) ; Extract the last component + (shortened-components ; Shorten all components except the last + (mapcar (lambda (comp) + (if (or (string-equal comp last-component) (string-empty-p comp)) + comp + (substring comp 0 1))) + components))) + (mapconcat 'identity shortened-components "/"))) ; Recombine components into a path + |
