Commit 1d0e3fc8 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(blink-matching-open): Get rid of text props from

the string shown in echo area.  Don't permanently set point.
Some rearrangements.
parent d502fc06
...@@ -4227,88 +4227,90 @@ If nil, search stops at the beginning of the accessible portion of the buffer." ...@@ -4227,88 +4227,90 @@ If nil, search stops at the beginning of the accessible portion of the buffer."
(defun blink-matching-open () (defun blink-matching-open ()
"Move cursor momentarily to the beginning of the sexp before point." "Move cursor momentarily to the beginning of the sexp before point."
(interactive) (interactive)
(and (> (point) (1+ (point-min))) (when (and (> (point) (1+ (point-min)))
blink-matching-paren blink-matching-paren
;; Verify an even number of quoting characters precede the close. ;; Verify an even number of quoting characters precede the close.
(= 1 (logand 1 (- (point) (= 1 (logand 1 (- (point)
(save-excursion (save-excursion
(forward-char -1) (forward-char -1)
(skip-syntax-backward "/\\") (skip-syntax-backward "/\\")
(point))))) (point))))))
(let* ((oldpos (point)) (let* ((oldpos (point))
(blinkpos) blinkpos
(mismatch) message-log-max ; Don't log messages about paren matching.
matching-paren) matching-paren
(save-excursion open-paren-line-string)
(save-restriction (save-excursion
(if blink-matching-paren-distance (save-restriction
(narrow-to-region (max (point-min) (if blink-matching-paren-distance
(- (point) blink-matching-paren-distance)) (narrow-to-region (max (point-min)
oldpos)) (- (point) blink-matching-paren-distance))
(condition-case () oldpos))
(let ((parse-sexp-ignore-comments (condition-case ()
(and parse-sexp-ignore-comments (let ((parse-sexp-ignore-comments
(not blink-matching-paren-dont-ignore-comments)))) (and parse-sexp-ignore-comments
(setq blinkpos (scan-sexps oldpos -1))) (not blink-matching-paren-dont-ignore-comments))))
(error nil))) (setq blinkpos (scan-sexps oldpos -1)))
(and blinkpos (error nil)))
;; Not syntax '$'. (and blinkpos
(not (eq (syntax-class (syntax-after blinkpos)) 8)) ;; Not syntax '$'.
(setq matching-paren (not (eq (syntax-class (syntax-after blinkpos)) 8))
(let ((syntax (syntax-after blinkpos))) (setq matching-paren
(and (consp syntax) (let ((syntax (syntax-after blinkpos)))
(eq (syntax-class syntax) 4) (and (consp syntax)
(cdr syntax))) (eq (syntax-class syntax) 4)
mismatch (cdr syntax)))))
(or (null matching-paren) (cond
(/= (char-after (1- oldpos)) ((or (null matching-paren)
matching-paren)))) (/= (char-before oldpos)
(if mismatch (setq blinkpos nil)) matching-paren))
(if blinkpos (message "Mismatched parentheses"))
;; Don't log messages about paren matching. ((not blinkpos)
(let (message-log-max) (if (not blink-matching-paren-distance)
(goto-char blinkpos) (message "Unmatched parenthesis")))
(if (pos-visible-in-window-p) ((pos-visible-in-window-p blinkpos)
(and blink-matching-paren-on-screen ;; Matching open within window, temporarily move to blinkpos but only
(sit-for blink-matching-delay)) ;; if `blink-matching-paren-on-screen' is non-nil.
(goto-char blinkpos) (when blink-matching-paren-on-screen
(message (save-excursion
"Matches %s" (goto-char blinkpos)
;; Show what precedes the open in its line, if anything. (sit-for blink-matching-delay))))
(if (save-excursion (t
(skip-chars-backward " \t") (save-excursion
(not (bolp))) (goto-char blinkpos)
(buffer-substring (progn (beginning-of-line) (point)) (setq open-paren-line-string
(1+ blinkpos)) ;; Show what precedes the open in its line, if anything.
;; Show what follows the open in its line, if anything. (if (save-excursion
(if (save-excursion (skip-chars-backward " \t")
(forward-char 1) (not (bolp)))
(skip-chars-forward " \t") (buffer-substring (line-beginning-position)
(not (eolp))) (1+ blinkpos))
(buffer-substring blinkpos ;; Show what follows the open in its line, if anything.
(progn (end-of-line) (point))) (if (save-excursion
;; Otherwise show the previous nonblank line, (forward-char 1)
;; if there is one. (skip-chars-forward " \t")
(if (save-excursion (not (eolp)))
(skip-chars-backward "\n \t") (buffer-substring blinkpos
(not (bobp))) (line-end-position))
(concat ;; Otherwise show the previous nonblank line,
(buffer-substring (progn ;; if there is one.
(if (save-excursion
(skip-chars-backward "\n \t")
(not (bobp)))
(concat
(buffer-substring (progn
(skip-chars-backward "\n \t") (skip-chars-backward "\n \t")
(beginning-of-line) (line-beginning-position))
(point)) (progn (end-of-line)
(progn (end-of-line) (skip-chars-backward " \t")
(skip-chars-backward " \t") (point)))
(point))) ;; Replace the newline and other whitespace with `...'.
;; Replace the newline and other whitespace with `...'. "..."
"..." (buffer-substring blinkpos (1+ blinkpos)))
(buffer-substring blinkpos (1+ blinkpos))) ;; There is nothing to show except the char itself.
;; There is nothing to show except the char itself. (buffer-substring blinkpos (1+ blinkpos)))))))
(buffer-substring blinkpos (1+ blinkpos)))))))) (message "Matches %s"
(cond (mismatch (substring-no-properties open-paren-line-string))))))))
(message "Mismatched parentheses"))
((not blink-matching-paren-distance)
(message "Unmatched parenthesis"))))))))
;Turned off because it makes dbx bomb out. ;Turned off because it makes dbx bomb out.
(setq blink-paren-function 'blink-matching-open) (setq blink-paren-function 'blink-matching-open)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment