Emacs101 / howm-manual

Note-taking in Emacs with howm package
123 stars 6 forks source link

Has anyone successfully made howm work with evil? #1

Open g-gundam opened 10 months ago

g-gundam commented 10 months ago

This is my second time giving howm a try, and I remember why I gave up the first time. Its keybindings clash with evil. I wonder if anyone out there has successfully configured Emacs so that howm works with evil. If so, it'd be nice to document it here.

PS: Thanks for writing the manual.

Emacs101 commented 10 months ago

This is why I gave up on evil. :) Basically, all Emacs documentation was written for the vanilla version. I actually tried to find evil customization but didn't succeed. It is probably somewhere in the Japanese segment of the Internet. I listed all howm-specific commands at the end of my tutorial; I guess rebinding them would be a relatively small pain.

kaorahi commented 10 months ago

In my case, I use a classic VI emulator, VIPER, with the following personal settings. I'm also interested in Vim emulation, but I haven't been able to find the time to make the transition.

;; Key bindings for the note buffers in VI state.
(defvar howm-mode-on-hook)
(add-hook 'howm-mode-on-hook 'myvip-howm-mode-hook t)
(defun myvip-howm-mode-hook ()
  (viper-add-local-keys 'vi-state
                        '(
                          ("\C-c,," . howm-menu)
                          ([return] . action-lock-magic-return)
                          ([tab] . action-lock-goto-next-link)
                          ([(meta tab)] . action-lock-goto-previous-link)
                          )))

;; Enable VI emulation on the summary buffer with some key bindings.
(defvar howm-view-summary-mode-hook)
(add-hook 'howm-view-summary-mode-hook 'myvip-howm-view-summary-mode-hook)
(defun myvip-howm-view-summary-mode-hook ()
  (viper-mode)
  (setq action-lock-original-return 'howm-view-summary-open)
  (viper-add-local-keys 'vi-state
                        '(
                          ([return] . action-lock-magic-return)
                          (" " . riffle-pop-or-scroll-other-window)
                          ([backspace] . scroll-other-window-down)
                          ("@" . riffle-summary-to-contents)
                          ("p" . howm-view-summary-peek)
                          ("u" . howm-view-filter-uniq)
                          ("T" . howm-list-title)
                          ("." . howm-reminder-goto-today)
                          ))
  (myvip-howm-view-common-hook))

;; Enable VI emulation on the contents buffer with some key bindings.
(defvar howm-view-contents-mode-hook)
(add-hook 'howm-view-contents-mode-hook 'myvip-howm-view-contents-mode-hook)
(defun myvip-howm-view-contents-mode-hook ()
  (viper-mode)
  (viper-add-local-keys 'vi-state
                        '(
                          ([return] . howm-view-contents-open)
                          ([tab] . riffle-contents-goto-next-item)
                          ([(meta tab)] . riffle-contents-goto-previous-item)
                          ("@" . riffle-contents-to-summary)
                          ))
  (myvip-howm-view-common-hook))

;; Common key bindings for the summary/contents buffer in VI mode.
(defun myvip-howm-view-common-hook ()
  (viper-add-local-keys 'vi-state
                        '(
                          ("s" . howm-view-filter-by-contents)
                          ("S" . howm-view-sort)
                          ("R" . howm-view-sort-reverse)
                          ("f" . howm-view-filter)
                          ("q" . howm-view-kill-buffer)
                          )))

;; Special key to open the menu.
;; (JP keyboards have extra keys which I actually never use.)
;; VI emulation is turned off on the menu buffer, allowing use of
;; the key bindings for the menu feature.
;; To use VI emulation there, it can be toggled with subsequent
;; presses of this special key.
(define-key global-map [muhenkan] 'my-howm-menu)
(defun my-howm-menu ()
  (interactive)
  (if (and (string= (buffer-name) (howm-menu-name howm-menu-top))
           (eq last-command 'my-howm-menu))
      (viper-change-state-to-vi)
    (progn
      (howm-menu)
      (viper-change-state-to-emacs))))
Emacs101 commented 10 months ago

Thanks for this solution!