Emacs library to interact with extended attributes
This library enables the user to interact with extended attributes (xattrs from now on). Xattrs are key-value metadata that can be added to files if filesystem supports them. This has been tested only on Linux.
Operations that are possible on xattrs: set, get, remove, list, empty-p
MAP implementation: xattr-map.el implements map interface for xattr-map
I needed to tag files in dired. I was abusing image-dired package to tag files, but, in the end, it was designed to work only with media files, which gave some troubles. Future work will require to write some dired-tags package based on this library.
You need to get emacs-module.h from emacs source files and set its directory
to EMACS_SRC make variable
make EMACS_SRC=/path/to/dir/where/emacs-module.h/is/stored(xattr-set "my-file-name.ext" "user.my.attribute" "with value")
;; => "with value"
(xattr-set "my-file-name.ext" "user.my.attribute2" "with value2")
;; => "with value2"
(xattr-get "my-file-name.ext" "user.my.attribute")
;; => "with value"
(xattr-list "my-file-name.ext")
;; => ("user.my.attribute" "user.my.attribute2")
(xattr-remove "my-file-name.ext" "user.my.attribute")
;; => nil
(xattr-list "my-file-name.ext")
;; => ("user.my.attribute2")
(xattr-empty-p "my-file-name.ext")
;; => nil
(require 'xattr-map)
(let ((map (xattr-map "my-file-name.ext")))
(map-keys map)
;; => ("user.my.attribute2")
(map-values map)
;; => ("with value2")
)(xattr-set FILE NAME VALUE)
(xattr-get FILE NAME)
(xattr-list FILE)
(xattr-empty-p FILE)
(xattr-remove FILE NAME)
All of this functions can signal different errors. Please, inspect
define-error definitions in xattr.el to learn more.
(xattr-map FILE)
C module handles relative files relative to the directory where GNU/Emacs started. Should we handle this in every xattr call?
Copyright (c) 2022 Valeriy Litkovskyy Licensed under the GPL3 License.