3

Whenever I open an info entry in emacs (C-h i) an additional frame pops up. On my system, it is too small and I'd love to have it in the top left corner, being wider and longer as it was created by default. The new frame is labeled "*info".

The same applies to the frame, that rises, whenever I use emacs various help functions (C-h k, C-h v, C-h f, ...). Those new frames are labaled "Help". This frame has a similar position and size, as the "info" frames.

I have defined a default-frame-alist as well as an initial-frame-alist in my ~.emacs file.

(setq initial-frame-alist
      '((top . 35)
        (right . 5)
        (width . 200)
        (height . 55) ))

(setq default-frame-alist
      '(
        ;(scroll-bar-foreground-color . "yellow")
        (vertical-scroll-bar . right)
        (scroll-bar-width . 17)
    (internal-border-width . 2) 
        (top . 20)
        (left . 10)
        (width . 120)
        (mouse-color . "yellow")
        (cursor-color . "red")
    ))

Those new frames are obviously not the initial frame. Therefore, it is okay to me, that the don't use the dimensions given in the 'initial-frame-alist'.

EDIT

This image shows the location of the two frames, after having pressed C-h i. AS you can see, a new frame "* info *" was opened on top of the initial frame (which is now in the background). Please notice also, the width of the new frame is not sufficient, to view the text, without breaking some longer lines. Furthermore, I'd love to have the new frame on the left screen side.

Additional frame on top of initial frame

But I'd like to define the dimensions as well. That would save me to use the mouse, to correct their size and location. Something like this is desired:

Desired Size and location of the new frame

(Obviously, I picked the frame with the mouse, moved it to its desired location and resized it with the mouse. I'd love to avoid using the mouse, instead I want to add some lisp code to my ~/.emacs to do this changes for me!

If I press than C-h k TAB I get another frame as shown here. This should also open on the left screen side (and not on the right side, as shown here).

Next additional frame *Help*

What do I have to add, to my '~.emacs' file, in order to define the size ('width' x 'height') and location ('left' and 'top') of this kind of frames.

Something like this (pseudocode)

(setq info-frame-alist
      '((top . 5)
        (left . 5)
        (width . 100)
        (height . 25) ))
(setq help-frame-alist
      '((top . 7)
        (left . 7)
        (width . 75)
        (height . 20) ))

Any suggestions?


EDIT

When I eval some functions in the new frames, I do get this kind of information:

(frame-root-window) ; => #<window 7 on *info*>

the number ("7" in this case) depends on how many buffers I have opened in the actual running emacs. But the text "info" is exact the title of the frame in question.

11
  • 1
    Do you see the same thing when you start Emacs using emacs -Q (no init file)? Otherwise, some of what you write seems unclear. E.g. C-i versus C-h i, and what do you mean by "a new frame"? If you use C-i multiple times do you end up with multiple Info frames? Seems like the recipe is not complete, or some of its description is not clear.
    – Drew
    Dec 23, 2019 at 19:03
  • Here is a link to an example of how to set frame location (top / left) and size (height / width), including to a precise pixel setting if so desired: emacs.stackexchange.com/a/17354/2287 The frame parameters used in the linked example function my-example-make-frame can be used in both the initial-frame-alist and default-frame-alist if so desired; or, you can use make-frame with the desired specs and create frames programmatically at will.
    – lawlist
    Dec 23, 2019 at 19:16
  • @Drew sorry, I had a mistake, that I corrected in my edit. C-i should have read C-h i. Yes, it doesn't matter, if you start emacs reading its init files or not. When I type 'C-h i' for the first time, I do get an new frame, presenting the content of the info directory. After having read the info, I press 'q' and the frame is icnoized (on MacOS/Aquamcs). When I type 'C-h i' again, the icon is reopend again and placed in at the former location on the screen. I wish to define the location and width of the frame in my init file, to avoid correcting it by hand/mouse.
    – Jan
    Dec 23, 2019 at 22:02
  • @lawlist thanks, I have read that link. But this seems not to apply on the frames, that pop up, when opening the info pages or asking for emacs help. I am looking for some lisp code to put into my init files, that say somehting like 'setq help-frame-alist '((top . 2) (right . 2) (width . enough) (height . sufficient)))', so that the frame has autmatically the correct size (width x height) and location an the computer screen.
    – Jan
    Dec 23, 2019 at 22:11
  • 1
    Are you referring to "frames" or "windows"?
    – Dan
    Dec 23, 2019 at 22:40

1 Answer 1

3

My suggestion would be to specify that *Help* and *info* buffers be special-display buffers.

You can customize option special-display-buffer-names, to specify that these buffers should be shown in their own frames at specific screen locations. You can also use option special-display-regexps, to handle multiple buffers *info*, *info<2>*,...

Simple example (but it's better to use M-x customize-option to set option values - that goes for default-frame-alist too):

(setq special-display-frame-alist '((left . 100) (top . 50)))

(add-to-list 'special-display-buffer-names "*Help*")
(add-to-list 'special-display-regexps "[*]info[*]\\(<[0-9]+>\\)?")

You can do more-complicated things, of course, such as putting the Help and Info frames at different locations or giving them other properties that are different.


[Be aware that the Emacs docs tell you that special-display-* things are considered deprecated, since you can do more, in much more complicated ways, using display-buffer-alist. When that was added to Emacs it was touted as a replacement for special-display-*, because it's more general. I don't consider special-display-* deprecated, personally. It's simple to use, to do a relatively simple job.]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.