From 1cbf2655db40cd474411b77ece57a287eb85ea2c Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sun, 27 Nov 2022 16:57:03 +0100 Subject: Extend memory-info for remote systems * doc/lispref/files.texi (Magic File Names): Add memory-info. * doc/lispref/internals.texi (Garbage Collection): memory-info can also retrieve values from remote systems. * etc/NEWS: Document changes in memory-info. Fix typos. * lisp/files.el (warn-maybe-out-of-memory): Ensure local memory info. * lisp/net/tramp.el (tramp-handle-memory-info): New defun. (tramp-file-name-for-operation) * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist) * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'memory-info'. * lisp/net/tramp-sshfs.el (tramp-sshfs-handle-exec-path): Let-bind `process-file-side-effects'. * src/alloc.c (Fmemory_info): Support remote systems. (Qmemory_info): Declare. * test/lisp/net/tramp-tests.el (tramp-test31-memory-info): New test. --- src/alloc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 0653f2e0ccc..980085d3292 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -7435,9 +7435,17 @@ DEFUN ("memory-info", Fmemory_info, Smemory_info, 0, 0, 0, doc: /* Return a list of (TOTAL-RAM FREE-RAM TOTAL-SWAP FREE-SWAP). All values are in Kbytes. If there is no swap space, last two values are zero. If the system is not supported -or memory information can't be obtained, return nil. */) +or memory information can't be obtained, return nil. +If `default-directory’ is remote, return memory information of the +respective remote host. */) (void) { + Lisp_Object handler + = Ffind_file_name_handler (BVAR (current_buffer, directory), + Qmemory_info); + if (!NILP (handler)) + return call1 (handler, Qmemory_info); + #if defined HAVE_LINUX_SYSINFO struct sysinfo si; uintmax_t units; @@ -7859,6 +7867,8 @@ do hash-consing of the objects allocated to pure space. */); doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); Vmemory_full = Qnil; + DEFSYM (Qmemory_info, "memory-info"); + DEFSYM (Qconses, "conses"); DEFSYM (Qsymbols, "symbols"); DEFSYM (Qstrings, "strings"); -- cgit v1.2.1