diff options
| author | Miles Bader | 2001-01-11 07:54:17 +0000 |
|---|---|---|
| committer | Miles Bader | 2001-01-11 07:54:17 +0000 |
| commit | 47a9f362d84fd2cbbf66f2f7ca3f68844b7d4fdc (patch) | |
| tree | 739ba00a8b90ccb4366908cc0ecb44841ea2328f /lisp/textmodes | |
| parent | cf523f0e1d6362cece2f1cc19b52d6eb9ec11db0 (diff) | |
| download | emacs-47a9f362d84fd2cbbf66f2f7ca3f68844b7d4fdc.tar.gz emacs-47a9f362d84fd2cbbf66f2f7ca3f68844b7d4fdc.zip | |
(ispell-adjusted-window-height): New function.
(ispell-overlay-window, ispell-help, ispell-show-choices)
(ispell-command-loop): Use it instead of `window-height'.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/ispell.el | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index f3cb28da3e7..e8d525d4599 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; ispell.el --- Interface to International Ispell Versions 3.1 and 3.2 | 1 | ;;; ispell.el --- Interface to International Ispell Versions 3.1 and 3.2 |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Ken Stevens <k.stevens@ieee.org> | 5 | ;; Author: Ken Stevens <k.stevens@ieee.org> |
| 6 | ;; Maintainer: Ken Stevens <k.stevens@ieee.org> | 6 | ;; Maintainer: Ken Stevens <k.stevens@ieee.org> |
| @@ -1505,7 +1505,8 @@ used. | |||
| 1505 | Global `ispell-quit' set to start location to continue spell session." | 1505 | Global `ispell-quit' set to start location to continue spell session." |
| 1506 | (let ((count ?0) | 1506 | (let ((count ?0) |
| 1507 | (line ispell-choices-win-default-height) | 1507 | (line ispell-choices-win-default-height) |
| 1508 | (max-lines (- (window-height) 4)) ; ensure 4 context lines. | 1508 | ;; ensure 4 context lines. |
| 1509 | (max-lines (- (ispell-adjusted-window-height) 4)) | ||
| 1509 | (choices miss) | 1510 | (choices miss) |
| 1510 | (window-min-height (min window-min-height | 1511 | (window-min-height (min window-min-height |
| 1511 | ispell-choices-win-default-height)) | 1512 | ispell-choices-win-default-height)) |
| @@ -1775,11 +1776,12 @@ Global `ispell-quit' set to start location to continue spell session." | |||
| 1775 | ;; standard selection by splitting a small buffer out of this window. | 1776 | ;; standard selection by splitting a small buffer out of this window. |
| 1776 | (let ((choices-window (get-buffer-window ispell-choices-buffer))) | 1777 | (let ((choices-window (get-buffer-window ispell-choices-buffer))) |
| 1777 | (if choices-window | 1778 | (if choices-window |
| 1778 | (if (= line (window-height choices-window)) | 1779 | (if (= line (ispell-adjusted-window-height choices-window)) |
| 1779 | (select-window choices-window) | 1780 | (select-window choices-window) |
| 1780 | ;; *Choices* window changed size. Adjust the choices window | 1781 | ;; *Choices* window changed size. Adjust the choices window |
| 1781 | ;; without scrolling the spelled window when possible | 1782 | ;; without scrolling the spelled window when possible |
| 1782 | (let ((window-line (- line (window-height choices-window))) | 1783 | (let ((window-line |
| 1784 | (- line (ispell-adjusted-window-height choices-window))) | ||
| 1783 | (visible (progn (vertical-motion -1) (point)))) | 1785 | (visible (progn (vertical-motion -1) (point)))) |
| 1784 | (if (< line ispell-choices-win-default-height) | 1786 | (if (< line ispell-choices-win-default-height) |
| 1785 | (setq window-line (+ window-line | 1787 | (setq window-line (+ window-line |
| @@ -1832,7 +1834,8 @@ SPC: Accept word this time. | |||
| 1832 | ;; an optional argument telling it about the smallest | 1834 | ;; an optional argument telling it about the smallest |
| 1833 | ;; acceptable window-height of the help buffer. | 1835 | ;; acceptable window-height of the help buffer. |
| 1834 | (if (< (window-height) 15) | 1836 | (if (< (window-height) 15) |
| 1835 | (enlarge-window (- 15 (window-height)))) | 1837 | (enlarge-window |
| 1838 | (- 15 (ispell-adjusted-window-height)))) | ||
| 1836 | (princ "Selections are: | 1839 | (princ "Selections are: |
| 1837 | 1840 | ||
| 1838 | DIGIT: Replace the word with a digit offered in the *Choices* buffer. | 1841 | DIGIT: Replace the word with a digit offered in the *Choices* buffer. |
| @@ -2050,6 +2053,19 @@ The variable `ispell-highlight-face' selects the face to use for highlighting." | |||
| 2050 | (ispell-highlight-spelling-error-overlay start end highlight)) | 2053 | (ispell-highlight-spelling-error-overlay start end highlight)) |
| 2051 | (t (ispell-highlight-spelling-error-generic start end highlight refresh)))) | 2054 | (t (ispell-highlight-spelling-error-generic start end highlight refresh)))) |
| 2052 | 2055 | ||
| 2056 | (defun ispell-adjusted-window-height (&optional window) | ||
| 2057 | "Like `window-height', adjusted to correct for the effect of tall mode-lines. | ||
| 2058 | The value returned is actually the nominal number of text-lines in the | ||
| 2059 | window plus 1. On a terminal, this is the same value returned by | ||
| 2060 | `window-height', but if the window has a mode-line is taller than a normal | ||
| 2061 | text line, the returned value may be smaller than that from | ||
| 2062 | `window-height'." | ||
| 2063 | (cond ((fboundp 'window-text-height) | ||
| 2064 | (1+ (window-text-height window))) | ||
| 2065 | (ispell-graphic-p | ||
| 2066 | (1- (window-height window))) | ||
| 2067 | (t | ||
| 2068 | (window-height window)))) | ||
| 2053 | 2069 | ||
| 2054 | (defun ispell-overlay-window (height) | 2070 | (defun ispell-overlay-window (height) |
| 2055 | "Create a window covering the top HEIGHT lines of the current window. | 2071 | "Create a window covering the top HEIGHT lines of the current window. |
| @@ -2069,18 +2085,10 @@ scrolling the current window. Leave the new window selected." | |||
| 2069 | (split-window nil height) | 2085 | (split-window nil height) |
| 2070 | (modify-frame-parameters frame '((unsplittable . t)))) | 2086 | (modify-frame-parameters frame '((unsplittable . t)))) |
| 2071 | (split-window nil height)) | 2087 | (split-window nil height)) |
| 2072 | (let ((deficit | 2088 | (let ((deficit (- height (ispell-adjusted-window-height)))) |
| 2073 | ;; Number of lines the window is still too short. We | ||
| 2074 | ;; ensure that there are at least (1- HEIGHT) lines | ||
| 2075 | ;; visible in the window. | ||
| 2076 | (- height | ||
| 2077 | (cond ((fboundp 'window-text-height) | ||
| 2078 | (1+ (window-text-height))) | ||
| 2079 | (ispell-graphic-p | ||
| 2080 | (1- (window-height))) | ||
| 2081 | (t | ||
| 2082 | (window-height)))))) | ||
| 2083 | (when (> deficit 0) | 2089 | (when (> deficit 0) |
| 2090 | ;; Number of lines the window is still too short. We ensure that | ||
| 2091 | ;; there are at least (1- HEIGHT) lines visible in the window. | ||
| 2084 | (enlarge-window deficit) | 2092 | (enlarge-window deficit) |
| 2085 | (goto-char top) | 2093 | (goto-char top) |
| 2086 | (vertical-motion deficit) | 2094 | (vertical-motion deficit) |