With treemacs open, running helm-find-files, C-l (which is part of normal navigation for helm-find-files in spacemacs, it enters directories and previews files) doesn't work. Instead, it prints the following error message:
Cannot split side window or parent of side window.
Let me know if you can reproduce this, and what other information would be useful.
My treemacs is 20180608.311, and my helm is 20180607.420, running on emacs 26.1.
Well that's really not supposed to happen. I specifically went out of my way a long time ago to make treemacs not a side window to prevent just this, except back then it was about shell-pop instead of helm.
Treemacs sets up its window using the following code in treemacs--setup-buffer:
(-> (selected-window)
(frame-root-window)
(split-window nil treemacs-position)
(select-window))
(let ((buf (treemacs--get-framelocal-buffer)))
(switch-to-buffer buf))
(treemacs--forget-last-highlight)
(set-window-dedicated-p (selected-window) t)
(let ((window-size-fixed))
(treemacs--set-width treemacs-width))
I am not using display-buffer-in-side-window, so treemacs should not be an actual side window. You can verify this by running (--when-let (treemacs--is-visible?) (message "%s" (window-parameters it))).
The resulting output should not contain window-slot and window-side parameters. If it does we need to look for the culprit elsewhere.
I also tried splitting treemacs myself. split-below works fine, split-right does produce the error for me as well. If that is also what's causing your issues then helm's choice to split treemacs would still be completely wrong, even if it did work. You really don't want to further split a window that's perpetually 35 characters wide by default.
Try producing a stacktrace and check whether the error is produced by split-window-right or split-window _ _ t
If helm's window choice is the culprit maybe there is a helm setting to make its preview reuse windows instead of splitting them (or otherwise control helm's preview-window selection)? Since the treemacs window is strongly dedicated to its buffer helm would then need to find another window to use.
The output of running the --when-let form that you gave me is ((window-side)). I'm not sure if that counts as containing a window-side parameter?
Also, I turned on debug mode and triggered the error, this is what I see:
Debugger entered--Lisp error: (error "Cannot split side window or parent of side window")
signal(error ("Cannot split side window or parent of side window"))
error("Cannot split side window or parent of side window")
split-window()
helm-persistent-action-display-window(nil)
helm-select-persistent-action-window()
helm-execute-persistent-action()
funcall-interactively(helm-execute-persistent-action)
call-interactively(helm-execute-persistent-action nil nil)
command-execute(helm-execute-persistent-action)
read-from-minibuffer("Find files or url: " "/n/nvme/nir/config/spacemacs.d/" (keymap (67108923 . ace-jump-helm-line) (tab . helm-execute-persistent-action) (33554440 . describe-key) (33554443 . helm-follow-action-backward) (33554442 . helm-follow-action-forward) (17 . ace-jump-helm-line) (insert-state keymap (26 . helm-select-action) "Auxiliary keymap for Insert state" (11 . helm-previous-line)) (f13 lambda nil (interactive) (helm-select-nth-action 12)) (f12 lambda nil (interactive) (helm-select-nth-action 11)) (f11 lambda nil (interactive) (helm-select-nth-action 10)) (f10 lambda nil (interactive) (helm-select-nth-action 9)) (f9 lambda nil (interactive) (helm-select-nth-action 8)) (f8 lambda nil (interactive) (helm-select-nth-action 7)) (f7 lambda nil (interactive) (helm-select-nth-action 6)) (f6 lambda nil (interactive) (helm-select-nth-action 5)) (f5 lambda nil (interactive) (helm-select-nth-action 4)) (f4 lambda nil (interactive) (helm-select-nth-action 3)) (f3 lambda nil (interactive) (helm-select-nth-action 2)) (f2 lambda nil (interactive) (helm-select-nth-action 1)) (menu-bar keymap (help-menu keymap (describe keymap (describe-mode . helm-help)))) (help keymap (109 . helm-help)) (23 . #f(compiled-function () (interactive nil) #<bytecode 0x1f05fa5>)) (f1 lambda nil (interactive) (helm-select-nth-action 0)) (8 . helm-next-source) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap (57 . helm-execute-selection-action-at-nth-+9) (56 . helm-execute-selection-action-at-nth-+8) (55 . helm-execute-selection-action-at-nth-+7) (54 . helm-execute-selection-action-at-nth-+6) (53 . helm-execute-selection-action-at-nth-+5) (52 . helm-execute-selection-action-at-nth-+4) (51 . helm-execute-selection-action-at-nth-+3) (50 . helm-execute-selection-action-at-nth-+2) (49 . helm-execute-selection-action-at-nth-+1) (63 . helm-help) (110 . #f(compiled-function () (interactive nil) #<bytecode 0x1f05f51>)) (62 . helm-toggle-truncate-line) (21 . helm-refresh) (6 . helm-follow-mode) (9 . helm-copy-to-buffer) (11 . helm-kill-selection-and-quit) (25 . helm-yank-selection) (37 . helm-exchange-minibuffer-and-header-line) (95 . helm-toggle-full-frame) (45 . helm-swap-windows)) (67108987 . helm-enlarge-window) (67108989 . helm-narrow-window) (19 . undefined) (24 keymap (57 . helm-execute-selection-action-at-nth-+9) (56 . helm-execute-selection-action-at-nth-+8) (55 . helm-execute-selection-action-at-nth-+7) (54 . helm-execute-selection-action-at-nth-+6) (53 . helm-execute-selection-action-at-nth-+5) (52 . helm-execute-selection-action-at-nth-+4) (51 . helm-execute-selection-action-at-nth-+3) (50 . helm-execute-selection-action-at-nth-+2) (49 . helm-execute-selection-action-at-nth-+1) (2 . helm-resume-list-buffers-after-quit) (98 . helm-resume-previous-session-after-quit) (6 . helm-quit-and-find-file)) (11 . helm-previous-line) (67108896 . helm-toggle-visible-mark) (0 . helm-toggle-visible-mark) (C-M-up . helm-scroll-other-window-down) (C-M-down . helm-scroll-other-window) (M-prior . helm-scroll-other-window-down) (M-next . helm-scroll-other-window) (12 . "\015") (15 . helm-next-source) (10 . helm-next-line) (26 . helm-select-action) (9 . helm-execute-persistent-action) (13 . helm-maybe-exit-minibuffer) (left . helm-previous-source) (right . helm-next-source) (7 . helm-keyboard-quit) (22 . helm-next-page) (27 keymap (8388640 . spacemacs/helm-navigation-transient-state/body) (110 . next-history-element) (112 . previous-history-element) (115 . undefined) (5 . helm-display-all-sources) (1 . helm-show-all-in-this-source-only) (85 . helm-unmark-all) (97 . helm-mark-all) (109 . helm-toggle-all-marks) (41 . helm-next-visible-mark) (40 . helm-prev-visible-mark) (91) (32 . spacemacs/helm-navigation-transient-state/body) (33554454 . helm-scroll-other-window-down) (25 . helm-scroll-other-window-down) (22 . helm-scroll-other-window) (12 . helm-reposition-window-other-window) (111 . helm-previous-source) (62 . helm-end-of-buffer) (60 . helm-beginning-of-buffer) (118 . helm-previous-page)) (next . helm-next-page) (prior . helm-previous-page) (C-up . helm-follow-action-backward) (C-down . helm-follow-action-forward) (16 . helm-previous-line) (14 . helm-next-line) (up . helm-previous-line) (down . helm-next-line) keymap (escape . keyboard-escape-quit) (3 keymap (12 . helm-minibuffer-history)) (insert-state keymap "Auxiliary keymap for Insert state" (18 . helm-minibuffer-history)) (normal-state keymap "Auxiliary keymap for Normal state" (return . exit-minibuffer) (escape . abort-recursive-edit)) (menu-bar keymap (minibuf "Minibuf" keymap (previous menu-item "Previous History Item" previous-history-element :help "Put previous minibuffer history element in the minibuffer") (next menu-item "Next History Item" next-history-element :help "Put next minibuffer history element in the minibuffer") (isearch-backward menu-item "Isearch History Backward" isearch-backward :help "Incrementally search minibuffer history backward") (isearch-forward menu-item "Isearch History Forward" isearch-forward :help "Incrementally search minibuffer history forward") (return menu-item "Enter" exit-minibuffer :key-sequence "\015" :help "Terminate input and exit minibuffer") (quit menu-item "Quit" abort-recursive-edit :help "Abort input and exit minibuffer") "Minibuf")) (10 . exit-minibuffer) (13 . exit-minibuffer) (7 . abort-recursive-edit) (C-tab . file-cache-minibuffer-complete) (9 . self-insert-command) (XF86Back . previous-history-element) (up . previous-line-or-history-element) (prior . previous-history-element) (XF86Forward . next-history-element) (down . next-line-or-history-element) (next . next-history-element) (27 keymap (114 . previous-matching-history-element) (115 . next-matching-history-element) (112 . previous-history-element) (110 . next-history-element))) nil nil "/n/nvme/nir/config/spacemacs.d/useful" t)
helm-read-pattern-maybe("Find files or url: " "/n/nvme/nir/config/spacemacs.d/" nil nil nil "/n/nvme/nir/config/spacemacs.d/useful" nil)
helm-internal(helm-source-find-files "/n/nvme/nir/config/spacemacs.d/" "Find files or url: " nil nil "*helm find files*" nil "/n/nvme/nir/config/spacemacs.d/useful" nil)
apply(helm-internal (helm-source-find-files "/n/nvme/nir/config/spacemacs.d/" "Find files or url: " nil nil "*helm find files*" nil "/n/nvme/nir/config/spacemacs.d/useful" nil))
helm(helm-source-find-files "/n/nvme/nir/config/spacemacs.d/" "Find files or url: " nil nil "*helm find files*" nil "/n/nvme/nir/config/spacemacs.d/useful" nil)
apply(helm (helm-source-find-files "/n/nvme/nir/config/spacemacs.d/" "Find files or url: " nil nil "*helm find files*" nil "/n/nvme/nir/config/spacemacs.d/useful" nil))
helm(:sources helm-source-find-files :input "/n/nvme/nir/config/spacemacs.d/" :case-fold-search smart :preselect nil :ff-transformer-show-only-basename t :default "/n/nvme/nir/config/spacemacs.d/useful" :prompt "Find files or url: " :buffer "*helm find files*")
helm-find-files-1("/n/nvme/nir/config/spacemacs.d/")
(let* ((hist (and arg helm-ff-history (helm-find-files-history))) (default-input hist) (input (cond ((and (eq major-mode 'dired-mode) default-input) (file-name-directory default-input)) ((and (not (string= default-input "")) default-input)) (t (expand-file-name (helm-current-directory)))))) (set-text-properties 0 (length input) nil input) (helm-find-files-1 input))
spacemacs/helm-find-files(nil)
funcall-interactively(spacemacs/helm-find-files nil)
call-interactively(spacemacs/helm-find-files nil nil)
command-execute(spacemacs/helm-find-files)
I think I have found the culprit. A long time ago I adviced split-window to treat treemacs as a side-window while the splitting happens. This was meant as a fix to the issue of split-window-right producing unenvely sized windows when treemacs is visible (this is an issue with emacs and fixed size windows in general).
Let's see if I'm right. Does running (advice-remove #'split-window-right #'treemacs--split-window-advice) fix your problem?
I'm afraid it doesn't seem to resolve the issue.
Ok, let's try taking treemacs itself out of the equation. The following code will set up a buffer just as treemacs would. Does helm still cause problems in that scenario? What about removing the final call to treemacs-mode?
(defun treemacs--on-window-config-change2 ()
"Collects all tasks that need to run on a window config change."
(-when-let (w (get-buffer-window "*TEST*"))
(treemacs-without-following
(with-selected-window w
(let (window-configuration-change-hook)
(when treemacs--width-is-locked
(treemacs--set-width treemacs-width))
(when treemacs-is-never-other-window
(set-window-parameter w 'no-other-window t)))))))
(progn
(-> (selected-window)
(frame-root-window)
(split-window nil treemacs-position)
(select-window))
(let ((buf (get-buffer-create "*TEST*")))
(switch-to-buffer buf))
(add-hook 'window-configuration-change-hook #'treemacs--on-window-config-change2 nil :local)
(set-window-dedicated-p (selected-window) t)
(treemacs--set-width treemacs-width)
(treemacs-mode))
I tested the following snippet, which is a copy of the above by @Alexander-Miller but with every mention of treemacs erased ;)
The helm issue still occurs, so this looks like it's helm's fault.
(defun test--set-width (width)
(unless (one-window-p)
(let ((window-size-fixed)
(w (max width window-min-width)))
(cond
((> (window-width) w)
(shrink-window-horizontally (- (window-width) w)))
((< (window-width) w)
(enlarge-window-horizontally (- w (window-width))))))))
(defun on-window-change ()
"Collects all tasks that need to run on a window config change."
(-when-let (w (get-buffer-window "*TEST*"))
(treemacs-without-following
(with-selected-window w
(let (window-configuration-change-hook)
(when t
(test--set-width 35)))))))
(progn
(-> (selected-window)
(frame-root-window)
(split-window nil 'left)
(select-window))
(let ((buf (get-buffer-create "*TEST*")))
(switch-to-buffer buf))
(add-hook 'window-configuration-change-hook #'on-window-change nil :local)
(set-window-dedicated-p (selected-window) t)
(test--set-width 35))
I'm getting the error message:
split-window: Cannot split side window or parent of side window
when trying to add a project C-p a and pressing C-l, TAB or right (arrow key) (which calls helm-execute-persistent-action) to complete the selected directory at the:
HELM Treemacs Add Project To Workspace prompt.
I following the linked issue:
treemacs + helm-swiper issue #968
https://github.com/hlissner/doom-emacs/issues/968
Which linked to this comment by simon-bourne:
https://github.com/syl20bnr/spacemacs/issues/7446#issuecomment-417376425
(with-eval-after-load "helm"
(defun helm-persistent-action-display-window (&optional split-onewindow)
"Return the window that will be used for persistent action.
If SPLIT-ONEWINDOW is non-`nil' window is split in persistent action."
(with-helm-window
(setq helm-persistent-action-display-window (get-mru-window)))))
When that is evaluated, then the error message doesn't appear anymore and C-l works as expected.
Let's pick this up again. Do you still see problems when treemacs was spawned with treemacs-display-in-side-window set to nil?
No change.
This might not be a Treemacs issue, because the same issue occurs with Neotree.
It is not just a helm issue either. I tried reproducing it from the state that helm's emacs-helm.sh script gives you, and didn't see any errors. If you want to see for yourself, or know more about what may be different in spacemacs, I used the following lines to get a minimal setup going:
(setq package-user-dir "/home/a/.emacs.d/elpa/26.2/develop/")
(package-initialize)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")
("gnu" . "https://elpa.gnu.org/packages/")))
(package-refresh-contents)
(dolist (dir (directory-files package-user-dir t nil))
(add-to-list 'load-path dir))
(setq package-load-list '(all))
(package-install 'treemacs)
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(require 'treemacs)
(treemacs)
In this issue:
Helm cannot split inside the active window? https://github.com/syl20bnr/spacemacs/issues/9044
The author wants helm to only appear in the current window, instead of taking up the whole bottom of the frame (Spacemacs default behavior).
The suggested workaround is to set:
(setq-default helm-display-function 'helm-default-display-buffer)
source: https://github.com/syl20bnr/spacemacs/issues/9044#issuecomment-309454459
When the workaround is evaluated. Then it works as expected, helm only splits the current window.
Now when I test the cannot split issue with this setup:
SPC w sSPC f tSPC f fNow one of the windows is replaced with the helm find files buffer.
(it seems to alternate between the windows if one closes C-g the helm buffer an opens it again)
Make sure that the helm buffer is in the second window. (reason below)
In this state, pressing C-h to move to the parent directory behaves the same as when the helm-display-function line hasn't been evaluated. The helm buffer just updates to show the parent directories contents.
But when a directory is selected, and C-l (lowercase L) is pressed, then a new window is created with a copy of the helm buffer, and all of them show the new directory.
Additional C-l presses adds another split helm window.
The question is, why does it want to split the window?
It doesn't seem to need to split it to move to the parent directory.
If the helm buffer was opened in the first window, then C-l also splits the window but it closes instantly, there's just a short flash when the windows split and are restored to the pre-split state.
It also happens when a help buffer is open, without Treemacs or Neotree.
C-h k kSPC f fC-lsplit-window: Cannot split side window or parent of side window
This is where the cannot split message is coming from:
https://github.com/emacs-helm/helm/blob/56bfcd2dedfdab4629972969a7620d269db0ad9c/helm.el#L6306
Surrounding the (split-window) command with:
;; Fix Issue #2050 with dedicated window.
((window-dedicated-p
(setq prev-win (previous-window (selected-window) 1)))
(with-helm-after-update-hook
(and (window-live-p helm-persistent-action-display-window)
(delete-window helm-persistent-action-display-window)))
(message "BEFORE SPLIT")
(split-window)
(message "AFTER SPLIT"))
only shows:
BEFORE SPLIT
split-window: Cannot split side window or parent of side window
Correction:
That split is used when a *Help* buffer is open.
When Treemacs is open, then the next cond clause is called:
((window-dedicated-p
(setq cur-win (get-buffer-window helm-current-buffer)))
(message "helm-current-buffer BEFORE SPLIT")
(split-window)
(message "helm-current-buffer AFTER SPLIT"))
https://github.com/emacs-helm/helm/blob/0077945f5119c552a434c3f0b1970c1b1481b224/helm.el#L6307
helm-current-buffer BEFORE SPLIT
split-window: Cannot split side window or parent of side window
This commit seems to have fixed the same error message before:
Fix window selection with multiple side windows
https://github.com/emacs-helm/helm/commit/38f9bb525f2ee0ce19a04cfdfce6825ccfb4ef66
@sdwolfz Do you know more about how these these issues could be fixed?
Can't say I know more about this right now but when I'll encounter this bug again I'll investigate.
Quick survey: anyone have the "cannot split side-window" problem who isn't on spacemacs?
IMO it's strange - and quite fragile - that spacemacs has its own helm-display-function in spacemacs//display-helm-window with its strange treatment of help buffer regexes. Is there a good reason not to set helm-display-function to pop-to-buffer and then have helm's popup behavior be determined by a few simple shackle/popwin rules? Granted there's still this problem that I think @duianto described above (though I am unaffected because I use a custom helm-in-child-frame impelementation), but that's still 1 problem instead of 2.
In fact I have some code in my personal config that makes shackle and purpose cooperate nicely - new windows obey shackle rules if they cannot find another window with the same purpose they can replace. I mostly just use it to make the messages and flycheck-error-list buffers share the same window, but I'm sure there's a lot more spacemacs' layer system could get out of this.
Yes ibuffer (and I would suspect buffer on its own) I do not use spacemacs - I am using Aquamacs and a hand crafted setup.
Set ibuffer-expert to non-nil
Mark a few buffers then hit D to delete them.
Ibuffer tries to put up a window that lists the buffers to be deleted and asks Are you sure?
With treemacs I get an error "Cannot split side window or parent of side window"
BackTrace
Debugger entered--Lisp error: (error "Cannot split side window or parent of side window")
signal(error ("Cannot split side window or parent of side window"))
ibuffer-confirm-operation-on("kill" ("custom.el" "*Customize Group: Ibuffer*"))
ibuffer-do-delete()
funcall-interactively(ibuffer-do-delete)
call-interactively(ibuffer-do-delete nil nil)
command-execute(ibuffer-do-delete)
Works for me, side-window or no, even if I turn off my shackle settings. Maybe it's an emacs version difference - is your aquamacs based on emacs 25 or 26?
Do you use shackle or popwin? If yes you can also try adding a rule for ibuffer's split dialogue.
Aquamacs is based on 25.3.50.1 (as far as I know no relevant changes here)/ I don't use shackle or popwin
sdwolfz found a solution to the cannot split side window issue in helm find files from a Treemacs window and it's been merged into helm.
Fix splitting issue when invoking helm from a dedicated window https://github.com/emacs-helm/helm/pull/2200
I'm not seeing the cannot split message anymore in Spacemacs.
(autohotkey auto-completion
(dart :variables dart-server-sdk-path "c:/src/flutter/bin/cache/dart-sdk/" dart-server-enable-analysis-server t)
emacs-lisp git helm html
(lsp :variables lsp-clients-dart-server-command "~/AppData/Roaming/Pub/Cache/bin/dart_language_server" lsp-dart-analysis-sdk-dir "c:/src/flutter/bin/cache/dart-sdk/")
multiple-cursors org php spell-checking syntax-checking treemacs version-control vinegar)
:fireworks: