fourier / ztree

Directory tree comparison mode for Emacs
http://www.emacswiki.org/emacs/ZtreeDiff
GNU General Public License v3.0
239 stars 21 forks source link

Key bindings #53

Closed rchar01 closed 6 years ago

rchar01 commented 6 years ago

Is there a way to change default key bindings for next C-n and previous line C-p to n and p?

By the way: I think that ztree (dir and diff) is a very good package, I use it every day. Thanks.

fourier commented 6 years ago

Personally I just use arrow keys. However for your task you can try to add to your config file

(define-key ztree-mode-map "n" 'next-line)
(define-key ztree-mode-map "p" 'previous-line)
rchar01 commented 6 years ago

Thanks, I added to my init.el:

(use-package ztree
  :bind (("<f8>"   . ztree-dir)
         ("C-<f8>" . ztree-diff)
         :map ztree-mode-map
         ("n" . next-line)
         ("p" . previous-line)
         ("f" . ztree-dir-narrow-to-dir)
         ("b" . ztree-dir-widen-to-parent)))

It is much easier to move around now.

rchar01 commented 6 years ago

I do not know if this is a bug but the above use-package setting does not work immediately after running ztree (dir or diff). It only works when I run ztree (dir or diff) and then evaluate emacs init.el, not immediately after ztree startup. I also reported this as an issue on the use-package GitHub page.

I also tried (with the same effect) with-eval-after-load. Works only with:

(require 'ztree)
(define-key ztree-mode-map "n" 'next-line)
(define-key ztree-mode-map "p" 'previous-line)

but I do not want to load the ztree at Emacs startup. Any ideas?

fourier commented 6 years ago

Not sure if I can help here since I dont use use-package and always manually craft "require" in my config, sorry.

rchar01 commented 6 years ago

I found the solution on use-package page, now I use:

- to bind keys within ztree-dir (local keymaps)

(use-package ztree-dir :bind (:map ztreedir-mode-map ("f" . ztree-dir-narrow-to-dir) ("b" . ztree-dir-widen-to-parent)))

- to bind keys within ztree-dir and ztree-diff (local keymaps):

(use-package ztree-view :bind (:map ztree-mode-map ("n" . next-line) ("p" . previous-line)))

fourier commented 6 years ago

I would recommend update the wiki (either github or better https://www.emacswiki.org/emacs/ZtreeDiff) with this information if you can, this will be a great contribution to ztree!

rchar01 commented 6 years ago

I'm working on it.

rchar01 commented 6 years ago

I've added information about the use-package bindings to the wiki. Currently it is on the first page. Do you want me to place it on a separate page?

fourier commented 6 years ago

Thank you for your contribution! its fine.