diff options
author | Tino Calancha <tino.calancha@gmail.com> | 2016-08-17 18:25:54 +0900 |
---|---|---|
committer | Tino Calancha <tino.calancha@gmail.com> | 2016-08-17 18:25:54 +0900 |
commit | 8d4039bcd69f0134fe3723b2bb3c921952e298c5 (patch) | |
tree | 39668b32ab1009fe37e4c18742bb6e67c9431561 /lisp/files.el | |
parent | 80082d00d8ab8803c792751c0019c2f88614f48e (diff) | |
download | emacs-8d4039bcd69f0134fe3723b2bb3c921952e298c5.tar.gz |
file-attribute-collect: New defun
* lisp/files.el (file-attribute-collect):
Return a sublist of the attributes returned by 'file-attributes'.
Suggested by Ted Zlatanov in:
http://lists.gnu.org/archive/html/emacs-devel/2016-07/msg01195.html
; * etc/NEWS: Mention this defun in NEWS.
Diffstat (limited to 'lisp/files.el')
-rw-r--r-- | lisp/files.el | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/files.el b/lisp/files.el index aad9f751cc4..b93cc79648d 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -7225,6 +7225,26 @@ of the form (HIGH MIDDLE . LOW): first the high bits, then the middle 24 bits, and finally the low 16 bits." (nth 11 attributes)) +(defun file-attribute-collect (attributes &rest attr-names) + "Return a sublist of ATTRIBUTES returned by `file-attributes'. +ATTR-NAMES are symbols with the selected attribute names. + +Valid attribute names are: type, link-number, user-id, group-id, +access-time, modification-time, status-change-time, size, modes, +inode-number and device-number." + (let ((all '(type link-number user-id group-id access-time + modification-time status-change-time + size modes inode-number device-number)) + result) + (while attr-names + (let ((attr (pop attr-names))) + (if (memq attr all) + (push (funcall + (intern (format "file-attribute-%s" (symbol-name attr))) + attributes) + result) + (error "Wrong attribute name '%S'" attr)))) + (nreverse result))) (define-key ctl-x-map "\C-f" 'find-file) (define-key ctl-x-map "\C-r" 'find-file-read-only) |