From 6dee778a079b7b7bdaf39a549327e54cdac55ef7 Mon Sep 17 00:00:00 2001 From: Constantine Vetoshev Date: Sat, 25 May 2019 07:59:47 -0700 Subject: [PATCH 1/3] Fix errors resulting from uninitialized frames. These occur when persp-mode is active, but a frame is created with after-make-frame-functions bypassed (i.e., let-bound to nil), resulting in frames without frame parameters which persp-mode expects. Since most of these errors occur in unguarded use of perspectives-hash, persp-curr, and persp-last, this workaround tries to return reasonable but empty values from these functions instead of nil. --- perspective.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/perspective.el b/perspective.el index b8a0708..24a3f71 100644 --- a/perspective.el +++ b/perspective.el @@ -212,17 +212,20 @@ all but one of their points will be overwritten. LOCAL-VARIABLES is an alist from variable names to their perspective-local values." - (frame-parameter frame 'persp--hash)) + (or (frame-parameter frame 'persp--hash) + (make-hash-table))) (defun persp-curr (&optional frame) "Get the current perspective in FRAME. FRAME defaults to the currently selected frame." - (frame-parameter frame 'persp--curr)) + (or (frame-parameter frame 'persp--curr) + (make-persp-internal))) (defun persp-last (&optional frame) "Get the last active perspective in FRAME. FRAME defaults to the currently selected frame." - (frame-parameter frame 'persp--last)) + (or (frame-parameter frame 'persp--last) + (make-persp-internal))) (defun persp-mode-set-prefix-key (newkey) "Set the prefix key to activate persp-mode" From 43e0d58333f09ac622720b7a12c2b7d00d61e124 Mon Sep 17 00:00:00 2001 From: Constantine Vetoshev Date: Tue, 9 Jul 2019 10:28:49 -0400 Subject: [PATCH 2/3] Fix two more spots which assume 'persp--hash exists on all frames. --- perspective.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/perspective.el b/perspective.el index 24a3f71..9f3f375 100644 --- a/perspective.el +++ b/perspective.el @@ -611,7 +611,7 @@ perspective that has the buffer. Prefers perspectives in the selected frame." (cl-loop for frame in (sort (frame-list) (lambda (frame1 frame2) (eq frame2 (selected-frame)))) - do (cl-loop for persp being the hash-values of (frame-parameter frame 'persp--hash) + do (cl-loop for persp being the hash-values of (perspectives-hash frame) if (and (not (and (equal frame (selected-frame)) (equal (persp-name persp) (persp-name (persp-curr frame))))) (memq buffer (persp-buffers persp))) @@ -917,7 +917,7 @@ from the current perspective at time of creation." (unless (assq variable (persp-local-variables (persp-curr))) (let ((entry (list variable (symbol-value variable)))) (dolist (frame (frame-list)) - (cl-loop for persp being the hash-values of (frame-parameter frame 'persp--hash) + (cl-loop for persp being the hash-values of (perspectives-hash frame) do (push entry (persp-local-variables persp))))))) (defmacro persp-setup-for (name &rest body) From abf4052455148b9d010d22582013817d83e90419 Mon Sep 17 00:00:00 2001 From: Constantine Vetoshev Date: Tue, 22 Oct 2019 14:08:24 -0700 Subject: [PATCH 3/3] Allow persp-last to return nil again. Write clarifying comments. --- perspective.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/perspective.el b/perspective.el index 9f3f375..90fa621 100644 --- a/perspective.el +++ b/perspective.el @@ -212,20 +212,26 @@ all but one of their points will be overwritten. LOCAL-VARIABLES is an alist from variable names to their perspective-local values." + ;; XXX: This must return a non-nil value to avoid breaking frames initialized + ;; with after-make-frame-functions bound to nil. (or (frame-parameter frame 'persp--hash) (make-hash-table))) (defun persp-curr (&optional frame) "Get the current perspective in FRAME. FRAME defaults to the currently selected frame." + ;; XXX: This must return a non-nil value to avoid breaking frames initialized + ;; with after-make-frame-functions bound to nil. (or (frame-parameter frame 'persp--curr) (make-persp-internal))) (defun persp-last (&optional frame) "Get the last active perspective in FRAME. FRAME defaults to the currently selected frame." - (or (frame-parameter frame 'persp--last) - (make-persp-internal))) + ;; XXX: Unlike persp-curr, it is unsafe to return a default value of + ;; (make-persp-internal) here, since some code assumes (persp-last) can return + ;; nil. + (frame-parameter frame 'persp--last)) (defun persp-mode-set-prefix-key (newkey) "Set the prefix key to activate persp-mode"