diff options
| author | Stefan Monnier | 2009-11-28 21:32:06 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2009-11-28 21:32:06 +0000 |
| commit | 21f49db9e9d118fafe45a36516fa6f64ccbe4658 (patch) | |
| tree | 9f99adcffb4ec07dd6d94ab61e0fb050e5593282 | |
| parent | 9d542758cfd2885a2713ff49202342f562b830d8 (diff) | |
| download | emacs-21f49db9e9d118fafe45a36516fa6f64ccbe4658.tar.gz emacs-21f49db9e9d118fafe45a36516fa6f64ccbe4658.zip | |
Try and remove assumptions about point-min==1.
* nxml/rng-valid.el (rng-validate-mode): Don't hardcode point-min==1.
(rng-compute-mode-line-string): Show the validation percentage in
terms of the narrowed text, not the widened text.
(rng-do-some-validation): Don't catch internal errors when debugging.
(rng-first-error): Simplify.
(rng-after-change-function): Remove work around. AFAIK the bug has
been fixed a while ago.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/nxml/rng-valid.el | 31 |
2 files changed, 23 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 39a55c525cc..2a1dd616ddf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,14 @@ | |||
| 1 | 2009-11-28 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2009-11-28 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | Try and remove assumptions about point-min==1. | ||
| 4 | * nxml/rng-valid.el (rng-validate-mode): Don't hardcode point-min==1. | ||
| 5 | (rng-compute-mode-line-string): Show the validation percentage in | ||
| 6 | terms of the narrowed text, not the widened text. | ||
| 7 | (rng-do-some-validation): Don't catch internal errors when debugging. | ||
| 8 | (rng-first-error): Simplify. | ||
| 9 | (rng-after-change-function): Remove work around. AFAIK the bug has | ||
| 10 | been fixed a while ago. | ||
| 11 | |||
| 3 | * image-mode.el (image-minor-mode): Exit more gracefully when the image | 12 | * image-mode.el (image-minor-mode): Exit more gracefully when the image |
| 4 | cannot be displayed (e.g. when doing C-x C-f some-new-file.svg RET). | 13 | cannot be displayed (e.g. when doing C-x C-f some-new-file.svg RET). |
| 5 | 14 | ||
diff --git a/lisp/nxml/rng-valid.el b/lisp/nxml/rng-valid.el index 4b1b7feaf52..cc5f48de6c4 100644 --- a/lisp/nxml/rng-valid.el +++ b/lisp/nxml/rng-valid.el | |||
| @@ -247,8 +247,8 @@ to use for finding the schema." | |||
| 247 | (nxml-with-unmodifying-text-property-changes | 247 | (nxml-with-unmodifying-text-property-changes |
| 248 | (rng-clear-cached-state (point-min) (point-max))) | 248 | (rng-clear-cached-state (point-min) (point-max))) |
| 249 | ;; 1+ to clear empty overlays at (point-max) | 249 | ;; 1+ to clear empty overlays at (point-max) |
| 250 | (rng-clear-overlays (point-min) (1+ (point-max)))) | 250 | (rng-clear-overlays (point-min) (1+ (point-max))) |
| 251 | (setq rng-validate-up-to-date-end 1) | 251 | (setq rng-validate-up-to-date-end (point-min))) |
| 252 | (rng-clear-conditional-region) | 252 | (rng-clear-conditional-region) |
| 253 | (setq rng-error-count 0) | 253 | (setq rng-error-count 0) |
| 254 | ;; do this here to avoid infinite loop if we set the schema | 254 | ;; do this here to avoid infinite loop if we set the schema |
| @@ -304,10 +304,6 @@ The schema is set like `rng-auto-set-schema'." | |||
| 304 | (or rng-validate-mode (rng-validate-mode))) | 304 | (or rng-validate-mode (rng-validate-mode))) |
| 305 | 305 | ||
| 306 | (defun rng-after-change-function (start end pre-change-len) | 306 | (defun rng-after-change-function (start end pre-change-len) |
| 307 | ;; Work around bug in insert-file-contents. | ||
| 308 | (when (> end (1+ (buffer-size))) | ||
| 309 | (setq start 1) | ||
| 310 | (setq end (1+ (buffer-size)))) | ||
| 311 | (setq rng-message-overlay-inhibit-point nil) | 307 | (setq rng-message-overlay-inhibit-point nil) |
| 312 | (nxml-with-unmodifying-text-property-changes | 308 | (nxml-with-unmodifying-text-property-changes |
| 313 | (rng-clear-cached-state start end)) | 309 | (rng-clear-cached-state start end)) |
| @@ -335,11 +331,13 @@ The schema is set like `rng-auto-set-schema'." | |||
| 335 | (setq rng-validate-up-to-date-end start)) | 331 | (setq rng-validate-up-to-date-end start)) |
| 336 | ;; Must make rng-validate-up-to-date-end < point-max | 332 | ;; Must make rng-validate-up-to-date-end < point-max |
| 337 | ;; (unless the buffer is empty). | 333 | ;; (unless the buffer is empty). |
| 338 | ;; otherwise validate-prepare will say there's nothing to do. | 334 | ;; otherwise rng-validate-prepare will say there's nothing to do. |
| 339 | ;; Don't use (point-max) because we may be narrowed. | 335 | (when (>= rng-validate-up-to-date-end (point-max)) |
| 340 | (if (> rng-validate-up-to-date-end (buffer-size)) | 336 | (setq rng-validate-up-to-date-end |
| 341 | (setq rng-validate-up-to-date-end | 337 | (if (< (point-min) (point-max)) |
| 342 | (max 1 (1- rng-validate-up-to-date-end)))) | 338 | (1- (point-max)) |
| 339 | ;; Only widen if really necessary. | ||
| 340 | (save-restriction (widen) (max (point-min) (1- (point-max))))))) | ||
| 343 | ;; Arrange to revalidate | 341 | ;; Arrange to revalidate |
| 344 | (rng-activate-timers) | 342 | (rng-activate-timers) |
| 345 | ;; Need to do this after activating the timer | 343 | ;; Need to do this after activating the timer |
| @@ -354,8 +352,9 @@ The schema is set like `rng-auto-set-schema'." | |||
| 354 | ;; the end. | 352 | ;; the end. |
| 355 | (floor (if (eq (buffer-size) 0) | 353 | (floor (if (eq (buffer-size) 0) |
| 356 | 0.0 | 354 | 0.0 |
| 357 | (/ (* (- rng-validate-up-to-date-end 1) 100.0) | 355 | (/ (* (- rng-validate-up-to-date-end (point-min)) |
| 358 | (buffer-size))))) | 356 | 100.0) |
| 357 | (- (point-max) (point-min)))))) | ||
| 359 | "%%")) | 358 | "%%")) |
| 360 | ((> rng-error-count 0) | 359 | ((> rng-error-count 0) |
| 361 | (concat " " | 360 | (concat " " |
| @@ -476,7 +475,7 @@ The schema is set like `rng-auto-set-schema'." | |||
| 476 | (save-restriction | 475 | (save-restriction |
| 477 | (widen) | 476 | (widen) |
| 478 | (nxml-with-invisible-motion | 477 | (nxml-with-invisible-motion |
| 479 | (condition-case err | 478 | (condition-case-no-debug err |
| 480 | (and (rng-validate-prepare) | 479 | (and (rng-validate-prepare) |
| 481 | (let ((rng-dt-namespace-context-getter '(nxml-ns-get-context))) | 480 | (let ((rng-dt-namespace-context-getter '(nxml-ns-get-context))) |
| 482 | (nxml-with-unmodifying-text-property-changes | 481 | (nxml-with-unmodifying-text-property-changes |
| @@ -809,9 +808,7 @@ Return t if there is work to do, nil otherwise." | |||
| 809 | Turn on `rng-validate-mode' if it is not already on." | 808 | Turn on `rng-validate-mode' if it is not already on." |
| 810 | (interactive) | 809 | (interactive) |
| 811 | (or rng-validate-mode (rng-validate-mode)) | 810 | (or rng-validate-mode (rng-validate-mode)) |
| 812 | (when (and (eq rng-validate-up-to-date-end 1) | 811 | (rng-do-some-validation) |
| 813 | (< rng-validate-up-to-date-end (point-max))) | ||
| 814 | (rng-do-some-validation)) | ||
| 815 | (let ((err (rng-find-next-error-overlay (1- (point-min))))) | 812 | (let ((err (rng-find-next-error-overlay (1- (point-min))))) |
| 816 | (if err | 813 | (if err |
| 817 | (rng-goto-error-overlay err) | 814 | (rng-goto-error-overlay err) |