summaryrefslogtreecommitdiff
path: root/elpa/req-package-20180605.1141/req-package-cycles.el
diff options
context:
space:
mode:
authormattkae <mattkae@protonmail.com>2022-05-11 09:23:58 -0400
committermattkae <mattkae@protonmail.com>2022-05-11 09:23:58 -0400
commit3f4a0d5370ae6c34afe180df96add3b8522f4af1 (patch)
treeae901409e02bde8ee278475f8cf6818f8f680a60 /elpa/req-package-20180605.1141/req-package-cycles.el
initial commit
Diffstat (limited to 'elpa/req-package-20180605.1141/req-package-cycles.el')
-rw-r--r--elpa/req-package-20180605.1141/req-package-cycles.el35
1 files changed, 35 insertions, 0 deletions
diff --git a/elpa/req-package-20180605.1141/req-package-cycles.el b/elpa/req-package-20180605.1141/req-package-cycles.el
new file mode 100644
index 0000000..73d982e
--- /dev/null
+++ b/elpa/req-package-20180605.1141/req-package-cycles.el
@@ -0,0 +1,35 @@
+;;; req-package-cycles.el --- summary:
+;;; commentary:
+;;; code:
+
+(require 'dash)
+
+(defvar req-package-cycles-count 0
+ "Number of cycles detected.")
+
+(defun req-package-cycles-detect-traverse-impl (graph visited cur path)
+ "Traverse for cycles look up implementation"
+ (puthash cur t visited)
+ (if (not (-contains? path cur))
+ (-each (gethash cur graph nil)
+ (lambda (dependent)
+ (req-package-cycles-detect-traverse-impl graph visited dependent (cons cur path))))
+ (progn (setq req-package-cycles-count (+ req-package-cycles-count 1))
+ (req-package--log-error "cycle detected: %s" (cons cur path)))))
+
+(defun req-package-cycles-detect-traverse (graph visited)
+ "Traverse for cycles look up"
+ (maphash (lambda (key value)
+ (if (null (gethash key visited nil))
+ (req-package-cycles-detect-traverse-impl graph visited key nil)))
+ graph)
+ (if (not (eq 0 req-package-cycles-count))
+ (message "%s cycle(s) detected. see M-x req-package--log-open-log"
+ req-package-cycles-count)))
+
+(defun req-package-cycles-detect (graph)
+ (setq req-package-cycles-count 0)
+ (req-package-cycles-detect-traverse graph (make-hash-table :size 200)))
+
+(provide 'req-package-cycles)
+;;; req-package-cycles ends here