Mercurial > emacs
comparison lisp/textmodes/ispell.el @ 35221:20bc16b92eef
(ispell-adjusted-window-height): New function.
(ispell-overlay-window, ispell-help, ispell-show-choices)
(ispell-command-loop): Use it instead of `window-height'.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 11 Jan 2001 07:53:53 +0000 |
parents | a0dab8c91962 |
children | f4c0144018d1 |
comparison
equal
deleted
inserted
replaced
35220:aab62e473631 | 35221:20bc16b92eef |
---|---|
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> |
7 ;; Stevens Mod Date: Fri Aug 4 09:41:50 PDT 2000 | 7 ;; Stevens Mod Date: Fri Aug 4 09:41:50 PDT 2000 |
8 ;; Stevens Revision: 3.4 | 8 ;; Stevens Revision: 3.4 |
1503 indicates whether the dictionary has been modified when option `a' or `i' is | 1503 indicates whether the dictionary has been modified when option `a' or `i' is |
1504 used. | 1504 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)) |
1512 (command-characters '( ? ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m )) | 1513 (command-characters '( ? ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m )) |
1513 (dedicated (window-dedicated-p (selected-window))) | 1514 (dedicated (window-dedicated-p (selected-window))) |
1773 (get-buffer-window ispell-choices-buffer t) | 1774 (get-buffer-window ispell-choices-buffer t) |
1774 (select-window (previous-window))) ; *Choices* window | 1775 (select-window (previous-window))) ; *Choices* window |
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 |
1786 (- ispell-choices-win-default-height | 1788 (- ispell-choices-win-default-height |
1787 line)))) | 1789 line)))) |
1830 (function (lambda () | 1832 (function (lambda () |
1831 ;;This shouldn't be necessary: with-electric-help needs | 1833 ;;This shouldn't be necessary: with-electric-help needs |
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. |
1839 SPC: Accept word this time. | 1842 SPC: Accept word this time. |
1840 `i': Accept word and insert into private dictionary. | 1843 `i': Accept word and insert into private dictionary. |
2048 (or (and (fboundp 'display-color-p) (display-color-p)) | 2051 (or (and (fboundp 'display-color-p) (display-color-p)) |
2049 window-system)) | 2052 window-system)) |
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. |
2056 Ensure that the line above point is still visible but otherwise avoid | 2072 Ensure that the line above point is still visible but otherwise avoid |
2057 scrolling the current window. Leave the new window selected." | 2073 scrolling the current window. Leave the new window selected." |
2067 (let ((frame (selected-frame))) | 2083 (let ((frame (selected-frame))) |
2068 (modify-frame-parameters frame '((unsplittable . nil))) | 2084 (modify-frame-parameters frame '((unsplittable . nil))) |
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) |
2087 (setq top (min (point) oldot)))) | 2095 (setq top (min (point) oldot)))) |
2088 (set-window-start (next-window) top)))) | 2096 (set-window-start (next-window) top)))) |