emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117515: * src/alloc.c (Fmemory_info) [HAVE_LINUX_SY


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r117515: * src/alloc.c (Fmemory_info) [HAVE_LINUX_SYSINFO]: Return nil if
Date: Fri, 11 Jul 2014 12:22:08 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117515
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2014-07-11 16:19:58 +0400
message:
  * src/alloc.c (Fmemory_info) [HAVE_LINUX_SYSINFO]: Return nil if
  sysinfo failed.  Adjust docstring.
  * doc/lispref/internals.texi (Garbage Collection): Mention memory-info.
  * lisp/files.el (out-of-memory-warning-percentage): New defcustom.
  (warn-maybe-out-of-memory): Use it.
modified:
  doc/lispref/ChangeLog          changelog-20091113204419-o5vbwnq5f7feedwu-6155
  doc/lispref/internals.texi     
internals.texi-20091113204419-o5vbwnq5f7feedwu-6188
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/files.el                  files.el-20091113204419-o5vbwnq5f7feedwu-265
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/alloc.c                    alloc.c-20091113204419-o5vbwnq5f7feedwu-252
=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog     2014-07-11 09:09:54 +0000
+++ b/doc/lispref/ChangeLog     2014-07-11 12:19:58 +0000
@@ -1,3 +1,7 @@
+2014-07-11  Dmitry Antipov  <address@hidden>
+
+       * internals.texi (Garbage Collection): Mention memory-info.
+
 2014-07-11  Michael Albinus  <address@hidden>
 
        * minibuf.texi (Intro to Minibuffers, Reading a Password):

=== modified file 'doc/lispref/internals.texi'
--- a/doc/lispref/internals.texi        2014-05-17 08:11:31 +0000
+++ b/doc/lispref/internals.texi        2014-07-11 12:19:58 +0000
@@ -513,6 +513,10 @@
 a certain kind of object.  See the documentation string for details.
 @end defun
 
address@hidden memory-info
+This functions returns an amount of total system memory and how much
+of it is free.  On an unsupported system, the value may be @code{nil}.
+
 @defvar gcs-done
 This variable contains the total number of garbage collections
 done so far in this Emacs session.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-07-11 09:09:54 +0000
+++ b/lisp/ChangeLog    2014-07-11 12:19:58 +0000
@@ -1,3 +1,8 @@
+2014-07-11  Dmitry Antipov  <address@hidden>
+
+       * files.el (out-of-memory-warning-percentage): New defcustom.
+       (warn-maybe-out-of-memory): Use it.
+
 2014-07-11  Michael Albinus  <address@hidden>
 
        * subr.el (read-passwd): Use `read-hide-char' if non-nil.  Bind it

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2014-07-10 18:19:37 +0000
+++ b/lisp/files.el     2014-07-11 12:19:58 +0000
@@ -1786,6 +1786,14 @@
   :version "22.1"
   :type '(choice integer (const :tag "Never request confirmation" nil)))
 
+(defcustom out-of-memory-warning-percentage 50
+  "Warn if file size exceeds this percentage of available free memory.
+When nil, never issue warning."
+  :group 'files
+  :group 'find-file
+  :version "24.4"
+  :type '(choice integer (const :tag "Never issue warning" nil)))
+
 (defun abort-if-file-too-large (size op-type filename)
   "If file SIZE larger than `large-file-warning-threshold', allow user to 
abort.
 OP-TYPE specifies the file operation being performed (for message to user)."
@@ -1798,19 +1806,22 @@
 
 (defun warn-maybe-out-of-memory (size)
   "Warn if an attempt to open file of SIZE bytes may run out of memory."
-  (when (and (numberp size) (not (zerop size)))
+  (when (and (numberp size) (not (zerop size))
+            (integerp out-of-memory-warning-percentage))
     (let ((meminfo (memory-info)))
       (when (consp meminfo)
-       (let ((total-free-memory (+ (nth 1 meminfo) (nth 3 meminfo))))
-         (when (> (/ size 1024) total-free-memory)
+       (let ((total-free-memory (float (+ (nth 1 meminfo) (nth 3 meminfo)))))
+         (when (> (/ size 1024)
+                  (/ (* total-free-memory out-of-memory-warning-percentage)
+                     100.0))
            (warn
             "You are trying to open a file whose size (%s)
-exceeds the amount of currently available free memory (%s).
+exceeds the %S%% of currently available free memory (%s).
 If that fails, try to open it with `find-file-literally'
 \(but note that some characters might be displayed incorrectly)."
             (file-size-human-readable size)
-            (file-size-human-readable
-             (* (float total-free-memory) 1024)))))))))
+            out-of-memory-warning-percentage
+            (file-size-human-readable (* total-free-memory 1024)))))))))
 
 (defun find-file-noselect (filename &optional nowarn rawfile wildcards)
   "Read file FILENAME into a buffer and return the buffer.

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-07-11 10:09:51 +0000
+++ b/src/ChangeLog     2014-07-11 12:19:58 +0000
@@ -1,3 +1,8 @@
+2014-07-11  Dmitry Antipov  <address@hidden>
+
+       * alloc.c (Fmemory_info) [HAVE_LINUX_SYSINFO]: Return nil if
+       sysinfo failed.  Adjust docstring.
+
 2014-07-11  Eli Zaretskii  <address@hidden>
 
        Implement memory-info for MS-DOS.

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2014-07-11 10:09:51 +0000
+++ b/src/alloc.c       2014-07-11 12:19:58 +0000
@@ -6875,8 +6875,9 @@
 
 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, return nil.  */)
+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.  */)
   (void)
 {
 #if defined HAVE_LINUX_SYSINFO
@@ -6884,7 +6885,7 @@
   uintmax_t units;
 
   if (sysinfo (&si))
-    emacs_abort ();
+    return Qnil;
 #ifdef LINUX_SYSINFO_UNIT
   units = si.mem_unit;
 #else


reply via email to

[Prev in Thread] Current Thread [Next in Thread]