2

I find myself running C-h k/f/v and after reading the popup that's in the other window, going to that window and closing it. Is there a way to streamline that process a bit more (maybe adding a hook onto C-g)?

Steps:

  1. M-x split-window-right ;; 2 windows are present
  2. C-h k C-k ;; opens a help window
  3. ??? ;; revert to the window / buffer configuration from step 1

EDIT: I realize this can be accomplished with winner-mode's winner-undo but since my muscle memory is used to spamming C-g to make things go away, I'm wondering if it's possible to spam a command that only works the first time so I can spam that command in specific situations like this. (it'd be great if we could augment C-g for this situation)

irregular
  • 962
  • 1
  • 9
  • 21
  • For clarity - I assume you mean *without* switching to the pop-up window and then switching back. `kill-buffer-and-window` (`C-x 4 0`) does what you want to the help window, but only if you're in it. But +1, I would be interested in answers to this question too. – Reign of Error Feb 25 '22 at 11:03
  • https://emacs.stackexchange.com/tags/elisp/info – Drew Feb 25 '22 at 15:50
  • Please specify more clearly what scenario you're talking about. There are quite a few possibilities/interpretations of what you ask - involving multiple frames, etc. In particular, I assume that `C-x 1` isn't a solution to your use case, but you need to *specify* the case. Please provide a recipe from `emacs -Q`, saying what you see after each step and what you expect/want to see instead. – Drew Feb 25 '22 at 15:59
  • How could there be a hook to leverage for this? How can anything know when you consider that you've sufficiently read the other window and want to delete it? (You could use a timer, of course, but then you'd either have to hurry reading sometimes or wait for the timer etc.) – Drew Feb 25 '22 at 16:02
  • I've updated the question with steps and realized that I could achieve what I wanted in a less optimal way with winner mode's winner-undo. Ideally I would like a shortcut that would have the winner-undo behavior called once even if I press it multiple times and this behavior would only happen in this situation. The idea with C-g came from how I normally spam pressing C-g when I want something to go away – irregular Feb 26 '22 at 00:32

3 Answers3

1

As described in this question and answer Select *Help* window buffer after C-h f it sounds like you might want to try using help-window-select. Setting it (in your init file or via customize) will automatically switch to the Help window (for instance after C-h f.) When there you can hit q to close the window and return to your previous window.

nega
  • 3,091
  • 15
  • 21
0

One suggestion is to use

(delete-window (other-window-for-scrolling))

which is going to delete the same window that C-M-v (scroll-other-window) and C-M-S-v (scroll-other-window-down) scroll.

d125q
  • 1,418
  • 5
  • 9
0

I think the solution in your case is popper.

The relevant function of this is that you can declare some windows as "popup" windows. Meaning with a keybinding you can either cycle the display of these or close them – no matter where your point (cursor) currently is.

If I am not doing a good job on describing the package, the author made a video showing it of here...

nnzi
  • 61
  • 1