[elpa] branch externals/gcmh created (now 5a83e25)

2020-11-16 Thread Andrea Corallo
akrl pushed a change to branch externals/gcmh.

at  5a83e25   Bump version 0.2

This branch includes the following new commits:

   new  db9eceb   initial add
   new  49db303   initial implementation
   new  8008009   some minor fixes
   new  75de01e   add missing requires
   new  920bc52   better comments
   new  c1bc27a   Add readme
   new  91cd1f7   autoload minor mode
   new  65787bc   typo fix
   new  81844fa   update readme
   new  dd69c84   add warning into readme
   new  e7af13d   better readme layout
   new  c96bd70   update readme
   new  72683e1   Update conventions
   new  5664cb3   Add garbage collection start message
   new  1953d91   Merge branch 'master' into 'master'
   new  5bf0ed3   Prevent duplicate idle timers being created
   new  a7f8cc2   Correct minor typos
   new  537d050   Further minor typo
   new  f542908   Merge branch 'feature/prevent-duplicate-timers' into 
'master'
   new  8867533   Improve messaging
   new  9e241e0   Fix missing `gcmh-low-cons-threshold' set introduced by 
8867533
   new  b1bde50   Update copyright + email
   new  84c43a4   Remove unnecessary require in README
   new  12fd03c   Set the new timer for running once and on 
post-command-hook
   new  855f03e   Implement auto idle delay mode
   new  f3389e9   Always use `setf' in place of `setq'
   new  f449abb   No reason anymore to use `run-with-idle-timer' so use 
`run-with-timer'
   new  04e3c0c   Set `gcmh-auto-idle-delay-factor' to 20
   new  345121d   Readme update
   new  8bf0666   Rename `gcmh-register-idle-timer' into 
`gcmh-register-idle-gc'
   new  2827dff   Clean-up unnecessary logic
   new  5a83e25   Bump version 0.2




[elpa] externals/gcmh 49db303 02/32: initial implementation

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 49db3037587b92e1c7e993875d4c609c42df0c36
Author: Andrea Corallo 
Commit: Andrea Corallo 

initial implementation
---
 gcmh.el | 97 +
 1 file changed, 97 insertions(+)

diff --git a/gcmh.el b/gcmh.el
index 4500e82..69daea1 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -1 +1,98 @@
 ;;; gcmh.el --- the Garbage Collector Magic Hack -*- lexical-binding:t -*-
+
+;; Copyright (C) 2019 Andrea Corallo
+
+;; Maintainer: andrea_cora...@yahoo.it
+;; Package: gcmh
+;; Homepage: https://gitlab.com/koral/gcmh
+;; Version: 0.1
+;; Package-Requires:
+;; Keywords: garbage collector, garbage collection
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see .
+
+;;; Commentary:
+;; Enforce an optimized Garbage Collection strategy to minimize GC
+;; interference with the user activity.
+;; A more detailed explanation of the rationale behind this can be found at
+;; http://akrl.sdf.org/
+
+;;; Code:
+
+(defcustom gcmh-low-cons-threshold gc-cons-threshold
+  "High cons gc threshold.
+This is the gc threshold used while in idle.  Default value is \
+`gc-cons-threshold'"
+  :group 'gcmh
+  :type 'number)
+
+(defcustom gcmh-high-cons-threshold #x4000
+  "High cons gc threshold.
+This should be set to a value that makes GC unlikely but does not make the OS \
+paging."
+  :group 'gcmh
+  :type 'number)
+
+(defcustom gcmh-verbose nil
+  "If t print a message into when garbage collecting."
+  :group 'gcmh
+  :type 'boolean)
+
+(defvar gcmh-timer nil
+  "Idle timer set for trigering GC.")
+
+(defmacro gcmh-time (&rest body)
+  "Measure and return the time it takes to evaluate BODY."
+  `(let ((time (current-time)))
+ ,@body
+ (float-time (time-since time
+
+(defun gcmh-set-high-threshold ()
+  "Set the high gc thereshold.
+This is to be used with the `pre-command-hook'."
+  (setq gc-cons-threshold gcmh-high-cons-threshold))
+
+;;;###autoload
+(define-minor-mode gcmh-mode
+  "Minor mode tweak Garbage Colelction strategy."
+  :lighter " GCMH"
+  :global t
+  (cond
+   (gcmh-mode
+(progn
+  (setq gc-cons-threshold gcmh-high-cons-threshold)
+  ;; Print a message when garbage collecting
+  (setq garbage-collection-messages gcmh-verbose)
+  ;; When idle for 15sec run the GC no matter what.
+  (unless gcmh-timer
+   (setq gcmh-timer
+ (run-with-idle-timer 15 t
+  (lambda ()
+(if gcmh-verbose
+(message "Garbage Collector has run 
for %.06fsec"
+ (gcmh-time (garbage-collect)))
+  (garbage-collect))
+(setq gc-cons-threshold 
gcmh-low-cons-threshold)
+  (add-hook 'pre-command-hook #'gcmh-set-high-threshold)))
+   (t (progn
+   (setq gc-cons-threshold gcmh-low-cons-threshold)
+   (cancel-timer gcmh-timer)
+   (setq gcmh-timer nil)
+   (remove-hook 'pre-command-hook #'gcmh-set-high-threshold)
+
+(provide 'gcmh)
+
+;;; gcmh.el ends here



[elpa] externals/gcmh 91cd1f7 07/32: autoload minor mode

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 91cd1f78db9042c535b65582b63eef8cda2542b7
Author: Andrea Corallo 
Commit: Andrea Corallo 

autoload minor mode
---
 gcmh.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcmh.el b/gcmh.el
index 5ebe3d4..0814566 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -77,6 +77,7 @@ paging."
 This is to be used with the `pre-command-hook'."
   (setq gc-cons-threshold gcmh-high-cons-threshold))
 
+;;;###autoload
 (define-minor-mode gcmh-mode
   "Minor mode tweak Garbage Colelction strategy."
   :lighter " GCMH"



[elpa] externals/gcmh 65787bc 08/32: typo fix

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 65787bce5e21ee4a376008a67095a395ac9d5fed
Author: Andrea Corallo 
Commit: Andrea Corallo 

typo fix
---
 gcmh.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcmh.el b/gcmh.el
index 0814566..40b70bf 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -79,7 +79,7 @@ This is to be used with the `pre-command-hook'."
 
 ;;;###autoload
 (define-minor-mode gcmh-mode
-  "Minor mode tweak Garbage Colelction strategy."
+  "Minor mode tweak Garbage Collection strategy."
   :lighter " GCMH"
   :require 'gcmh
   :global t



[elpa] externals/gcmh 537d050 18/32: Further minor typo

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 537d050e7a0849ea3b03f7ec2ce1500fe4c2dbff
Author: Stuart Hickinbottom 
Commit: Stuart Hickinbottom 

Further minor typo
---
 gcmh.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index 0036d77..bbccbc9 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -36,8 +36,8 @@
 
 (defcustom gcmh-low-cons-threshold 80
   "Low cons GC threshold.
-This is the GC threshold used while while idling. Default value
-is the same of `gc-cons-threshold' default."
+This is the GC threshold used while idling. Default value is the
+same of `gc-cons-threshold' default."
   :group 'gcmh
   :type 'number)
 



[elpa] externals/gcmh 1953d91 15/32: Merge branch 'master' into 'master'

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 1953d913b5aa8822b83db8e20e17145470e01d79
Merge: c96bd70 5664cb3
Author: Koral 
Commit: Koral 

Merge branch 'master' into 'master'

Update conventions

See merge request koral/gcmh!1
---
 gcmh.el | 70 +
 1 file changed, 31 insertions(+), 39 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index 40b70bf..d2eae63 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -34,37 +34,32 @@
 
 ;;; Code:
 
-(require 'custom)
-(require 'message)
-(require 'timer)
-(require 'easy-mmode)
-
 (defcustom gcmh-low-cons-threshold 80
-  "High cons gc threshold.
-This is the gc threshold used while while idling.  Default value is \
-the same of `gc-cons-threshold' default"
+  "Low cons gc threshold.
+This is the gc threshold used while while idling. Default value
+is the same of `gc-cons-threshold' default"
   :group 'gcmh
   :type 'number)
 
 (defcustom gcmh-high-cons-threshold #x4000
   "High cons gc threshold.
-This should be set to a value that makes GC unlikely but does not make the OS \
-paging."
+This should be set to a value that makes GC unlikely but does not
+make the OS paging."
   :group 'gcmh
   :type 'number)
 
-(defcustom gcmh-time-constant 15
+(defcustom gcmh-idle-delay 15
   "Idle time to wait in seconds before triggering GC."
   :group 'gcmh
   :type 'number)
 
 (defcustom gcmh-verbose nil
-  "If t print a message when garbage collecting."
+  "If t, print a message when garbage collecting."
   :group 'gcmh
   :type 'boolean)
 
-(defvar gcmh-timer nil
-  "Idle timer set for trigering GC.")
+(defvar gcmh-idle-timer nil
+  "Idle timer for trigering GC.")
 
 (defmacro gcmh-time (&rest body)
   "Measure and return the time it takes to evaluate BODY."
@@ -77,35 +72,32 @@ paging."
 This is to be used with the `pre-command-hook'."
   (setq gc-cons-threshold gcmh-high-cons-threshold))
 
+(defun gcmh-idle-garbage-collect ()
+  "Run garbage collection after `gcmh-idle-delay'."
+  (if gcmh-verbose
+  (progn (message "Garbage collecting...")
+ (message "Garbage Collector ran for %.06f sec"
+  (gcmh-time (garbage-collect
+(garbage-collect))
+  (setq gc-cons-threshold gcmh-low-cons-threshold))
+
 ;;;###autoload
 (define-minor-mode gcmh-mode
-  "Minor mode tweak Garbage Collection strategy."
+  "Minor mode to tweak Garbage Collection strategy."
   :lighter " GCMH"
-  :require 'gcmh
   :global t
-  (cond
-   (gcmh-mode
-(progn
-  (setq gc-cons-threshold gcmh-high-cons-threshold)
-  ;; Print a message when garbage collecting
-  (setq garbage-collection-messages gcmh-verbose)
-  ;; When idle for 15sec run the GC no matter what.
-  (unless gcmh-timer
-   (setq gcmh-timer
- (run-with-idle-timer gcmh-time-constant t
-  (lambda ()
-(if gcmh-verbose
-(message "Garbage Collector has run 
for %.06fsec"
- (gcmh-time (garbage-collect)))
-  (garbage-collect))
-(setq gc-cons-threshold 
gcmh-low-cons-threshold)
-  ;; Release severe GC strategy before the user restart to working
-  (add-hook 'pre-command-hook #'gcmh-set-high-threshold)))
-   (t (progn
-   (setq gc-cons-threshold gcmh-low-cons-threshold)
-   (cancel-timer gcmh-timer)
-   (setq gcmh-timer nil)
-   (remove-hook 'pre-command-hook #'gcmh-set-high-threshold)
+  (if gcmh-mode
+  (progn
+(setq  gc-cons-threshold gcmh-high-cons-threshold
+   ;; When idle for gcmh-idle-delay, run the GC no matter what.
+   gcmh-idle-timer (run-with-idle-timer gcmh-idle-delay t
+
#'gcmh-idle-garbage-collect))
+;; Release severe GC strategy before the user restart to working
+(add-hook 'pre-command-hook #'gcmh-set-high-threshold))
+(cancel-timer gcmh-idle-timer)
+(setq gc-cons-threshold gcmh-low-cons-threshold
+  gcmh-idle-timer nil)
+(remove-hook 'pre-command-hook #'gcmh-set-high-threshold)))
 
 (provide 'gcmh)
 



[elpa] externals/gcmh dd69c84 10/32: add warning into readme

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit dd69c843e34f022fd35048e21c960cc8984c874a
Author: Andrea Corallo 
Commit: Andrea Corallo 

add warning into readme
---
 README.org | 5 +
 1 file changed, 5 insertions(+)

diff --git a/README.org b/README.org
index 15030b3..298e154 100644
--- a/README.org
+++ b/README.org
@@ -10,6 +10,11 @@
 
   [[http://akrl.sdf.org/]]
 
+  WARNING: in case Emacs is used in system already under severe memory pressure
+  be sure to understand how GCMH works and trim ~gcmh-high-cons-threshold~
+  accordingly. Default value may be to big and/or GCMH may not fit your use
+  case.
+
 ** Usage
 
Add into your .emacs



[elpa] externals/gcmh 5bf0ed3 16/32: Prevent duplicate idle timers being created

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 5bf0ed3384ea5dd43c5ca007603f7b05aac5d2cf
Author: Stuart Hickinbottom 
Commit: Stuart Hickinbottom 

Prevent duplicate idle timers being created

I found that when combined with desktop-save-mode, upon session
reloading in a new Emacs instance, then gcmh-mode would be enabled
multiple times even when it was already active. This causes multiple
duplicate idle timers to be created (one for each time the mode is
enabled).

The same effect can be provoked by manually running (gcmh-mode t)
multiple times.

The effect of this is garbage collection being executed multiple times
each time the idle time expired.

I noticed this because GC was slower than expected, and turning on
gcmh-verbose revealed all those duplicate GC events each time Emacs
had been idle.

This change simply removes any extant timer before enabling the mode
so we're guaranteed to only have one or zero idle timers defined.
---
 gcmh.el | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcmh.el b/gcmh.el
index d2eae63..3564e48 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -86,6 +86,10 @@ This is to be used with the `pre-command-hook'."
   "Minor mode to tweak Garbage Collection strategy."
   :lighter " GCMH"
   :global t
+
+  ;; Cancel any pending timer (prevents duplicate idle timers).
+  (when (timerp gcmh-idle-timer)
+(cancel-timer gcmh-idle-timer))
   (if gcmh-mode
   (progn
 (setq  gc-cons-threshold gcmh-high-cons-threshold
@@ -94,7 +98,6 @@ This is to be used with the `pre-command-hook'."
 
#'gcmh-idle-garbage-collect))
 ;; Release severe GC strategy before the user restart to working
 (add-hook 'pre-command-hook #'gcmh-set-high-threshold))
-(cancel-timer gcmh-idle-timer)
 (setq gc-cons-threshold gcmh-low-cons-threshold
   gcmh-idle-timer nil)
 (remove-hook 'pre-command-hook #'gcmh-set-high-threshold)))



[elpa] externals/gcmh b1bde50 22/32: Update copyright + email

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit b1bde5089169a74f62033d027e06e98cbeedd43f
Author: Andrea Corallo 
Commit: Andrea Corallo 

Update copyright + email
---
 gcmh.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index f042ced..dd9f2a6 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -1,8 +1,8 @@
 ;;; gcmh.el --- the Garbage Collector Magic Hack -*- lexical-binding:t -*-
 
-;; Copyright (C) 2019 Andrea Corallo
+;; Copyright (C) 2019-2020 Andrea Corallo
 
-;; Maintainer: andrea_cora...@yahoo.it
+;; Maintainer: a...@sdf.org
 ;; Package: gcmh
 ;; Homepage: https://gitlab.com/koral/gcmh
 ;; Version: 0.1



[elpa] externals/gcmh e7af13d 11/32: better readme layout

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit e7af13d7743457ed430a9858fa35a3720c55dec6
Author: Andrea Corallo 
Commit: Andrea Corallo 

better readme layout
---
 README.org | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/README.org b/README.org
index 298e154..dd53364 100644
--- a/README.org
+++ b/README.org
@@ -4,16 +4,21 @@
 
   Enforce a sneaky Garbage Collection strategy to minimize GC interference with
   the activity.
+
   During normal use a high GC threshold is set.
+
   When idling GC is immediately triggered and a low threshold is set.
+
   A more detailed explanation of the rationale behind this can be found at:
 
   [[http://akrl.sdf.org/]]
 
-  WARNING: in case Emacs is used in system already under severe memory pressure
-  be sure to understand how GCMH works and trim ~gcmh-high-cons-threshold~
-  accordingly. Default value may be to big and/or GCMH may not fit your use
-  case.
+*** WARNING
+
+In case Emacs is used in a system already under severe memory pressure
+be sure to understand how GCMH works and trim ~gcmh-high-cons-threshold~
+accordingly. Default value may be to big and/or GCMH may not fit your use
+case.
 
 ** Usage
 



[elpa] externals/gcmh db9eceb 01/32: initial add

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit db9ecebd54baecf2b80e856576425342532d4a62
Author: Andrea Corallo 
Commit: Andrea Corallo 

initial add
---
 gcmh.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcmh.el b/gcmh.el
new file mode 100644
index 000..4500e82
--- /dev/null
+++ b/gcmh.el
@@ -0,0 +1 @@
+;;; gcmh.el --- the Garbage Collector Magic Hack -*- lexical-binding:t -*-



[elpa] externals/gcmh 9e241e0 21/32: Fix missing `gcmh-low-cons-threshold' set introduced by 8867533

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 9e241e0a9f921b04407050a0f0fada3d0c3b254a
Author: Andrea Corallo 
Commit: Andrea Corallo 

Fix missing `gcmh-low-cons-threshold' set introduced by 8867533
---
 gcmh.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcmh.el b/gcmh.el
index d78b505..f042ced 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -82,7 +82,8 @@ This is to be used with the `pre-command-hook'."
 (gcmh-time (garbage-collect)))
  (error (message "Garbage collecting...failed")
 (signal (car e) (cdr e)
-(garbage-collect)))
+(garbage-collect))
+  (setq gc-cons-threshold gcmh-low-cons-threshold))
 
 ;;;###autoload
 (define-minor-mode gcmh-mode



[elpa] externals/gcmh a7f8cc2 17/32: Correct minor typos

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit a7f8cc2f9a3a2ce30b29bda7d8e9a85fd5b781ed
Author: Stuart Hickinbottom 
Commit: Stuart Hickinbottom 

Correct minor typos
---
 gcmh.el | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index 3564e48..0036d77 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -35,16 +35,16 @@
 ;;; Code:
 
 (defcustom gcmh-low-cons-threshold 80
-  "Low cons gc threshold.
-This is the gc threshold used while while idling. Default value
-is the same of `gc-cons-threshold' default"
+  "Low cons GC threshold.
+This is the GC threshold used while while idling. Default value
+is the same of `gc-cons-threshold' default."
   :group 'gcmh
   :type 'number)
 
 (defcustom gcmh-high-cons-threshold #x4000
-  "High cons gc threshold.
+  "High cons GC threshold.
 This should be set to a value that makes GC unlikely but does not
-make the OS paging."
+cause OS paging."
   :group 'gcmh
   :type 'number)
 
@@ -59,7 +59,7 @@ make the OS paging."
   :type 'boolean)
 
 (defvar gcmh-idle-timer nil
-  "Idle timer for trigering GC.")
+  "Idle timer for triggering GC.")
 
 (defmacro gcmh-time (&rest body)
   "Measure and return the time it takes to evaluate BODY."
@@ -68,7 +68,7 @@ make the OS paging."
  (float-time (time-since time
 
 (defun gcmh-set-high-threshold ()
-  "Set the high gc thereshold.
+  "Set the high GC threshold.
 This is to be used with the `pre-command-hook'."
   (setq gc-cons-threshold gcmh-high-cons-threshold))
 



[elpa] externals/gcmh 5664cb3 14/32: Add garbage collection start message

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 5664cb3be0579a2e713df59cafffacd7223f5d4e
Author: Troy Hinckley 
Commit: Troy Hinckley 

Add garbage collection start message
---
 gcmh.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index d5762c0..d2eae63 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -75,8 +75,9 @@ This is to be used with the `pre-command-hook'."
 (defun gcmh-idle-garbage-collect ()
   "Run garbage collection after `gcmh-idle-delay'."
   (if gcmh-verbose
-  (message "Garbage Collector ran for %.06f sec"
-   (gcmh-time (garbage-collect)))
+  (progn (message "Garbage collecting...")
+ (message "Garbage Collector ran for %.06f sec"
+  (gcmh-time (garbage-collect
 (garbage-collect))
   (setq gc-cons-threshold gcmh-low-cons-threshold))
 



[elpa] externals/gcmh 75de01e 04/32: add missing requires

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 75de01e49bac78d9feceaacf0543ff8471acb96c
Author: Andrea Corallo 
Commit: Andrea Corallo 

add missing requires
---
 gcmh.el | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcmh.el b/gcmh.el
index 041208e..69c20e3 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -32,6 +32,11 @@
 
 ;;; Code:
 
+(require 'custom)
+(require 'message)
+(require 'timer)
+(require 'easy-mmode)
+
 (defcustom gcmh-low-cons-threshold gc-cons-threshold
   "High cons gc threshold.
 This is the gc threshold used while in idle.  Default value is \



[elpa] externals/gcmh f3389e9 26/32: Always use `setf' in place of `setq'

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit f3389e935d15e5d44e7e7d24c6e89666f03aa356
Author: Andrea Corallo 
Commit: Andrea Corallo 

Always use `setf' in place of `setq'
---
 gcmh.el | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index 6c32281..99227b5 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -78,7 +78,7 @@ time the last non idle garbage collection time."
 (defun gcmh-set-high-threshold ()
   "Set the high GC threshold.
 This is to be used with the `pre-command-hook'."
-  (setq gc-cons-threshold gcmh-high-cons-threshold))
+  (setf gc-cons-threshold gcmh-high-cons-threshold))
 
 (defvar gcmh-last-gc-time 0.1
   "How long it took to perform the last garbage collection.")
@@ -101,11 +101,11 @@ Cancel the previous one if present."
(message "Garbage collecting...")
(condition-case-unless-debug e
(message "Garbage collecting...done (%.3fs)"
-(setq gcmh-last-gc-time (gcmh-time (garbage-collect
+(setf gcmh-last-gc-time (gcmh-time (garbage-collect
  (error (message "Garbage collecting...failed")
 (signal (car e) (cdr e)
-(setq gcmh-last-gc-time (gcmh-time (garbage-collect
-  (setq gc-cons-threshold gcmh-low-cons-threshold))
+(setf gcmh-last-gc-time (gcmh-time (garbage-collect
+  (setf gc-cons-threshold gcmh-low-cons-threshold))
 
 ;;;###autoload
 (define-minor-mode gcmh-mode
@@ -122,7 +122,7 @@ Cancel the previous one if present."
;; Release severe GC strategy before the user restart to working
(add-hook 'pre-command-hook #'gcmh-set-high-threshold)
(add-hook 'post-command-hook #'gcmh-register-idle-timer))
-(setq gc-cons-threshold gcmh-low-cons-threshold
+(setf gc-cons-threshold gcmh-low-cons-threshold
   gcmh-idle-timer nil)
 (remove-hook 'pre-command-hook #'gcmh-set-high-threshold)
 (remove-hook 'post-command-hook #'gcmh-register-idle-timer)))



[elpa] externals/gcmh 81844fa 09/32: update readme

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 81844fa43b9af8cc0882f8cd25f6bbfd5bb390c7
Author: Andrea Corallo 
Commit: Andrea Corallo 

update readme
---
 README.org | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.org b/README.org
index e522e55..15030b3 100644
--- a/README.org
+++ b/README.org
@@ -1,3 +1,5 @@
+[[License: GPL v3][https://img.shields.io/badge/License-GPL%20v3-blue.svg]]
+[[https://melpa.org/#/gcmh][file:https://melpa.org/packages/gcmh-badge.svg]]
 * GCMH - the Garbage Collector Magic Hack
 
   Enforce a sneaky Garbage Collection strategy to minimize GC interference with



[elpa] externals/gcmh 8008009 03/32: some minor fixes

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 80080093c786805b91d6f0766f5754d3f72cd65c
Author: Andrea Corallo 
Commit: Andrea Corallo 

some minor fixes
---
 gcmh.el | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index 69daea1..041208e 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -6,8 +6,8 @@
 ;; Package: gcmh
 ;; Homepage: https://gitlab.com/koral/gcmh
 ;; Version: 0.1
-;; Package-Requires:
-;; Keywords: garbage collector, garbage collection
+;; Package-Requires: ((emacs "24"))
+;; Keywords: internal
 
 ;; This file is not part of GNU Emacs.
 
@@ -25,7 +25,7 @@
 ;; along with GNU Emacs.  If not, see .
 
 ;;; Commentary:
-;; Enforce an optimized Garbage Collection strategy to minimize GC
+;; Enforce an optimized sneaky Garbage Collection strategy to minimize GC
 ;; interference with the user activity.
 ;; A more detailed explanation of the rationale behind this can be found at
 ;; http://akrl.sdf.org/
@@ -46,6 +46,11 @@ paging."
   :group 'gcmh
   :type 'number)
 
+(defcustom gcmh-time-constant 15
+  "Idle time to wait in seconds before triggering GC."
+  :group 'gcmh
+  :type 'number)
+
 (defcustom gcmh-verbose nil
   "If t print a message into when garbage collecting."
   :group 'gcmh
@@ -65,10 +70,10 @@ paging."
 This is to be used with the `pre-command-hook'."
   (setq gc-cons-threshold gcmh-high-cons-threshold))
 
-;;;###autoload
 (define-minor-mode gcmh-mode
   "Minor mode tweak Garbage Colelction strategy."
   :lighter " GCMH"
+  :require 'gcmh
   :global t
   (cond
(gcmh-mode
@@ -79,13 +84,14 @@ This is to be used with the `pre-command-hook'."
   ;; When idle for 15sec run the GC no matter what.
   (unless gcmh-timer
(setq gcmh-timer
- (run-with-idle-timer 15 t
+ (run-with-idle-timer gcmh-time-constant t
   (lambda ()
 (if gcmh-verbose
 (message "Garbage Collector has run 
for %.06fsec"
  (gcmh-time (garbage-collect)))
   (garbage-collect))
 (setq gc-cons-threshold 
gcmh-low-cons-threshold)
+  ;; Release severe GC strategy before the user restart to working
   (add-hook 'pre-command-hook #'gcmh-set-high-threshold)))
(t (progn
(setq gc-cons-threshold gcmh-low-cons-threshold)



[elpa] externals/gcmh 5a83e25 32/32: Bump version 0.2

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 5a83e257b5f00ef5a1e04fb6734d4d0490bb35b0
Author: Andrea Corallo 
Commit: Andrea Corallo 

Bump version 0.2
---
 gcmh.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcmh.el b/gcmh.el
index 590a5d6..12418e2 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -5,7 +5,7 @@
 ;; Maintainer: a...@sdf.org
 ;; Package: gcmh
 ;; Homepage: https://gitlab.com/koral/gcmh
-;; Version: 0.1
+;; Version: 0.2
 ;; Package-Requires: ((emacs "24"))
 ;; Keywords: internal
 



[elpa] externals/gcmh 855f03e 25/32: Implement auto idle delay mode

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 855f03edf921aabc5822f9941a6e939a84bb3c6a
Author: Andrea Corallo 
Commit: Andrea Corallo 

Implement auto idle delay mode
---
 gcmh.el | 28 +---
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index c81e698..6c32281 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -49,7 +49,15 @@ cause OS paging."
   :type 'number)
 
 (defcustom gcmh-idle-delay 15
-  "Idle time to wait in seconds before triggering GC."
+  "Idle time to wait in seconds before triggering GC.
+If `auto' this is auto computed based on `gcmh-auto-idle-delay-factor'."
+  :group 'gcmh
+  :type '(choice number (const auto)))
+
+(defcustom gcmh-auto-idle-delay-factor 10
+  "Factor to compute the idle delay when in idle-delay auto mode.
+The idle delay will be `gcmh-auto-idle-delay-factor' times the
+time the last non idle garbage collection time."
   :group 'gcmh
   :type 'number)
 
@@ -72,13 +80,19 @@ cause OS paging."
 This is to be used with the `pre-command-hook'."
   (setq gc-cons-threshold gcmh-high-cons-threshold))
 
+(defvar gcmh-last-gc-time 0.1
+  "How long it took to perform the last garbage collection.")
+
 (defun gcmh-register-idle-timer ()
   "Register a timer to run `gcmh-idle-garbage-collect'.
 Cancel the previous one if present."
-  (when (timerp gcmh-idle-timer)
-(cancel-timer gcmh-idle-timer))
-  (setf gcmh-idle-timer
-   (run-with-idle-timer gcmh-idle-delay nil #'gcmh-idle-garbage-collect)))
+  (let ((idle-t (if (eq gcmh-idle-delay 'auto)
+   (* gcmh-auto-idle-delay-factor gcmh-last-gc-time)
+ gcmh-idle-delay)))
+(when (timerp gcmh-idle-timer)
+  (cancel-timer gcmh-idle-timer))
+(setf gcmh-idle-timer
+ (run-with-idle-timer idle-t nil #'gcmh-idle-garbage-collect
 
 (defun gcmh-idle-garbage-collect ()
   "Run garbage collection after `gcmh-idle-delay'."
@@ -87,10 +101,10 @@ Cancel the previous one if present."
(message "Garbage collecting...")
(condition-case-unless-debug e
(message "Garbage collecting...done (%.3fs)"
-(gcmh-time (garbage-collect)))
+(setq gcmh-last-gc-time (gcmh-time (garbage-collect
  (error (message "Garbage collecting...failed")
 (signal (car e) (cdr e)
-(garbage-collect))
+(setq gcmh-last-gc-time (gcmh-time (garbage-collect
   (setq gc-cons-threshold gcmh-low-cons-threshold))
 
 ;;;###autoload



[elpa] externals/gcmh f542908 19/32: Merge branch 'feature/prevent-duplicate-timers' into 'master'

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit f542908b9ae4405d70fa70f42bd62618c5de4b95
Merge: 1953d91 537d050
Author: Koral 
Commit: Koral 

Merge branch 'feature/prevent-duplicate-timers' into 'master'

Feature/prevent duplicate timers

See merge request koral/gcmh!2
---
 gcmh.el | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index d2eae63..bbccbc9 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -35,16 +35,16 @@
 ;;; Code:
 
 (defcustom gcmh-low-cons-threshold 80
-  "Low cons gc threshold.
-This is the gc threshold used while while idling. Default value
-is the same of `gc-cons-threshold' default"
+  "Low cons GC threshold.
+This is the GC threshold used while idling. Default value is the
+same of `gc-cons-threshold' default."
   :group 'gcmh
   :type 'number)
 
 (defcustom gcmh-high-cons-threshold #x4000
-  "High cons gc threshold.
+  "High cons GC threshold.
 This should be set to a value that makes GC unlikely but does not
-make the OS paging."
+cause OS paging."
   :group 'gcmh
   :type 'number)
 
@@ -59,7 +59,7 @@ make the OS paging."
   :type 'boolean)
 
 (defvar gcmh-idle-timer nil
-  "Idle timer for trigering GC.")
+  "Idle timer for triggering GC.")
 
 (defmacro gcmh-time (&rest body)
   "Measure and return the time it takes to evaluate BODY."
@@ -68,7 +68,7 @@ make the OS paging."
  (float-time (time-since time
 
 (defun gcmh-set-high-threshold ()
-  "Set the high gc thereshold.
+  "Set the high GC threshold.
 This is to be used with the `pre-command-hook'."
   (setq gc-cons-threshold gcmh-high-cons-threshold))
 
@@ -86,6 +86,10 @@ This is to be used with the `pre-command-hook'."
   "Minor mode to tweak Garbage Collection strategy."
   :lighter " GCMH"
   :global t
+
+  ;; Cancel any pending timer (prevents duplicate idle timers).
+  (when (timerp gcmh-idle-timer)
+(cancel-timer gcmh-idle-timer))
   (if gcmh-mode
   (progn
 (setq  gc-cons-threshold gcmh-high-cons-threshold
@@ -94,7 +98,6 @@ This is to be used with the `pre-command-hook'."
 
#'gcmh-idle-garbage-collect))
 ;; Release severe GC strategy before the user restart to working
 (add-hook 'pre-command-hook #'gcmh-set-high-threshold))
-(cancel-timer gcmh-idle-timer)
 (setq gc-cons-threshold gcmh-low-cons-threshold
   gcmh-idle-timer nil)
 (remove-hook 'pre-command-hook #'gcmh-set-high-threshold)))



[elpa] externals/gcmh 920bc52 05/32: better comments

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 920bc52b0e09d419de70ba6d0c836b431f668288
Author: Andrea Corallo 
Commit: Andrea Corallo 

better comments
---
 gcmh.el | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index 69c20e3..5ebe3d4 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -25,8 +25,10 @@
 ;; along with GNU Emacs.  If not, see .
 
 ;;; Commentary:
-;; Enforce an optimized sneaky Garbage Collection strategy to minimize GC
-;; interference with the user activity.
+;; Enforce a sneaky Garbage Collection strategy to minimize GC interference 
with
+;; the activity.
+;; During normal use a high GC threshold is set.
+;; When idling GC is immediately triggered and a low threshold is set.
 ;; A more detailed explanation of the rationale behind this can be found at
 ;; http://akrl.sdf.org/
 
@@ -37,10 +39,10 @@
 (require 'timer)
 (require 'easy-mmode)
 
-(defcustom gcmh-low-cons-threshold gc-cons-threshold
+(defcustom gcmh-low-cons-threshold 80
   "High cons gc threshold.
-This is the gc threshold used while in idle.  Default value is \
-`gc-cons-threshold'"
+This is the gc threshold used while while idling.  Default value is \
+the same of `gc-cons-threshold' default"
   :group 'gcmh
   :type 'number)
 
@@ -57,7 +59,7 @@ paging."
   :type 'number)
 
 (defcustom gcmh-verbose nil
-  "If t print a message into when garbage collecting."
+  "If t print a message when garbage collecting."
   :group 'gcmh
   :type 'boolean)
 



[elpa] externals/gcmh c96bd70 12/32: update readme

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit c96bd7063a324bb042cb6baf705c0b7d3b02ce2a
Author: Andrea Corallo 
Commit: Andrea Corallo 

update readme
---
 README.org | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.org b/README.org
index dd53364..d78ef58 100644
--- a/README.org
+++ b/README.org
@@ -13,7 +13,7 @@
 
   [[http://akrl.sdf.org/]]
 
-*** WARNING
+  - WARNING
 
 In case Emacs is used in a system already under severe memory pressure
 be sure to understand how GCMH works and trim ~gcmh-high-cons-threshold~



[elpa] externals/gcmh f449abb 27/32: No reason anymore to use `run-with-idle-timer' so use `run-with-timer'

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit f449abb5629f28155dd87aff4b8708c01f92e00e
Author: Andrea Corallo 
Commit: Andrea Corallo 

No reason anymore to use `run-with-idle-timer' so use `run-with-timer'
---
 gcmh.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcmh.el b/gcmh.el
index 99227b5..fedea6d 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -92,7 +92,7 @@ Cancel the previous one if present."
 (when (timerp gcmh-idle-timer)
   (cancel-timer gcmh-idle-timer))
 (setf gcmh-idle-timer
- (run-with-idle-timer idle-t nil #'gcmh-idle-garbage-collect
+ (run-with-timer idle-t nil #'gcmh-idle-garbage-collect
 
 (defun gcmh-idle-garbage-collect ()
   "Run garbage collection after `gcmh-idle-delay'."



[elpa] externals/gcmh 12fd03c 24/32: Set the new timer for running once and on post-command-hook

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 12fd03c7c0915b2ae470e77e6600ad04f7f67dde
Author: Andrea Corallo 
Commit: Andrea Corallo 

Set the new timer for running once and on post-command-hook
---
 gcmh.el | 21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index dd9f2a6..c81e698 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -72,6 +72,14 @@ cause OS paging."
 This is to be used with the `pre-command-hook'."
   (setq gc-cons-threshold gcmh-high-cons-threshold))
 
+(defun gcmh-register-idle-timer ()
+  "Register a timer to run `gcmh-idle-garbage-collect'.
+Cancel the previous one if present."
+  (when (timerp gcmh-idle-timer)
+(cancel-timer gcmh-idle-timer))
+  (setf gcmh-idle-timer
+   (run-with-idle-timer gcmh-idle-delay nil #'gcmh-idle-garbage-collect)))
+
 (defun gcmh-idle-garbage-collect ()
   "Run garbage collection after `gcmh-idle-delay'."
   (if gcmh-verbose
@@ -96,15 +104,14 @@ This is to be used with the `pre-command-hook'."
 (cancel-timer gcmh-idle-timer))
   (if gcmh-mode
   (progn
-(setq  gc-cons-threshold gcmh-high-cons-threshold
-   ;; When idle for gcmh-idle-delay, run the GC no matter what.
-   gcmh-idle-timer (run-with-idle-timer gcmh-idle-delay t
-
#'gcmh-idle-garbage-collect))
-;; Release severe GC strategy before the user restart to working
-(add-hook 'pre-command-hook #'gcmh-set-high-threshold))
+(setf gc-cons-threshold gcmh-high-cons-threshold)
+   ;; Release severe GC strategy before the user restart to working
+   (add-hook 'pre-command-hook #'gcmh-set-high-threshold)
+   (add-hook 'post-command-hook #'gcmh-register-idle-timer))
 (setq gc-cons-threshold gcmh-low-cons-threshold
   gcmh-idle-timer nil)
-(remove-hook 'pre-command-hook #'gcmh-set-high-threshold)))
+(remove-hook 'pre-command-hook #'gcmh-set-high-threshold)
+(remove-hook 'post-command-hook #'gcmh-register-idle-timer)))
 
 (provide 'gcmh)
 



[elpa] externals/gcmh c1bc27a 06/32: Add readme

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit c1bc27aead05fda40bfe5d2959d29ccbcb7d92fd
Author: Andrea Corallo 
Commit: Andrea Corallo 

Add readme
---
 README.org | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/README.org b/README.org
new file mode 100644
index 000..e522e55
--- /dev/null
+++ b/README.org
@@ -0,0 +1,22 @@
+* GCMH - the Garbage Collector Magic Hack
+
+  Enforce a sneaky Garbage Collection strategy to minimize GC interference with
+  the activity.
+  During normal use a high GC threshold is set.
+  When idling GC is immediately triggered and a low threshold is set.
+  A more detailed explanation of the rationale behind this can be found at:
+
+  [[http://akrl.sdf.org/]]
+
+** Usage
+
+   Add into your .emacs
+
+   #+BEGIN_SRC
+(add-to-list 'load-path "path-to-gcmh-here")
+(require 'gcmh)
+(gcmh-mode 1)
+   #+END_SRC
+
+   If this is done at the beginning of your .emacs start-up time should
+   also benefit form it.



[elpa] externals/gcmh 345121d 29/32: Readme update

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 345121d408cec012b642c7c41fcc88074fe58154
Author: Andrea Corallo 
Commit: Andrea Corallo 

Readme update
---
 README.org | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/README.org b/README.org
index 2fe7044..2148a61 100644
--- a/README.org
+++ b/README.org
@@ -3,11 +3,11 @@
 * GCMH - the Garbage Collector Magic Hack
 
   Enforce a sneaky Garbage Collection strategy to minimize GC interference with
-  the activity.
+  user activity.
 
   During normal use a high GC threshold is set.
 
-  When idling GC is immediately triggered and a low threshold is set.
+  When idling GC is triggered and a low threshold is set.
 
   A more detailed explanation of the rationale behind this can be found at:
 
@@ -15,10 +15,10 @@
 
   - WARNING
 
-In case Emacs is used in a system already under severe memory pressure
-be sure to understand how GCMH works and trim ~gcmh-high-cons-threshold~
-accordingly. Default value may be to big and/or GCMH may not fit your use
-case.
+In case Emacs is used in a system already under severe memory
+pressure be sure to understand how GCMH works and trim
+~gcmh-high-cons-threshold~ accordingly.  Default value may be to
+big and/or GCMH may not fit your use case.
 
 ** Usage
 



[elpa] externals/gcmh 84c43a4 23/32: Remove unnecessary require in README

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 84c43a4c0b41a595ac6e299fa317d2831813e580
Author: Andrea Corallo 
Commit: Andrea Corallo 

Remove unnecessary require in README
---
 README.org | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/README.org b/README.org
index d78ef58..2fe7044 100644
--- a/README.org
+++ b/README.org
@@ -25,9 +25,8 @@
Add into your .emacs
 
#+BEGIN_SRC
-(add-to-list 'load-path "path-to-gcmh-here")
-(require 'gcmh)
-(gcmh-mode 1)
+   (add-to-list 'load-path "path-to-gcmh-here")
+   (gcmh-mode 1)
#+END_SRC
 
If this is done at the beginning of your .emacs start-up time should



[elpa] externals/gcmh 72683e1 13/32: Update conventions

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 72683e169beda961628bd00089625e0f26d16390
Author: Troy Hinckley 
Commit: Troy Hinckley 

Update conventions

First removed the unnecessary require statements. Then update some of
the wording to be clearer. Reworked the minor mode to be cleaner and
more consise. Split out the idle timer function to its own definition.
Also removed the setting of garbage-collection-messages. It may not be
desired behavior and does not disable with the minor mode. If the user
wants to set it, they can do so.
---
 gcmh.el | 69 -
 1 file changed, 30 insertions(+), 39 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index 40b70bf..d5762c0 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -34,37 +34,32 @@
 
 ;;; Code:
 
-(require 'custom)
-(require 'message)
-(require 'timer)
-(require 'easy-mmode)
-
 (defcustom gcmh-low-cons-threshold 80
-  "High cons gc threshold.
-This is the gc threshold used while while idling.  Default value is \
-the same of `gc-cons-threshold' default"
+  "Low cons gc threshold.
+This is the gc threshold used while while idling. Default value
+is the same of `gc-cons-threshold' default"
   :group 'gcmh
   :type 'number)
 
 (defcustom gcmh-high-cons-threshold #x4000
   "High cons gc threshold.
-This should be set to a value that makes GC unlikely but does not make the OS \
-paging."
+This should be set to a value that makes GC unlikely but does not
+make the OS paging."
   :group 'gcmh
   :type 'number)
 
-(defcustom gcmh-time-constant 15
+(defcustom gcmh-idle-delay 15
   "Idle time to wait in seconds before triggering GC."
   :group 'gcmh
   :type 'number)
 
 (defcustom gcmh-verbose nil
-  "If t print a message when garbage collecting."
+  "If t, print a message when garbage collecting."
   :group 'gcmh
   :type 'boolean)
 
-(defvar gcmh-timer nil
-  "Idle timer set for trigering GC.")
+(defvar gcmh-idle-timer nil
+  "Idle timer for trigering GC.")
 
 (defmacro gcmh-time (&rest body)
   "Measure and return the time it takes to evaluate BODY."
@@ -77,35 +72,31 @@ paging."
 This is to be used with the `pre-command-hook'."
   (setq gc-cons-threshold gcmh-high-cons-threshold))
 
+(defun gcmh-idle-garbage-collect ()
+  "Run garbage collection after `gcmh-idle-delay'."
+  (if gcmh-verbose
+  (message "Garbage Collector ran for %.06f sec"
+   (gcmh-time (garbage-collect)))
+(garbage-collect))
+  (setq gc-cons-threshold gcmh-low-cons-threshold))
+
 ;;;###autoload
 (define-minor-mode gcmh-mode
-  "Minor mode tweak Garbage Collection strategy."
+  "Minor mode to tweak Garbage Collection strategy."
   :lighter " GCMH"
-  :require 'gcmh
   :global t
-  (cond
-   (gcmh-mode
-(progn
-  (setq gc-cons-threshold gcmh-high-cons-threshold)
-  ;; Print a message when garbage collecting
-  (setq garbage-collection-messages gcmh-verbose)
-  ;; When idle for 15sec run the GC no matter what.
-  (unless gcmh-timer
-   (setq gcmh-timer
- (run-with-idle-timer gcmh-time-constant t
-  (lambda ()
-(if gcmh-verbose
-(message "Garbage Collector has run 
for %.06fsec"
- (gcmh-time (garbage-collect)))
-  (garbage-collect))
-(setq gc-cons-threshold 
gcmh-low-cons-threshold)
-  ;; Release severe GC strategy before the user restart to working
-  (add-hook 'pre-command-hook #'gcmh-set-high-threshold)))
-   (t (progn
-   (setq gc-cons-threshold gcmh-low-cons-threshold)
-   (cancel-timer gcmh-timer)
-   (setq gcmh-timer nil)
-   (remove-hook 'pre-command-hook #'gcmh-set-high-threshold)
+  (if gcmh-mode
+  (progn
+(setq  gc-cons-threshold gcmh-high-cons-threshold
+   ;; When idle for gcmh-idle-delay, run the GC no matter what.
+   gcmh-idle-timer (run-with-idle-timer gcmh-idle-delay t
+
#'gcmh-idle-garbage-collect))
+;; Release severe GC strategy before the user restart to working
+(add-hook 'pre-command-hook #'gcmh-set-high-threshold))
+(cancel-timer gcmh-idle-timer)
+(setq gc-cons-threshold gcmh-low-cons-threshold
+  gcmh-idle-timer nil)
+(remove-hook 'pre-command-hook #'gcmh-set-high-threshold)))
 
 (provide 'gcmh)
 



[elpa] externals/gcmh 04e3c0c 28/32: Set `gcmh-auto-idle-delay-factor' to 20

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 04e3c0c9cf928176ac04a775819883a2921b8001
Author: Andrea Corallo 
Commit: Andrea Corallo 

Set `gcmh-auto-idle-delay-factor' to 20
---
 gcmh.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcmh.el b/gcmh.el
index fedea6d..0a6fac4 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -54,7 +54,7 @@ If `auto' this is auto computed based on 
`gcmh-auto-idle-delay-factor'."
   :group 'gcmh
   :type '(choice number (const auto)))
 
-(defcustom gcmh-auto-idle-delay-factor 10
+(defcustom gcmh-auto-idle-delay-factor 20
   "Factor to compute the idle delay when in idle-delay auto mode.
 The idle delay will be `gcmh-auto-idle-delay-factor' times the
 time the last non idle garbage collection time."



[elpa] externals/gcmh 2827dff 31/32: Clean-up unnecessary logic

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 2827dfff7568786f8055f57a9bbb56d74f126889
Author: Andrea Corallo 
Commit: Andrea Corallo 

Clean-up unnecessary logic
---
 gcmh.el | 4 
 1 file changed, 4 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index e576704..590a5d6 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -112,10 +112,6 @@ Cancel the previous one if present."
   "Minor mode to tweak Garbage Collection strategy."
   :lighter " GCMH"
   :global t
-
-  ;; Cancel any pending timer (prevents duplicate idle timers).
-  (when (timerp gcmh-idle-timer)
-(cancel-timer gcmh-idle-timer))
   (if gcmh-mode
   (progn
 (setf gc-cons-threshold gcmh-high-cons-threshold)



[elpa] externals/gcmh 8bf0666 30/32: Rename `gcmh-register-idle-timer' into `gcmh-register-idle-gc'

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 8bf06660dd3f9ac788e79b26f23f585bd9cccfdc
Author: Andrea Corallo 
Commit: Andrea Corallo 

Rename `gcmh-register-idle-timer' into `gcmh-register-idle-gc'
---
 gcmh.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index 0a6fac4..e576704 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -83,7 +83,7 @@ This is to be used with the `pre-command-hook'."
 (defvar gcmh-last-gc-time 0.1
   "How long it took to perform the last garbage collection.")
 
-(defun gcmh-register-idle-timer ()
+(defun gcmh-register-idle-gc ()
   "Register a timer to run `gcmh-idle-garbage-collect'.
 Cancel the previous one if present."
   (let ((idle-t (if (eq gcmh-idle-delay 'auto)
@@ -121,11 +121,11 @@ Cancel the previous one if present."
 (setf gc-cons-threshold gcmh-high-cons-threshold)
;; Release severe GC strategy before the user restart to working
(add-hook 'pre-command-hook #'gcmh-set-high-threshold)
-   (add-hook 'post-command-hook #'gcmh-register-idle-timer))
+   (add-hook 'post-command-hook #'gcmh-register-idle-gc))
 (setf gc-cons-threshold gcmh-low-cons-threshold
   gcmh-idle-timer nil)
 (remove-hook 'pre-command-hook #'gcmh-set-high-threshold)
-(remove-hook 'post-command-hook #'gcmh-register-idle-timer)))
+(remove-hook 'post-command-hook #'gcmh-register-idle-gc)))
 
 (provide 'gcmh)
 



[elpa] externals/gcmh 8867533 20/32: Improve messaging

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 8867533a736f2098917904c26fd833feca2310a5
Author: Andrea Corallo 
Commit: Andrea Corallo 

Improve messaging
---
 gcmh.el | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index bbccbc9..d78b505 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -75,11 +75,14 @@ This is to be used with the `pre-command-hook'."
 (defun gcmh-idle-garbage-collect ()
   "Run garbage collection after `gcmh-idle-delay'."
   (if gcmh-verbose
-  (progn (message "Garbage collecting...")
- (message "Garbage Collector ran for %.06f sec"
-  (gcmh-time (garbage-collect
-(garbage-collect))
-  (setq gc-cons-threshold gcmh-low-cons-threshold))
+  (progn
+   (message "Garbage collecting...")
+   (condition-case-unless-debug e
+   (message "Garbage collecting...done (%.3fs)"
+(gcmh-time (garbage-collect)))
+ (error (message "Garbage collecting...failed")
+(signal (car e) (cdr e)
+(garbage-collect)))
 
 ;;;###autoload
 (define-minor-mode gcmh-mode



[elpa] master f22e27d: * externals-list: New package GCMH

2020-11-16 Thread Andrea Corallo
branch: master
commit f22e27d65320112cf11504363b12106966257564
Author: Andrea Corallo 
Commit: Andrea Corallo 

* externals-list: New package GCMH
---
 externals-list | 1 +
 1 file changed, 1 insertion(+)

diff --git a/externals-list b/externals-list
index 5e2879a..bc5a5c5 100644
--- a/externals-list
+++ b/externals-list
@@ -91,6 +91,7 @@
  ("f90-interface-browser" :subtree "https://github.com/wence-/f90-iface";)
  ("flymake":core "lisp/progmodes/flymake.el")
  ("frog-menu"  :external "https://github.com/clemera/frog-menu";)
+ ("gcmh"   :external "https://gitlab.com/koral/gcmh";)
  ("ggtags" :subtree "https://github.com/leoliu/ggtags";)
  ("gnome-c-style"  :subtree "https://github.com/ueno/gnome-c-style.git";)
  ("gnorb"   :subtree "https://github.com/girzel/gnorb";)



[elpa] externals/gcmh 69e86da: * gcmh.el: Fix copyright notice

2020-11-16 Thread Stefan Monnier
branch: externals/gcmh
commit 69e86daf0bafe89856d6258bbb747ce74e0f1239
Author: Stefan Monnier 
Commit: Stefan Monnier 

* gcmh.el: Fix copyright notice

(gcmh): New group (previously referenced but not defined).
Remove now redundant references to this group.
---
 gcmh.el | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index 12418e2..ca18772 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -1,6 +1,6 @@
 ;;; gcmh.el --- the Garbage Collector Magic Hack -*- lexical-binding:t -*-
 
-;; Copyright (C) 2019-2020 Andrea Corallo
+;; Copyright (C) 2019-2020  Free Software Foundation, Inc.
 
 ;; Maintainer: a...@sdf.org
 ;; Package: gcmh
@@ -34,36 +34,35 @@
 
 ;;; Code:
 
+(defgroup gcmh nil
+  "Garbage Collector Magic Hack."
+  :group 'alloc)
+
 (defcustom gcmh-low-cons-threshold 80
   "Low cons GC threshold.
 This is the GC threshold used while idling. Default value is the
 same of `gc-cons-threshold' default."
-  :group 'gcmh
   :type 'number)
 
 (defcustom gcmh-high-cons-threshold #x4000
   "High cons GC threshold.
 This should be set to a value that makes GC unlikely but does not
 cause OS paging."
-  :group 'gcmh
   :type 'number)
 
 (defcustom gcmh-idle-delay 15
   "Idle time to wait in seconds before triggering GC.
 If `auto' this is auto computed based on `gcmh-auto-idle-delay-factor'."
-  :group 'gcmh
   :type '(choice number (const auto)))
 
 (defcustom gcmh-auto-idle-delay-factor 20
   "Factor to compute the idle delay when in idle-delay auto mode.
 The idle delay will be `gcmh-auto-idle-delay-factor' times the
 time the last non idle garbage collection time."
-  :group 'gcmh
   :type 'number)
 
 (defcustom gcmh-verbose nil
   "If t, print a message when garbage collecting."
-  :group 'gcmh
   :type 'boolean)
 
 (defvar gcmh-idle-timer nil



[elpa] externals/gcmh 0089f9c: * gcmh.el: Update copyright and header section

2020-11-16 Thread Andrea Corallo
branch: externals/gcmh
commit 0089f9c3a6d4e9a310d0791cf6fa8f35642ecfd9
Author: Andrea Corallo 
Commit: Andrea Corallo 

* gcmh.el: Update copyright and header section
---
 gcmh.el | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/gcmh.el b/gcmh.el
index ca18772..c2b78b2 100644
--- a/gcmh.el
+++ b/gcmh.el
@@ -2,33 +2,32 @@
 
 ;; Copyright (C) 2019-2020  Free Software Foundation, Inc.
 
+;; Author: Andrea Corallo 
 ;; Maintainer: a...@sdf.org
 ;; Package: gcmh
 ;; Homepage: https://gitlab.com/koral/gcmh
-;; Version: 0.2
+;; Version: 0.2.1
 ;; Package-Requires: ((emacs "24"))
 ;; Keywords: internal
 
-;; This file is not part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
+;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
 ;; (at your option) any later version.
 
-;; GNU Emacs is distributed in the hope that it will be useful,
+;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see .
+;; along with this program.  If not, see .
 
 ;;; Commentary:
 ;; Enforce a sneaky Garbage Collection strategy to minimize GC interference 
with
 ;; the activity.
 ;; During normal use a high GC threshold is set.
-;; When idling GC is immediately triggered and a low threshold is set.
+;; When idling GC is triggered and a low threshold is set.
 ;; A more detailed explanation of the rationale behind this can be found at
 ;; http://akrl.sdf.org/