Mapping dired-sidebar to “SPC o p”

I have my personal “leader prefix key”-thing already for some personal shortcuts which works fine.

Now I found dired-sidebar and would like to map it “SPC o p” like treemacs or neotree (and not to my personal things). How would I do this correctly? I searched the repo but couldn’t find how it is done for treemacs and neotree.

So what would I need to do?

Have a look at the map! macro! There are many examples sprinkled around Doom Emacs, and more generally, around the internet. You could also have a look at doomemacs/ at 042fe0c43831c8575abfdec4196ebd7305fa16ac · doomemacs/doomemacs · GitHub.

Thanks for you answer. But as I have written - I searched through the repo of doom emacs and grepped through the files on my machine. I forgot to mention that I read the documentation before and used various search engines before asking here. That’s how I figured out in the first place how to do my own mappings.

But I couldn’t find how I could do what I want to do – map dired-sidebar-toggle-sidebar to “SPC o p” like it is done with treemacs or neotree. That’s why I asked here.

I found now “modules/config/default/+evil-bindings”, after having another idea how to search, where the shortcut is defined.

There is this:

      ;;; <leader> o --- open
      (:prefix-map ("o" . "open")
       :desc "Org agenda"       "A"  #'org-agenda
       (:prefix ("a" . "org agenda")
        :desc "Agenda"         "a"  #'org-agenda
        :desc "Todo list"      "t"  #'org-todo-list
        :desc "Tags search"    "m"  #'org-tags-view
        :desc "View search"    "v"  #'org-search-view)
       :desc "Default browser"    "b"  #'browse-url-of-file
       :desc "Start debugger"     "d"  #'+debugger/start
       :desc "New frame"          "f"  #'make-frame
       :desc "Select frame"       "F"  #'select-frame-by-name
       :desc "REPL"               "r"  #'+eval/open-repl-other-window
       :desc "REPL (same window)" "R"  #'+eval/open-repl-same-window
       :desc "Dired"              "-"  #'dired-jump
       (:when (modulep! :ui neotree)
        :desc "Project sidebar"              "p" #'+neotree/open
        :desc "Find file in project sidebar" "P" #'+neotree/find-this-file)
       (:when (modulep! :ui treemacs)
        :desc "Project sidebar" "p" #'+treemacs/toggle
        :desc "Find file in project sidebar" "P" #'treemacs-find-file)

I have no idea how I would extend it.

I kind of doubt that:

(:prefix-map ("o" . "open")
(:desc "Project sidebar"              "p" #'dired-toggle-sidebar

would work.

You are quoting part of an expression.

You could use:

(map! :leader :desc "My description" :n "o p"   #'my-command)

Thanks a lot! That worked. I didn´t understand that I can do it this way. I thought I had to work with “:prefix”

This topic was automatically closed after 360 days. New replies are no longer allowed.