astoff / devdocs.el

Emacs viewer for DevDocs
297 stars 17 forks source link

devdocs-lookup should leave point in the devdocs buffer (even when called from another buffer) #21

Closed rswgnu closed 2 years ago

rswgnu commented 2 years ago

Thanks for devdocs.

So far, I've just seen one issue.

When devdocs-lookup is called from a non-devdocs buffer, it calls with-selected-window, which restores the prior selected window and buffer when finished. This means that one can't just run another lookup or use any of the key bindings in the devdocs buffer to navigate. Just use a pop-to-buffer or something like that instead and then one can use 'q' to quit from the devdocs buffer whenever ready.

rswgnu commented 2 years ago

Here's the suggested update that seems to work well:

(defun devdocs-lookup (&optional ask-docs initial-input)
  "Look up a DevDocs documentation entry.

Display entries in the documents `devdocs-current-docs' for
selection.  With a prefix argument (or, from Lisp, if ASK-DOCS is
non-nil), first read the name of one or more installed documents
and set `devdocs-current-docs' for this buffer.

If INITIAL-INPUT is not nil, insert it into the minibuffer."
  (interactive "P")
  (let* ((entry (devdocs--read-entry "Go to documentation: "
                                     (devdocs--relevant-docs ask-docs)
                                     initial-input))
         (buffer (devdocs--render entry)))
    (pop-to-buffer buffer)
    (devdocs-goto-target)
    (recenter 0)))
astoff commented 2 years ago

Well... I for one would not want this behavior. Although the package is described as an Info browser analogue, I use it more like C-h o (describe-symbol).

But I guess it makes sense to add a customization variable. I'm slightly unsure about the window management details; for instance, info-display-manual doesn't change the window configuration (it just stays on the current window), while your solution creates (or takes over) a different window. WDYT?

rswgnu commented 2 years ago

There are two separate issues here.

  1. Should devdocs-lookup leave point in the devdocs buffer? I say yes, so that the user can use all of the mode's key bindings and then quit when done.
  2. Should devdocs-lookup pop to a different window upon display. I have no opinion on that. You could use display-buffer instead of pop-to-buffer and let the configuration of that determine the window used.

Thanks.

astoff commented 2 years ago

Thanks for your input regarding 2. Regarding 1, like I said, I find the default behavior of C-h v and friends a better default. So I will implement an user option on the lines of help-window-select.

astoff commented 2 years ago

@rswgnu Let me know if the new option devdocs-window-select works for you. Thanks for the suggestion!

rswgnu commented 2 years ago

That should be fine. Thank you.