Closed agzam closed 4 years ago
From the .spacemacs file
;; A list of packages that will not be installed and loaded.
dotspacemacs-excluded-packages '()
Would adding treemacs package here help ?
@jr0cket John, I don't want to remove treemacs, I just want to re-use the binding. And Spacemacs not letting me do that easily. Besides, that won't exclude it. It's a core package.
@agzam don't do this, use the SPC o
prefix.
What do you mean "don't do this"? Don't be silly, it's Emacs we're talking about. If I want to do something, I probably can and I most definitely will :)
Of course but the issue is that you're doing something that well..is perilous. Also SPC pt is defined in the neotree and treemacs layers, not in core.
On 4/7/20 10:16 PM, Ag Ibragimov wrote:
What do you mean "don't do this"? Don't be silly, it's Emacs we're talking about. If I want to do something, I probably can and I most definitely will :)
β You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/syl20bnr/spacemacs/issues/13460#issuecomment-610713382, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAFUMHGQVIIUHIGDTAHME3RLPM67ANCNFSM4MDPXDCA.
From the .spacemacs file
;; A list of packages that will not be installed and loaded. dotspacemacs-excluded-packages '()
Would adding treemacs package here help ?
This is not the answer to the original question, but seems a viable alternative (I do not have that answer).
On a test of my system this morning, I commented out the treemacs layer and adding treemacs
to dotspacemacs-excluded-packages
. After restarting Spacemacs the SPC p t
keybinding was not present, however, SPC SPC treemacs
still launches treemacs.
I am unsubscribing from this issue as I have nothing more to share.
Put your binding inside dotspacemacs/user-config
which will run last so it will override what is set in :init
by the tree layer.
(spacemacs/set-leader-keys "pt" #'direx:jump-to-project-root-or-current-dir)
Remove all binding code in your use-package
. You won't need it. I don't use treemacs
. I tested with neotree
maybe you can refer this: https://github.com/ekaschalk/.spacemacs.d/tree/master/layers/config/local/redo-spacemacs
The spacebind--eager-bind
variable has now been enabled by default on the develop
branch.
https://github.com/syl20bnr/spacemacs/blob/acdb59767cc26b40819cc103767491951405e176/core/core-spacebind.el#L14-L16
This enables rebinding SPC p t
with:
(use-package direx
:demand t
:init
(spacemacs/set-leader-keys "pt" #'direx-project:jump-to-project-root))
or outside the use-package
expression:
(spacemacs/set-leader-keys "pt" #'direx-project:jump-to-project-root)
@agzam Feel free to close this issue if the issue has been fixed.
Since I didn't have agzam's function direx:jump-to-project-root-or-current-dir
https://github.com/agzam/dot-spacemacs/blob/943d8d63b124a575151118c311a204231646bc90/layers/ag-dired/funcs.el#L81
I used direx-project:jump-to-project-root
in the examples above.
@thanhvg The reason it works with the neotree
layer, is because it binds SPC p t
with the function: spacemacs/set-leader-keys
https://github.com/syl20bnr/spacemacs/blob/acdb59767cc26b40819cc103767491951405e176/layers/%2Bfiletree/neotree/packages.el#L107-L110
The treemacs
layer binds it using the spacmeacs|spacebind
macro.
https://github.com/syl20bnr/spacemacs/blob/d95d41f55ba074128b3ed8f0eedcdc3c31b52e42/layers/%2Bfiletree/treemacs/packages.el#L42-L51
@duianto I don't know what I'm missing but this fixed nothing for me. This is what I have right now:
treemacs
SPC p t
binds to spacemacs/treemacs-project-toggle
(that's expected)(use-package direx
piece, and it loads it just fine. But I'm still failing to override SPC p t
from within my custom layerWhat I've tried so far:
(spacemacs/set-leader-keys "pt" #'direx:jump-to-project-root-or-current-dir)
inside :init
of use-package call:config
sectionspacemacs|spacebind
instead of set-leader-keys
(setq-default spacebind--eager-bind nil)
in dotspacemacs/user-init
layers.el
for my layer with (configuration-layer/declare-layers '(treemacs))
, hoping it will get loaded after treemacs layer(message "π±π±π±π±π±π±π±π±π±π±π±")
inside use-package direx
block and (message "πΆπΆπΆπΆπΆπΆπΆπΆπΆπΆπΆ")
inside treemacs/init-treemacs
in .emacs.d/layers/+filetree/treemacs/packages.el
.
And the dogs always get printed after the cats.I don't know what else to try. I just can't rebind the damn keybinding (from within the layer) without loading treemacs at least once.
The only suggestion that worked is what @thanhvg suggested. Placing it in dotspacemacs/user-config
. But that is not "clean" approach. It breaks "the modularity". I guess, that'd will do for now.
I tested it by adding direx
to the additional packages list.
And both the:
worked from the user-config section, in both:
#### System Info :computer: - OS: gnu/linux - Emacs: 26.3.50 - Spacemacs: 0.300.0 - Spacemacs branch: develop (rev. acdb59767) - Graphic display: t - Distribution: spacemacs - Editing style: vim - Completion: helm - Layers: ```elisp (auto-completion command-log emacs-lisp git helm markdown multiple-cursors (org :variables org-agenda-files '("~/org/notes.org")) python (shell :variables shell-default-shell 'vterm shell-default-height 30 shell-default-position 'bottom) spell-checking syntax-checking treemacs version-control) ``` - System configuration features: XPM JPEG TIFF GIF PNG SOUND DBUS GSETTINGS GLIB NOTIFY LIBSELINUX GNUTLS FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS
#### System Info :computer: - OS: windows-nt - Emacs: 26.3 - Spacemacs: 0.300.0 - Spacemacs branch: develop (rev. acdb59767) - Graphic display: t - Distribution: spacemacs - Editing style: vim - Completion: helm - Layers: ```elisp (ag-dired autohotkey (auto-completion :variables auto-completion-enable-help-tooltip t auto-completion-enable-snippets-in-popup t) command-log dap emacs-lisp git helm helpful html imenu-list javascript latex (markdown :variables markdown-live-preview-engine 'vmd markdown-command "vmd") multiple-cursors (org :variables org-agenda-files '("~/org/notes.org")) pdf (php :variables php-backend 'lsp) (python :variables python-backend 'anaconda) (shell :variables shell-default-shell 'shell shell-default-height 30 shell-default-position 'bottom) spell-checking (syntax-checking :variables syntax-checking-enable-by-default nil) treemacs version-control) ``` - System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS THREADS LCMS2
I now tried it with your ag-dired
layer:
https://github.com/agzam/dot-spacemacs/tree/master/layers/ag-dired
And it seems to be a loading order issue. When the key binding locations are logged:
ag-dired/init-direx :init define SPC p t
treemacs/init-treemacs :init define SPC p t
the treemacs binding is defined after the ag-dired binding (Spacemacs might be loading the layers alphabetically).
It seems to work to add a new function: ag-dired/post-init-direx
ag-dired/init-direx :init
treemacs/init-treemacs :init define SPC p t
ag-dired/post-init-direx define SPC p t
By removing the following from the ag-dired/init-direx
function:
(with-eval-after-load 'treemacs
(spacemacs/set-leader-keys
"pt" #'direx:jump-to-project-root-or-current-dir))
https://github.com/agzam/dot-spacemacs/blob/master/layers/ag-dired/packages.el#L77
And adding the following after the ag-dired/init-direx
function:
(defun ag-dired/post-init-direx ()
(spacemacs/set-leader-keys
"pt" #'direx:jump-to-project-root-or-current-dir))
However when I press SPC p t
before a direx buffer has been opened, then I get the message:
let: Symbolβs function definition is void: direx-project:find-project-root-noselect
The variable: spacebind--eager-bind
also had to be enabled (t
) (which it is on the current develop
branch), because when I tried to change it back to it's previous value (nil
), then SPC p t
still opens treemacs, even with the post-init-direx function above.
Oh.. wow.. I don't know what to say. Your determination to keep digging to get to the bottom of this amazes me. Thank you! My apologies for complaining about something non-essential like this. I didn't mean to force you to spend so much time trying to find a solution.
let: Symbolβs function definition is void: direx-project:find-project-root-noselect
that can be fixed by requiring direx-project
, it might be a tiny issue with direx.
I don't know how the simple idea of using post-init function to bind the key hasn't come to my mind. Once again - thank you!
No apologies necessary, and it's not non-essential, if one person encounters an issue, then it's likely to happen again. Now we know a little bit more about key binding loading order π
I'm dealing with this thing that's annoying me. I wanted to rebind
SPC p t
, which is bound to(treemacs)
to be used by something else, in my case to be used bydirex
package. So I did this:That didn't work - tremacs loads and still overrides that binding.
I thought, fine, I'll do it this way
And that worked, however - very first time (after loading Emacs) it still opens treemacs. The reason - the keybinding is set for treemacs, which loads lazily, and until you run it at least once, it won't rebind.
Can someone suggest a workaround?