diff options
| author | Richard M. Stallman | 2005-09-09 01:11:34 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-09-09 01:11:34 +0000 |
| commit | 1d0e3fc84f058248515f242c0484a0dabfac95aa (patch) | |
| tree | eeb3540813d164efe06d46e3aa05961adb4be744 | |
| parent | d502fc069259daaea123cda1a413de56d78f7004 (diff) | |
| download | emacs-1d0e3fc84f058248515f242c0484a0dabfac95aa.tar.gz emacs-1d0e3fc84f058248515f242c0484a0dabfac95aa.zip | |
(blink-matching-open): Get rid of text props from
the string shown in echo area. Don't permanently set point.
Some rearrangements.
| -rw-r--r-- | lisp/simple.el | 164 |
1 files changed, 83 insertions, 81 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index cac29e1b0f7..fe58a47610e 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -4227,88 +4227,90 @@ If nil, search stops at the beginning of the accessible portion of the buffer." | |||
| 4227 | (defun blink-matching-open () | 4227 | (defun blink-matching-open () |
| 4228 | "Move cursor momentarily to the beginning of the sexp before point." | 4228 | "Move cursor momentarily to the beginning of the sexp before point." |
| 4229 | (interactive) | 4229 | (interactive) |
| 4230 | (and (> (point) (1+ (point-min))) | 4230 | (when (and (> (point) (1+ (point-min))) |
| 4231 | blink-matching-paren | 4231 | blink-matching-paren |
| 4232 | ;; Verify an even number of quoting characters precede the close. | 4232 | ;; Verify an even number of quoting characters precede the close. |
| 4233 | (= 1 (logand 1 (- (point) | 4233 | (= 1 (logand 1 (- (point) |
| 4234 | (save-excursion | 4234 | (save-excursion |
| 4235 | (forward-char -1) | 4235 | (forward-char -1) |
| 4236 | (skip-syntax-backward "/\\") | 4236 | (skip-syntax-backward "/\\") |
| 4237 | (point))))) | 4237 | (point)))))) |
| 4238 | (let* ((oldpos (point)) | 4238 | (let* ((oldpos (point)) |
| 4239 | (blinkpos) | 4239 | blinkpos |
| 4240 | (mismatch) | 4240 | message-log-max ; Don't log messages about paren matching. |
| 4241 | matching-paren) | 4241 | matching-paren |
| 4242 | (save-excursion | 4242 | open-paren-line-string) |
| 4243 | (save-restriction | 4243 | (save-excursion |
| 4244 | (if blink-matching-paren-distance | 4244 | (save-restriction |
| 4245 | (narrow-to-region (max (point-min) | 4245 | (if blink-matching-paren-distance |
| 4246 | (- (point) blink-matching-paren-distance)) | 4246 | (narrow-to-region (max (point-min) |
| 4247 | oldpos)) | 4247 | (- (point) blink-matching-paren-distance)) |
| 4248 | (condition-case () | 4248 | oldpos)) |
| 4249 | (let ((parse-sexp-ignore-comments | 4249 | (condition-case () |
| 4250 | (and parse-sexp-ignore-comments | 4250 | (let ((parse-sexp-ignore-comments |
| 4251 | (not blink-matching-paren-dont-ignore-comments)))) | 4251 | (and parse-sexp-ignore-comments |
| 4252 | (setq blinkpos (scan-sexps oldpos -1))) | 4252 | (not blink-matching-paren-dont-ignore-comments)))) |
| 4253 | (error nil))) | 4253 | (setq blinkpos (scan-sexps oldpos -1))) |
| 4254 | (and blinkpos | 4254 | (error nil))) |
| 4255 | ;; Not syntax '$'. | 4255 | (and blinkpos |
| 4256 | (not (eq (syntax-class (syntax-after blinkpos)) 8)) | 4256 | ;; Not syntax '$'. |
| 4257 | (setq matching-paren | 4257 | (not (eq (syntax-class (syntax-after blinkpos)) 8)) |
| 4258 | (let ((syntax (syntax-after blinkpos))) | 4258 | (setq matching-paren |
| 4259 | (and (consp syntax) | 4259 | (let ((syntax (syntax-after blinkpos))) |
| 4260 | (eq (syntax-class syntax) 4) | 4260 | (and (consp syntax) |
| 4261 | (cdr syntax))) | 4261 | (eq (syntax-class syntax) 4) |
| 4262 | mismatch | 4262 | (cdr syntax))))) |
| 4263 | (or (null matching-paren) | 4263 | (cond |
| 4264 | (/= (char-after (1- oldpos)) | 4264 | ((or (null matching-paren) |
| 4265 | matching-paren)))) | 4265 | (/= (char-before oldpos) |
| 4266 | (if mismatch (setq blinkpos nil)) | 4266 | matching-paren)) |
| 4267 | (if blinkpos | 4267 | (message "Mismatched parentheses")) |
| 4268 | ;; Don't log messages about paren matching. | 4268 | ((not blinkpos) |
| 4269 | (let (message-log-max) | 4269 | (if (not blink-matching-paren-distance) |
| 4270 | (goto-char blinkpos) | 4270 | (message "Unmatched parenthesis"))) |
| 4271 | (if (pos-visible-in-window-p) | 4271 | ((pos-visible-in-window-p blinkpos) |
| 4272 | (and blink-matching-paren-on-screen | 4272 | ;; Matching open within window, temporarily move to blinkpos but only |
| 4273 | (sit-for blink-matching-delay)) | 4273 | ;; if `blink-matching-paren-on-screen' is non-nil. |
| 4274 | (goto-char blinkpos) | 4274 | (when blink-matching-paren-on-screen |
| 4275 | (message | 4275 | (save-excursion |
| 4276 | "Matches %s" | 4276 | (goto-char blinkpos) |
| 4277 | ;; Show what precedes the open in its line, if anything. | 4277 | (sit-for blink-matching-delay)))) |
| 4278 | (if (save-excursion | 4278 | (t |
| 4279 | (skip-chars-backward " \t") | 4279 | (save-excursion |
| 4280 | (not (bolp))) | 4280 | (goto-char blinkpos) |
| 4281 | (buffer-substring (progn (beginning-of-line) (point)) | 4281 | (setq open-paren-line-string |
| 4282 | (1+ blinkpos)) | 4282 | ;; Show what precedes the open in its line, if anything. |
| 4283 | ;; Show what follows the open in its line, if anything. | 4283 | (if (save-excursion |
| 4284 | (if (save-excursion | 4284 | (skip-chars-backward " \t") |
| 4285 | (forward-char 1) | 4285 | (not (bolp))) |
| 4286 | (skip-chars-forward " \t") | 4286 | (buffer-substring (line-beginning-position) |
| 4287 | (not (eolp))) | 4287 | (1+ blinkpos)) |
| 4288 | (buffer-substring blinkpos | 4288 | ;; Show what follows the open in its line, if anything. |
| 4289 | (progn (end-of-line) (point))) | 4289 | (if (save-excursion |
| 4290 | ;; Otherwise show the previous nonblank line, | 4290 | (forward-char 1) |
| 4291 | ;; if there is one. | 4291 | (skip-chars-forward " \t") |
| 4292 | (if (save-excursion | 4292 | (not (eolp))) |
| 4293 | (skip-chars-backward "\n \t") | 4293 | (buffer-substring blinkpos |
| 4294 | (not (bobp))) | 4294 | (line-end-position)) |
| 4295 | (concat | 4295 | ;; Otherwise show the previous nonblank line, |
| 4296 | (buffer-substring (progn | 4296 | ;; if there is one. |
| 4297 | (if (save-excursion | ||
| 4298 | (skip-chars-backward "\n \t") | ||
| 4299 | (not (bobp))) | ||
| 4300 | (concat | ||
| 4301 | (buffer-substring (progn | ||
| 4297 | (skip-chars-backward "\n \t") | 4302 | (skip-chars-backward "\n \t") |
| 4298 | (beginning-of-line) | 4303 | (line-beginning-position)) |
| 4299 | (point)) | 4304 | (progn (end-of-line) |
| 4300 | (progn (end-of-line) | 4305 | (skip-chars-backward " \t") |
| 4301 | (skip-chars-backward " \t") | 4306 | (point))) |
| 4302 | (point))) | 4307 | ;; Replace the newline and other whitespace with `...'. |
| 4303 | ;; Replace the newline and other whitespace with `...'. | 4308 | "..." |
| 4304 | "..." | 4309 | (buffer-substring blinkpos (1+ blinkpos))) |
| 4305 | (buffer-substring blinkpos (1+ blinkpos))) | 4310 | ;; There is nothing to show except the char itself. |
| 4306 | ;; There is nothing to show except the char itself. | 4311 | (buffer-substring blinkpos (1+ blinkpos))))))) |
| 4307 | (buffer-substring blinkpos (1+ blinkpos)))))))) | 4312 | (message "Matches %s" |
| 4308 | (cond (mismatch | 4313 | (substring-no-properties open-paren-line-string)))))))) |
| 4309 | (message "Mismatched parentheses")) | ||
| 4310 | ((not blink-matching-paren-distance) | ||
| 4311 | (message "Unmatched parenthesis")))))))) | ||
| 4312 | 4314 | ||
| 4313 | ;Turned off because it makes dbx bomb out. | 4315 | ;Turned off because it makes dbx bomb out. |
| 4314 | (setq blink-paren-function 'blink-matching-open) | 4316 | (setq blink-paren-function 'blink-matching-open) |