* lisp/net/tramp-compat.el (tramp-compat-ntake): New defalias.
* lisp/net/tramp.el (tramp-handle-directory-files):
* lisp/net/tramp-crypt.el (tramp-crypt-handle-directory-files):
* lisp/net/tramp-sh.el (tramp-sh-handle-directory-files-and-attributes):
* lisp/net/tramp-smb.el (tramp-smb-handle-directory-files): Use it.
(setq secret (funcall secret)))
secret))))
+;; Function `ntake' is new in Emacs 29.1.
+(defalias 'tramp-compat-ntake
+ (if (fboundp 'ntake)
+ #'ntake
+ (lambda (n list)
+ (when (and (natnump n) (> n 0))
+ (if (>= n (length list))
+ list (nbutlast list (- (length list) n)))))))
+
(dolist (elt (all-completions "tramp-compat-" obarray 'functionp))
(put (intern elt) 'tramp-suppress-trace t))
(unless nosort
(setq result (sort result #'string<)))
(when (and (natnump count) (> count 0))
- (setq result (nbutlast result (- (length result) count))))
+ (setq result (tramp-compat-ntake count result)))
result)))
(defun tramp-crypt-handle-file-attributes (filename &optional id-format)
(setq result (sort result (lambda (x y) (string< (car x) (car y))))))
(when (and (natnump count) (> count 0))
- (setq result (nbutlast result (- (length result) count))))
+ (setq result (tramp-compat-ntake count result)))
(or result
;; The scripts could fail, for example with huge file size.
;; Return count number of results.
(when (and (natnump count) (> count 0))
- (setq result (nbutlast result (- (length result) count))))
+ (setq result (tramp-compat-ntake count result)))
;; Prepend directory.
(when full
(unless nosort
(setq result (sort result #'string<)))
(when (and (natnump count) (> count 0))
- (setq result (nbutlast result (- (length result) count))))
+ (setq result (tramp-compat-ntake count result)))
result)))
(defun tramp-handle-directory-files-and-attributes