emacs - Programmatically detect if any line in a buffer is wrapping? -


i have idea possibly cool/probably stupid emacs script dynamically resize text fill available space.

one thing can't seem figure out how query current buffer see if lines being wrapped. how it?

you can check if lines wrapped in current buffer function this:

(defun wrapped-lines-p ()   (save-excursion     (goto-char (point-min))     (let ((long-line-regexp             (format "^.\\{%d\\}.+$" (window-body-width))))       (search-forward-regexp long-line-regexp nil t)))) 

as noted in comments, doesn't take account buffer's font size. since buffers can have mix of different sized fonts, window text pixel size needs tested. try this:

(defun wrapped-lines-p ()   (let ((window-width-pixels (window-body-width nil t)))     (> (car (window-text-pixel-size nil nil nil (1+ window-width-pixels)))        window-width-pixels))) 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -