aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTino Calancha2016-08-17 18:25:54 +0900
committerTino Calancha2016-08-17 18:25:54 +0900
commit8d4039bcd69f0134fe3723b2bb3c921952e298c5 (patch)
tree39668b32ab1009fe37e4c18742bb6e67c9431561
parent80082d00d8ab8803c792751c0019c2f88614f48e (diff)
downloademacs-8d4039bcd69f0134fe3723b2bb3c921952e298c5.tar.gz
emacs-8d4039bcd69f0134fe3723b2bb3c921952e298c5.zip
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.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/files.el20
2 files changed, 22 insertions, 2 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 8a13d525450..0c561ccc511 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -115,8 +115,8 @@ have been added. They are: 'file-attribute-type',
115'file-attribute-group-id', 'file-attribute-access-time', 115'file-attribute-group-id', 'file-attribute-access-time',
116'file-attribute-modification-time', 116'file-attribute-modification-time',
117'file-attribute-status-change-time', 'file-attribute-size', 117'file-attribute-status-change-time', 'file-attribute-size',
118'file-attribute-modes', 'file-attribute-inode-number', and 118'file-attribute-modes', 'file-attribute-inode-number',
119'file-attribute-device-number'. 119'file-attribute-device-number' and 'file-attribute-collect'.
120 120
121+++ 121+++
122** The new function 'buffer-hash' computes a fast, non-consing hash of 122** The new function 'buffer-hash' computes a fast, non-consing hash of
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
7225middle 24 bits, and finally the low 16 bits." 7225middle 24 bits, and finally the low 16 bits."
7226 (nth 11 attributes)) 7226 (nth 11 attributes))
7227 7227
7228(defun file-attribute-collect (attributes &rest attr-names)
7229 "Return a sublist of ATTRIBUTES returned by `file-attributes'.
7230ATTR-NAMES are symbols with the selected attribute names.
7231
7232Valid attribute names are: type, link-number, user-id, group-id,
7233access-time, modification-time, status-change-time, size, modes,
7234inode-number and device-number."
7235 (let ((all '(type link-number user-id group-id access-time
7236 modification-time status-change-time
7237 size modes inode-number device-number))
7238 result)
7239 (while attr-names
7240 (let ((attr (pop attr-names)))
7241 (if (memq attr all)
7242 (push (funcall
7243 (intern (format "file-attribute-%s" (symbol-name attr)))
7244 attributes)
7245 result)
7246 (error "Wrong attribute name '%S'" attr))))
7247 (nreverse result)))
7228 7248
7229(define-key ctl-x-map "\C-f" 'find-file) 7249(define-key ctl-x-map "\C-f" 'find-file)
7230(define-key ctl-x-map "\C-r" 'find-file-read-only) 7250(define-key ctl-x-map "\C-r" 'find-file-read-only)