1

I'm trying to write something that will disable a certain mode (fci-mode) if a buffer's visible width is under a certain amount. I know about the (window-width) function, however, that doesn't change if the window is vertically split (so the buffer is only half as wide).

Is there a method I can call that gives the visible width of a buffer in characters?

[EDIT] Stefan pointed out that (window-width) does change when a window is split. I was testing this incorrectly.

  • 1
    Can you clarify what you mean when you say "buffer"? Do you mean "window," "frame," or something else? See What's the difference between a buffer, a file, a window, and a frame? – Dan Mar 11 '16 at 22:50
  • 2
    AFAIK window-width does change when the window is split. – Stefan Mar 11 '16 at 23:02
  • @Stefan I believe you're correct, I was testing this incorrectly. – Lee H Mar 11 '16 at 23:32
  • 1
    Do you mean the maximum width of the content as displayed in the buffer? If so, I don't think there is a function that gives you this directly and reliably. Lots of things (images, font sizes, display property) can affect the apparent width of buffer contents. – Drew Mar 12 '16 at 0:22
  • Here is a link to a diagram in the manual of window components and some functions to extract various values -- perhaps that will help in this case: gnu.org/software/emacs/manual/html_node/elisp/Window-Sizes.html – lawlist Mar 12 '16 at 1:49
1

Have you tried this?

(window-total-width)

Also just be aware that a buffer's width in characters can vary wildly and gets affected by font width, window margins, frame margins, scroll bars, border thickness, text that have the box property enabled etc.... there's many many more but you get the idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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