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
Post a Comment