kaorahi / howm

note-taking tool on Emacs
GNU General Public License v2.0
147 stars 11 forks source link

`r [Update]` Command on Howm Menu only returns error `Not howm-mode` #18

Closed termitereform closed 6 months ago

termitereform commented 6 months ago

Hello!

I've been trying out Howm and really liking it. I did have a question about the behavior of one of the menu items.

In the main Howm menu, there's an Update command listed that doesn't seem to work. It seems like it ought to check for updated files, but instead it drops me back to the *scratch* buffer with an error in the echo area that reads Not howm-mode. It leaves the *howmM:%menu%* buffer open, but buried.

This occurs both in my default config, and with emacs -Q and manually loading the library. It occurs on Windows, Ubuntu in WSL, and macOS.

Inspecting what the default key (r) is bound to returns:

r runs the command (lambda (arg) (interactive "P") (let ((pos #<marker at 234
in *howmM:%menu%*>)) (if nil (goto-char pos) (save-excursion (goto-char pos)
(let ((case-fold-search nil)) (when (null (action-lock-get-action))
(action-lock-goto-next-link)) (action-lock-invoke arg)))))) (found in
howm-menu-mode-local-map), which is an interactive Lisp function.

And the debug-on-error backtrace reports:

Debugger entered--Lisp error: (error "Not howm-mode")
  error("Not howm-mode")
  howm-initialize-buffer()
  apply(howm-initialize-buffer nil)
  (progn (switch-to-buffer prev) (apply #'howm-initialize-buffer nil))
  (let ((a nil) (cur (current-buffer)) (prev (if (howm-buffer-alive-p howm-menu-previous-buffer) howm-menu-previous-buffer (current-buffer)))) (progn (switch-to-buffer prev) (apply #'howm-initialize-buffer nil)))
  (lambda (&optional howm-menu-action-arg-name) (let ((a nil) (cur (current-buffer)) (prev (if (howm-buffer-alive-p howm-menu-previous-buffer) howm-menu-previous-buffer (current-buffer)))) (progn (switch-to-buffer prev) (apply #'howm-initialize-buffer nil))))(nil)
  action-lock-invoke(nil)
  (let ((case-fold-search nil)) (when (null (action-lock-get-action)) (action-lock-goto-next-link)) (action-lock-invoke arg))
  (save-excursion (goto-char pos) (let ((case-fold-search nil)) (when (null (action-lock-get-action)) (action-lock-goto-next-link)) (action-lock-invoke arg)))
  (if nil (goto-char pos) (save-excursion (goto-char pos) (let ((case-fold-search nil)) (when (null (action-lock-get-action)) (action-lock-goto-next-link)) (action-lock-invoke arg))))
  (let ((pos #<marker at 234 in *howmM:%menu%*>)) (if nil (goto-char pos) (save-excursion (goto-char pos) (let ((case-fold-search nil)) (when (null (action-lock-get-action)) (action-lock-goto-next-link)) (action-lock-invoke arg)))))
  (lambda (arg) (interactive "P") (let ((pos #<marker at 234 in *howmM:%menu%*>)) (if nil (goto-char pos) (save-excursion (goto-char pos) (let ((case-fold-search nil)) (when (null ...) (action-lock-goto-next-link)) (action-lock-invoke arg))))))(nil)
  funcall-interactively((lambda (arg) (interactive "P") (let ((pos #<marker at 234 in *howmM:%menu%*>)) (if nil (goto-char pos) (save-excursion (goto-char pos) (let ((case-fold-search nil)) (when (null ...) (action-lock-goto-next-link)) (action-lock-invoke arg)))))) nil)
  command-execute((lambda (arg) (interactive "P") (let ((pos #<marker at 234 in *howmM:%menu%*>)) (if nil (goto-char pos) (save-excursion (goto-char pos) (let ((case-fold-search nil)) (when (null ...) (action-lock-goto-next-link)) (action-lock-invoke arg)))))))
jabirali commented 6 months ago

Seems that I can confirm this behavior in my setup (Emacs 30.0.91).

If I e.g. open howm-list-all as my entry point, and then press , r to first enter the menu and then refresh, then I'm thrown back to the previously open buffer (here: howm-list-all) with the message howm-initialize-buffer: Not howm-mode written to the *Messages* buffer.

termitereform commented 6 months ago

Yeah, that happens to me as well. But for whatever reason C-u , r on the list does refresh everything.

And If I'm on the menu, and I hit C-c , r it refreshes as expected.

In Howm menu, C-c , r is bound to howm-refresh.

kaorahi commented 6 months ago

Thank you for the heads-up. I'd like to hear what you expected from "r [Update]" before I influence your thoughts with further explanation.

The reported behavior was intentional, but changing it will be better since it's too counter-intuitive. I'm considering implementing "what you expected" instead of (error "Not howm-mode").

My intended usage of "r [Update]" is:

To update the menu itself, you can use "R [Update Menu]" instead, but you don't need it if the value of howm-menu-expiry-hours is 0 (default). You'll want to modify this variable when you have many notes and C-c , , becomes slow.

I agree these are misleading...

(Background)

My mental model of the menu buffer is not the system's main screen, but more like a MODAL DIALOG for the command list that temporarily appears over the current buffer. (@Emacs101, have you noticed this?) It's just too big for a dialog and includes too much extra information, like the todo list. With this design, I expect that we would unintentionally glance at the todo list every now and then without explicitly trying to show it. (Zero operation is one of my important mottos.)

Since the menu is just a "dialog", some commands are applied to the buffer that was active BEFORE the menu was opened. In other words, they are applied to the buffer underneath the menu, not the menu buffer itself. This has repeatedly caused confusion. To check the list of such commands, search for the keyword previous in the value of the variable howm-menu-command-table-en.

Emacs101 commented 6 months ago

@kaorahi In this particular situation, I believe that the necessary modifications are not required in the program itself, but rather in my manual. :)

@termitereform On page 14 and 34, I provided an explanation of the function associated with the "r" key. Could you please review the content and suggest any additions or rephrasing that may help clarify the instructions?

termitereform commented 6 months ago

Ahhhh-- okay, thinking of the menu as a modal rather than a workspace makes a lot of stuff click for me that I didn't understand before. And Emacs101's explanation of r's behavior there explains perfectly. My bad! We can close this out.

kaorahi commented 6 months ago

I added some messages to prevent this trouble (8a954fe). English (and French) improvements are welcome.

The new menu template is only applied to new users, as I don't want to overwrite any potentially customized menus. Existing users will need to manually delete 0000-00-00-000000.txt to switch to the new one.

@termitereform, please let me know if you prefer a different option of the "thx" line in ChangeLog, like FULL NAME san (FOO at BAR.BAZ) for example.

https://github.com/kaorahi/howm/blob/8a954fe1963bb60b6f85205bc3a4aa7c16b59072/ChangeLog#L5

termitereform commented 6 months ago

That messaging works great for me -- and I'm fine with using this handle. Really appreciate y'all taking a look, even if it was user error!