aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorChong Yidong <[email protected]>2009-04-15 22:41:20 +0000
committerChong Yidong <[email protected]>2009-04-15 22:41:20 +0000
commit7beba943eca576811305afdef5a471cee1f36fe6 (patch)
tree638caeb263908ba1ded6b95a15cf23062b549818 /lisp/subr.el
parented8ab760ef75888924f37746d025efaa00a84c76 (diff)
* subr.el (posn-col-row): Properly compute line spacing.
Suggested by Nikolaj Schumacher (Bug#2933).
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el20
1 files changed, 13 insertions, 7 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index ffe8a9de5b..5372adb510 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -930,13 +930,19 @@ and `event-end' functions."
(cons (scroll-bar-scale pair (window-width window)) 0))
(t
(let* ((frame (if (framep window) window (window-frame window)))
- (x (/ (car pair) (frame-char-width frame)))
- (y (/ (cdr pair) (+ (frame-char-height frame)
- (or (frame-parameter frame 'line-spacing)
- ;; FIXME: Why the `default'?
- (default-value 'line-spacing)
- 0)))))
- (cons x y))))))
+ ;; FIXME: This should take line-spacing properties on
+ ;; newlines into account.
+ (spacing (when (display-graphic-p frame)
+ (or (with-current-buffer (window-buffer window)
+ line-spacing)
+ (frame-parameter frame 'line-spacing)))))
+ (cond ((floatp spacing)
+ (setq spacing (truncate (* spacing
+ (frame-char-height frame)))))
+ ((null spacing)
+ (setq spacing 0)))
+ (cons (/ (car pair) (frame-char-width frame))
+ (/ (cdr pair) (+ (frame-char-height frame) spacing))))))))
(defun posn-actual-col-row (position)
"Return the actual column and row in POSITION, measured in characters.