diff options
| author | Richard M. Stallman | 2002-09-09 00:27:30 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-09-09 00:27:30 +0000 |
| commit | 12a9371238d13d32d0fdd4dd0e95474eb08dab56 (patch) | |
| tree | a8c7802c394ebd22668e5dd6c5812ad3e137771f | |
| parent | 99b398e0a4c501e2d7fe21eaed3eb61d254afb89 (diff) | |
| download | emacs-12a9371238d13d32d0fdd4dd0e95474eb08dab56.tar.gz emacs-12a9371238d13d32d0fdd4dd0e95474eb08dab56.zip | |
(undo-elt-in-region): Fix one-off error at END.
(forward-visible-line): Handle invisibility by ignoring
invisible newlines. Also include entire invisible lines beyond
the stopping point.
| -rw-r--r-- | lisp/simple.el | 82 |
1 files changed, 53 insertions, 29 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index bfef6535b02..d9ae114a2e0 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -1089,7 +1089,7 @@ we stop and ignore all further elements." | |||
| 1089 | If it crosses the edge, we return nil." | 1089 | If it crosses the edge, we return nil." |
| 1090 | (cond ((integerp undo-elt) | 1090 | (cond ((integerp undo-elt) |
| 1091 | (and (>= undo-elt start) | 1091 | (and (>= undo-elt start) |
| 1092 | (< undo-elt end))) | 1092 | (<= undo-elt end))) |
| 1093 | ((eq undo-elt nil) | 1093 | ((eq undo-elt nil) |
| 1094 | t) | 1094 | t) |
| 1095 | ((atom undo-elt) | 1095 | ((atom undo-elt) |
| @@ -1109,16 +1109,16 @@ If it crosses the edge, we return nil." | |||
| 1109 | (cons alist-elt undo-adjusted-markers))) | 1109 | (cons alist-elt undo-adjusted-markers))) |
| 1110 | (and (cdr alist-elt) | 1110 | (and (cdr alist-elt) |
| 1111 | (>= (cdr alist-elt) start) | 1111 | (>= (cdr alist-elt) start) |
| 1112 | (< (cdr alist-elt) end)))) | 1112 | (<= (cdr alist-elt) end)))) |
| 1113 | ((null (car undo-elt)) | 1113 | ((null (car undo-elt)) |
| 1114 | ;; (nil PROPERTY VALUE BEG . END) | 1114 | ;; (nil PROPERTY VALUE BEG . END) |
| 1115 | (let ((tail (nthcdr 3 undo-elt))) | 1115 | (let ((tail (nthcdr 3 undo-elt))) |
| 1116 | (and (>= (car tail) start) | 1116 | (and (>= (car tail) start) |
| 1117 | (< (cdr tail) end)))) | 1117 | (<= (cdr tail) end)))) |
| 1118 | ((integerp (car undo-elt)) | 1118 | ((integerp (car undo-elt)) |
| 1119 | ;; (BEGIN . END) | 1119 | ;; (BEGIN . END) |
| 1120 | (and (>= (car undo-elt) start) | 1120 | (and (>= (car undo-elt) start) |
| 1121 | (< (cdr undo-elt) end))))) | 1121 | (<= (cdr undo-elt) end))))) |
| 1122 | 1122 | ||
| 1123 | (defun undo-elt-crosses-region (undo-elt start end) | 1123 | (defun undo-elt-crosses-region (undo-elt start end) |
| 1124 | "Test whether UNDO-ELT crosses one edge of that region START ... END. | 1124 | "Test whether UNDO-ELT crosses one edge of that region START ... END. |
| @@ -2104,39 +2104,65 @@ you can use this command to copy text from a read-only buffer." | |||
| 2104 | (goto-char end)))) | 2104 | (goto-char end)))) |
| 2105 | (point)))) | 2105 | (point)))) |
| 2106 | 2106 | ||
| 2107 | |||
| 2107 | (defun forward-visible-line (arg) | 2108 | (defun forward-visible-line (arg) |
| 2108 | "Move forward by ARG lines, ignoring currently invisible newlines only. | 2109 | "Move forward by ARG lines, ignoring currently invisible newlines only. |
| 2109 | If ARG is negative, move backward -ARG lines. | 2110 | If ARG is negative, move backward -ARG lines. |
| 2110 | If ARG is zero, move to the beginning of the current line." | 2111 | If ARG is zero, move to the beginning of the current line." |
| 2111 | (condition-case nil | 2112 | (condition-case nil |
| 2112 | (if (> arg 0) | 2113 | (if (> arg 0) |
| 2113 | (while (> arg 0) | 2114 | (progn |
| 2114 | (or (zerop (forward-line 1)) | 2115 | (while (> arg 0) |
| 2115 | (signal 'end-of-buffer nil)) | ||
| 2116 | ;; If the following character is currently invisible, | ||
| 2117 | ;; skip all characters with that same `invisible' property value, | ||
| 2118 | ;; then find the next newline. | ||
| 2119 | (while (and (not (eobp)) | ||
| 2120 | (let ((prop | ||
| 2121 | (get-char-property (point) 'invisible))) | ||
| 2122 | (if (eq buffer-invisibility-spec t) | ||
| 2123 | prop | ||
| 2124 | (or (memq prop buffer-invisibility-spec) | ||
| 2125 | (assq prop buffer-invisibility-spec))))) | ||
| 2126 | (goto-char | ||
| 2127 | (if (get-text-property (point) 'invisible) | ||
| 2128 | (or (next-single-property-change (point) 'invisible) | ||
| 2129 | (point-max)) | ||
| 2130 | (next-overlay-change (point)))) | ||
| 2131 | (or (zerop (forward-line 1)) | 2116 | (or (zerop (forward-line 1)) |
| 2132 | (signal 'end-of-buffer nil))) | 2117 | (signal 'end-of-buffer nil)) |
| 2133 | (setq arg (1- arg))) | 2118 | ;; If the newline we just skipped is invisible, |
| 2119 | ;; don't count it. | ||
| 2120 | (let ((prop | ||
| 2121 | (get-char-property (1- (point)) 'invisible))) | ||
| 2122 | (if (if (eq buffer-invisibility-spec t) | ||
| 2123 | prop | ||
| 2124 | (or (memq prop buffer-invisibility-spec) | ||
| 2125 | (assq prop buffer-invisibility-spec))) | ||
| 2126 | (setq arg (1+ arg)))) | ||
| 2127 | (setq arg (1- arg))) | ||
| 2128 | ;; If invisible text follows, and it is a number of complete lines, | ||
| 2129 | ;; skip it. | ||
| 2130 | (let ((opoint (point))) | ||
| 2131 | (while (and (not (eobp)) | ||
| 2132 | (let ((prop | ||
| 2133 | (get-char-property (point) 'invisible))) | ||
| 2134 | (if (eq buffer-invisibility-spec t) | ||
| 2135 | prop | ||
| 2136 | (or (memq prop buffer-invisibility-spec) | ||
| 2137 | (assq prop buffer-invisibility-spec))))) | ||
| 2138 | (goto-char | ||
| 2139 | (if (get-text-property (point) 'invisible) | ||
| 2140 | (or (next-single-property-change (point) 'invisible) | ||
| 2141 | (point-max)) | ||
| 2142 | (next-overlay-change (point))))) | ||
| 2143 | (unless (bolp) | ||
| 2144 | (goto-char opoint)))) | ||
| 2134 | (let ((first t)) | 2145 | (let ((first t)) |
| 2135 | (while (or first (< arg 0)) | 2146 | (while (or first (< arg 0)) |
| 2136 | (if (zerop arg) | 2147 | (if (zerop arg) |
| 2137 | (beginning-of-line) | 2148 | (beginning-of-line) |
| 2138 | (or (zerop (forward-line -1)) | 2149 | (or (zerop (forward-line -1)) |
| 2139 | (signal 'beginning-of-buffer nil))) | 2150 | (signal 'beginning-of-buffer nil))) |
| 2151 | ;; If the newline we just moved to is invisible, | ||
| 2152 | ;; don't count it. | ||
| 2153 | (unless (bobp) | ||
| 2154 | (let ((prop | ||
| 2155 | (get-char-property (1- (point)) 'invisible))) | ||
| 2156 | (if (if (eq buffer-invisibility-spec t) | ||
| 2157 | prop | ||
| 2158 | (or (memq prop buffer-invisibility-spec) | ||
| 2159 | (assq prop buffer-invisibility-spec))) | ||
| 2160 | (setq arg (1+ arg))))) | ||
| 2161 | (setq first nil) | ||
| 2162 | (setq arg (1+ arg))) | ||
| 2163 | ;; If invisible text follows, and it is a number of complete lines, | ||
| 2164 | ;; skip it. | ||
| 2165 | (let ((opoint (point))) | ||
| 2140 | (while (and (not (bobp)) | 2166 | (while (and (not (bobp)) |
| 2141 | (let ((prop | 2167 | (let ((prop |
| 2142 | (get-char-property (1- (point)) 'invisible))) | 2168 | (get-char-property (1- (point)) 'invisible))) |
| @@ -2148,11 +2174,9 @@ If ARG is zero, move to the beginning of the current line." | |||
| 2148 | (if (get-text-property (1- (point)) 'invisible) | 2174 | (if (get-text-property (1- (point)) 'invisible) |
| 2149 | (or (previous-single-property-change (point) 'invisible) | 2175 | (or (previous-single-property-change (point) 'invisible) |
| 2150 | (point-min)) | 2176 | (point-min)) |
| 2151 | (previous-overlay-change (point)))) | 2177 | (previous-overlay-change (point))))) |
| 2152 | (or (zerop (forward-line -1)) | 2178 | (unless (bolp) |
| 2153 | (signal 'beginning-of-buffer nil))) | 2179 | (goto-char opoint))))) |
| 2154 | (setq first nil) | ||
| 2155 | (setq arg (1+ arg))))) | ||
| 2156 | ((beginning-of-buffer end-of-buffer) | 2180 | ((beginning-of-buffer end-of-buffer) |
| 2157 | nil))) | 2181 | nil))) |
| 2158 | 2182 | ||