New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Emacs 24.3: might be as simple as removing one use of window-text-pixel-size #220

Closed
oantolin opened this Issue Sep 10, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@oantolin

It seems to me that removing the unique usage of window-text-pixel-size would render ivy usable on Emacs 24.3. I think redefining ivy--resize-minibuffer-to-fit as follows works:

(defun ivy--resize-minibuffer-to-fit ()
  "Resize the minibuffer window so it has enough space to display
all of the text contained in the minibuffer."
  (with-selected-window (minibuffer-window)
    (fit-window-to-buffer)))

@oantolin oantolin changed the title from Support Emacs 24.3: might be as simple as removing one use of `window-text-pixel-size` to Support Emacs 24.3: might be as simple as removing one use of window-text-pixel-size Sep 10, 2015

@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Sep 10, 2015

Owner

Thanks, I've added a check if the function is bound before using it. Let me know if it works.

Owner

abo-abo commented Sep 10, 2015

Thanks, I've added a check if the function is bound before using it. Let me know if it works.

@oantolin

This comment has been minimized.

Show comment
Hide comment
@oantolin

oantolin Sep 24, 2015

Mmh. It doesn't work on Emacs 24.3: before this change, of course, Emacs 24.3 complained about window-text-pixel-size being undefined; now, of course, it doesn't have that complaint, but in graphical Emacs 24.3 the minibuffer never gets resized! Which means that you can't see any candidates, only the input line (that also contains the number of matches). On the other hand in text mode Emacs 24.3 ivy seems to work just fine.

Mmh. It doesn't work on Emacs 24.3: before this change, of course, Emacs 24.3 complained about window-text-pixel-size being undefined; now, of course, it doesn't have that complaint, but in graphical Emacs 24.3 the minibuffer never gets resized! Which means that you can't see any candidates, only the input line (that also contains the number of matches). On the other hand in text mode Emacs 24.3 ivy seems to work just fine.

@oantolin

This comment has been minimized.

Show comment
Hide comment
@oantolin

oantolin Sep 24, 2015

OK, so I don't fully understand the logic of resizing the minibuffer in ivy in graphical mode vs text mode, but I got ivy to work in Emacs 24.3 by redefining ivy--resize-minibuffer-to-fit as follows:

(defun ivy--resize-minibuffer-to-fit ()
   "Resize the minibuffer window so it has enough space to display
all of the text contained in the minibuffer."
  (with-selected-window (minibuffer-window)
    (let ((text-height (count-screen-lines))
          (body-height (window-body-height)))
      (when (> text-height body-height)
        (window-resize nil (- text-height body-height) nil t)))))

If I understand correctly this is simply a linewise version of the pixelwise version currently in ivy. I guess this means that for lines of varying sizes this version won't look as pretty, but so be it. It would be nice to have ivy simply use the text mode resizing logic for both text and graphical mode in Emacs 24.3, but I don't know how to make that change yet.

OK, so I don't fully understand the logic of resizing the minibuffer in ivy in graphical mode vs text mode, but I got ivy to work in Emacs 24.3 by redefining ivy--resize-minibuffer-to-fit as follows:

(defun ivy--resize-minibuffer-to-fit ()
   "Resize the minibuffer window so it has enough space to display
all of the text contained in the minibuffer."
  (with-selected-window (minibuffer-window)
    (let ((text-height (count-screen-lines))
          (body-height (window-body-height)))
      (when (> text-height body-height)
        (window-resize nil (- text-height body-height) nil t)))))

If I understand correctly this is simply a linewise version of the pixelwise version currently in ivy. I guess this means that for lines of varying sizes this version won't look as pretty, but so be it. It would be nice to have ivy simply use the text mode resizing logic for both text and graphical mode in Emacs 24.3, but I don't know how to make that change yet.

@oantolin

This comment has been minimized.

Show comment
Hide comment
@oantolin

oantolin Sep 24, 2015

Also, on the topic of supporting Emacs 24.3: for some reason help-function-arglist is not autoloaded in 24.3; ivy uses that function, but I hadn't noticed because I guess I had always used ivy after using some help function. To make ivy usable before I call any help function, I used (autoload 'help-function-arglist "help-fns").

Also, on the topic of supporting Emacs 24.3: for some reason help-function-arglist is not autoloaded in 24.3; ivy uses that function, but I hadn't noticed because I guess I had always used ivy after using some help function. To make ivy usable before I call any help function, I used (autoload 'help-function-arglist "help-fns").

@abo-abo abo-abo closed this in 9a509df Sep 26, 2015

@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Sep 26, 2015

Owner

Thanks for the code. It should work fine now.

Owner

abo-abo commented Sep 26, 2015

Thanks for the code. It should work fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment