Function: touch-screen-preview-select
touch-screen-preview-select is an interactive and byte-compiled
function defined in touch-screen.el.gz.
Signature
(touch-screen-preview-select)
Documentation
Display a preview of the line around point in the echo area.
Unless the minibuffer is an active or the current line is excessively tall, display an indication of the position of point and the contents of the visible line around it within the echo area.
If the selected window is hscrolled or lines may be truncated,
attempt to find the extents of the text between column 0 and the
right most column of the window using posn-at-x-y.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/touch-screen.el.gz
(defun touch-screen-preview-select ()
"Display a preview of the line around point in the echo area.
Unless the minibuffer is an active or the current line is
excessively tall, display an indication of the position of point
and the contents of the visible line around it within the echo
area.
If the selected window is hscrolled or lines may be truncated,
attempt to find the extents of the text between column 0 and the
right most column of the window using `posn-at-x-y'."
(interactive)
;; First, establish that the minibuffer isn't active and the line
;; isn't taller than two times the frame character height.
(unless (or (> (minibuffer-depth) 0)
;; The code below doesn't adapt well to buffers
;; containing long lines.
(long-line-optimizations-p)
(let ((window-line-height (window-line-height))
(maximum-height (* 2 (frame-char-height))))
(unless window-line-height
;; `window-line-height' isn't available.
;; Redisplay first and try to ascertain the height
;; of the line again.
(redisplay t)
(setq window-line-height (window-line-height)))
;; `window-line-height' might still be unavailable.
(and window-line-height
(> (car window-line-height)
maximum-height))))
(catch 'hscrolled-away
(let ((beg nil) end string y)
;; Detect whether or not the window is hscrolled. If it
;; is, set beg to the location of the first column
;; instead.
(when (> (window-hscroll) 0)
(setq y (+ (or (cdr (posn-x-y (posn-at-point)))
(throw 'hscrolled-away t))
(window-header-line-height)
(window-tab-line-height)))
(let* ((posn (posn-at-x-y 0 y))
(point (posn-point posn)))
(setq beg point)))
;; Check if lines are being truncated; if so, use the
;; character at the end of the window as the end of the
;; text to be displayed, as the visual line may extend
;; past the window.
(when (or truncate-lines beg) ; truncate-lines or hscroll.
(setq y (or y (+ (or (cdr (posn-x-y (posn-at-point)))
(throw 'hscrolled-away t))
(window-header-line-height)
(window-tab-line-height))))
(let* ((posn (posn-at-x-y (1- (window-width nil t)) y))
(point (posn-point posn)))
(setq end point)))
;; Now find the rest of the visual line.
(save-excursion
(unless beg
(beginning-of-visual-line)
(setq beg (point)))
(unless end
(end-of-visual-line)
(setq end (point))))
;; Obtain a substring containing the beginning of the
;; visual line and the end.
(setq string (buffer-substring beg end))
;; Hack `invisible' properties within the new string.
;; Look for each change of the property that is a variable
;; name and replace it with its actual value according to
;; `buffer-invisibility-spec'.
(when (listp buffer-invisibility-spec)
(let ((index 0)
(property (get-text-property 0
'invisible
string))
index1 invisible)
(while index
;; Find the end of this text property.
(setq index1 (next-single-property-change index
'invisible
string))
;; Replace the property with whether or not it is
;; non-nil.
(when property
(setq invisible nil)
(catch 'invisible
(dolist (spec buffer-invisibility-spec)
;; Process one element of the buffer
;; invisibility specification.
(if (consp spec)
(when (eq (cdr spec) 't)
;; (ATOM . t) makes N invisible if N is
;; equal to ATOM or a list containing
;; ATOM.
(when (or (eq (car spec) property)
(and (listp spec)
(memq (car spec) invisible)))
(throw 'invisible (setq invisible t))))
;; Otherwise, N is invisible if SPEC is
;; equal to N.
(when (eq spec property)
(throw 'invisible (setq invisible t))))))
(put-text-property index (or index1
(- end beg))
'invisible invisible string))
;; Set index to that of the next text property and
;; continue.
(setq index index1
property (and index1
(get-text-property index1
'invisible
string))))))
(let ((resize-mini-windows t) difference width
(message-log-max nil))
;; Find the offset of point from beg and display a cursor
;; below.
(setq difference (- (point) beg)
width (string-pixel-width
(substring string 0 difference)))
(message "%s\n%s^" string
(propertize " "
'display (list 'space
:width (list width)))))
nil))))