summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Abrahams <dave@boostpro.com>2014-12-19 16:29:35 -0800
committerDave Abrahams <dave@boostpro.com>2014-12-19 16:29:35 -0800
commitec1d659a8121e874bcc87a2a5e5c3f68f24e5f68 (patch)
treea30b16406d11f7448f99398d2a8194599aad2792
parent401a0c7d00c1cac4d0d7d4ecd3fbf003cfe7f18c (diff)
Resilience against recursive customization groups
I’m seeing this group cycle: (magit-popups magit-popup convenience emacs), which was causing an infinite recursion.
-rw-r--r--initsplit.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/initsplit.el b/initsplit.el
index 9e45b84..aea6002 100644
--- a/initsplit.el
+++ b/initsplit.el
@@ -221,17 +221,22 @@ of the filename as with `load-library'."
(initsplit-strip-lisp-suffix
(initsplit-filename filespec))))
-(defun initsplit-find-option-match (pattern options)
+(defun initsplit-find-option-match (pattern options &optional visited)
"Where OPTIONS are an alist as accepted by
`custom-buffer-create', return nil unless they specify
-customization of a symbol whose name matches PATTERN."
+customization of a symbol whose name matches PATTERN. The
+optional VISITED parameter is for internal use only and should
+always be nil when this function is not called recursively."
(find-if
(lambda (option)
- (if (eq (cadr option) 'custom-group)
- (initsplit-find-option-match pattern (custom-group-members (car option) nil))
- (string-match pattern (symbol-name (car option)))))
+ (let ((x (car option)))
+ (if (eq (cadr option) 'custom-group)
+ (if (memq x visited)
+ (message "group cycle: %s" visited)
+ (initsplit-find-option-match pattern (custom-group-members x nil) (cons x visited)))
+ (string-match pattern (symbol-name x)))))
options))
-
+
(defadvice custom-buffer-create-internal
(before initsplit-custom-buffer-create-internal
(options &optional description) activate compile preactivate)