mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 07:41:37 -05:00
Remove unused jupyter-tramp.el
functions
This commit is contained in:
parent
96aaedf5b5
commit
81b034dad9
1 changed files with 0 additions and 102 deletions
102
jupyter-tramp.el
102
jupyter-tramp.el
|
@ -839,108 +839,6 @@ return nil."
|
|||
(if nosort files
|
||||
(sort files (lambda (a b) (string-lessp (car a) (car b)))))))
|
||||
|
||||
;;; Inserting directory listings
|
||||
;; NOTE: None of the directory listing functions are actually used, since
|
||||
;; ls-lisp actually handles most dired switches.
|
||||
|
||||
(defun jupyter-tramp--insert-aligned-columns (rows &optional right-align-cols)
|
||||
(let ((max-lens (make-list (length (car rows)) 0)))
|
||||
;; Compute max lengths for each column
|
||||
(let ((head rows))
|
||||
(while head
|
||||
(let ((x max-lens)
|
||||
(y (pop head)))
|
||||
(while x
|
||||
(setcar x (max (pop x) (length (pop y))))))))
|
||||
(cl-loop
|
||||
for row in rows
|
||||
do (cl-loop
|
||||
for col being the elements of row using (index i)
|
||||
for pad-len = (- (nth i max-lens) (length col))
|
||||
for pad = (when (and (> pad-len 0)
|
||||
;; No need to pad the last column
|
||||
(not (= i (1- (length row)))))
|
||||
(make-string pad-len ?\s))
|
||||
collect (if (member i right-align-cols)
|
||||
(concat pad col)
|
||||
(concat col pad))
|
||||
into cols finally (insert (mapconcat #'identity cols " ") "\n")))))
|
||||
|
||||
(defun jupyter-tramp--byte-size-string (size)
|
||||
(let* ((B size)
|
||||
(KB (/ B 1000.0))
|
||||
(MB (/ KB 1000.0))
|
||||
(GB (/ MB 1000.0))
|
||||
(TB (/ GB 1000.0))
|
||||
(PB (/ TB 1000.0))
|
||||
(suf "")
|
||||
(size (cond
|
||||
((< KB 1.0) (setq suf "B") B)
|
||||
((< MB 1.0) (setq suf "K") KB)
|
||||
((< GB 1.0) (setq suf "M") MB)
|
||||
((< TB 1.0) (setq suf "G") GB)
|
||||
((< PB 1.0) (setq suf "T") TB)
|
||||
(t (setq suf "P") PB))))
|
||||
(concat
|
||||
(format
|
||||
(if (< size 100)
|
||||
(if (integerp size) "%d" "%.1f")
|
||||
(setq size (round size))
|
||||
"%d")
|
||||
size)
|
||||
suf)))
|
||||
|
||||
(defun jupyter-tramp--directory-listing-rows (file switches &optional full-directory-p)
|
||||
(jupyter-tramp--barf-if-not-file file)
|
||||
(cl-loop
|
||||
with total = 0
|
||||
with year-fmt = (format-time-string "%Y-01-01 00:00")
|
||||
with year = (apply #'encode-time (parse-time-string year-fmt))
|
||||
for attrs in (or (and (file-directory-p file)
|
||||
(or full-directory-p
|
||||
(not (dired-check-switches
|
||||
switches "d" "directory")))
|
||||
(directory-files-and-attributes file nil nil t))
|
||||
(list (cons (file-local-name file) (file-attributes file))))
|
||||
for file = (pop attrs)
|
||||
for links = (number-to-string (or (file-attribute-link-number attrs) 1))
|
||||
for user = (file-attribute-user-id attrs)
|
||||
for group = (file-attribute-group-id attrs)
|
||||
for mtime = (let ((time (file-attribute-modification-time attrs)))
|
||||
(format-time-string
|
||||
(concat "%b %d " (if (time-less-p time year) " %Y"
|
||||
"%H:%M"))
|
||||
time))
|
||||
for size = (jupyter-tramp--byte-size-string
|
||||
(let ((s (or (file-attribute-size attrs) 64)))
|
||||
(prog1 s (cl-incf total s))))
|
||||
for mbits = (file-attribute-modes attrs)
|
||||
collect (list mbits links user group size mtime file) into rows
|
||||
finally return (cons (jupyter-tramp--byte-size-string total) rows)))
|
||||
|
||||
(defun jupyter-tramp-insert-directory (file switches &optional wildcard full-directory-p)
|
||||
(if wildcard
|
||||
(let* ((files (directory-files
|
||||
(file-name-directory file)
|
||||
'abs (when wildcard
|
||||
;; TODO: Directory name wildcards
|
||||
(wildcard-to-regexp (file-name-nondirectory file)))))
|
||||
(dirs (cl-remove-if-not #'file-directory-p files)))
|
||||
(mapc (lambda (x) (insert-directory x switches))
|
||||
(cl-set-difference files dirs))
|
||||
(when dirs (insert "\n"))
|
||||
(while dirs
|
||||
(let ((dir (pop dirs)))
|
||||
(insert dir ":\n")
|
||||
(insert-directory dir switches nil full-directory-p)
|
||||
(when dirs (insert "\n")))))
|
||||
(cl-destructuring-bind (total-size . rows)
|
||||
(jupyter-tramp--directory-listing-rows file switches full-directory-p)
|
||||
(when (or full-directory-p (> (length rows) 1))
|
||||
(insert (format "total %s\n" total-size)))
|
||||
;; Right align the byte size column
|
||||
(jupyter-tramp--insert-aligned-columns rows '(4)))))
|
||||
|
||||
(provide 'jupyter-tramp)
|
||||
|
||||
;;; jupyter-tramp.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue