Git Product home page Git Product logo

trashed's People

Contributors

shingo256 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

trashed's Issues

NonGNU Elpa?

There is this newfangled repository at NonGNU Elpa. It's like ELPA but you don't need to be a card-carrying FSF member.

Submitting this package to NonGNU ELPA would make it accessible to future Emacs users (since NonGNU will be part of Emacs28+) and improve visibility!

Some valid info files are rejected

Hi,

I noticed that some valid info files are rejected. For example, this one is skipped, apparently because of the spaces around the =, even though it's a valid file:

[Trash Info]
Path = /home/me/src/emacs/melpa/sandbox
DeletionDate = 2019-09-09T19:45:50

I also added a fix for this in #1

Thanks.

Errror when there is no directory for trashcan

Running trashed throws an error if I have never used the trashcan:

trashed-read-files: Opening directory: No such file or directory, /home/akirakomamura/.local/share/Trash/files

Apparently this is caused by evaluating the following expression in the function:

(directory-files-and-attributes trashed-files-dir nil nil t)

It can be prevented by putting the expression inside (ignore-errors ...).

Suggestion

Hi,

Great work converting to use tabulated-list-mode!

Here's some code you might want to use that simplifies the implementation of trashed-read-files a bit. I think it makes it easier to understand.

(defun trashed-read-files ()
  (let* ((files (directory-files-and-attributes trashed-files-dir nil nil t))
         (entries (cl-loop for (name . attrs) in files
                           unless (or (string= name ".") (string= name ".."))
                           collect (trashed-file-info name attrs))))
    (setf tabulated-list-entries entries)))

(defun trashed-file-info (name attrs)
  "Return list of name and vector for `tabulated-list-entries' for file NAME with ATTRS."
  (-let* ((type (cl-typecase (file-attribute-type attrs)
                  (string "l")
                  (null "-")
                  (t "d")))
          (size (number-to-string (file-attribute-size attrs)))
          (info-file (expand-file-name (concat name ".trashinfo") trashed-info-dir))
          ((path deletion-ts) (trashed-trashinfo info-file))
          (path (-> path url-unhex-string
                    (decode-coding-string 'utf-8 t)
                    (propertize 'mouse-face 'highlight)))
          (deletion-ts (format-time-string "%Y-%m-%d %H:%M:%S" deletion-ts)))
    (list name (vector type size deletion-ts path))))

(defun trashed-trashinfo (trashinfo-file)
  "Return list of original file path and deletion timestamp for TRASHINFO-FILE."
  (when (file-readable-p trashinfo-file)
    (with-temp-buffer
      (insert-file-contents trashinfo-file)
      (let* ((path (when (re-search-forward (rx bol "Path"
                                                (0+ blank) "=" (0+ blank)
                                                (group (1+ nonl))) nil t)
                     (match-string 1)))
             (deletion-ts (progn
                            (goto-char (point-min))
                            (when (re-search-forward (rx bol "DeletionDate"
                                                         (0+ blank) "=" (0+ blank)
                                                         (group (1+ nonl))) nil t)
                              (parse-iso8601-time-string (match-string 1))))))
        (list path deletion-ts)))))

Also, in the header, it says Data & Time instead of Date & Time. You might want to use something more explicit like Deleted At.

BTW, you might find this interesting. :) https://github.com/alphapapa/rubbish.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.