Fix case-folding in Occur

* lisp/replace.el (occur-engine): Bind case-fold-search in each
buffer we search.  (Bug#29254)
This commit is contained in:
Eli Zaretskii 2017-11-18 13:06:22 +02:00
parent 29520b083f
commit cbd319a351

View file

@ -1643,6 +1643,11 @@ See also `multi-occur'."
(inhibit-field-text-motion t)
(headerpt (with-current-buffer out-buf (point))))
(with-current-buffer buf
;; The following binding is for when case-fold-search
;; has a local binding in the original buffer, in which
;; case we cannot bind it globally and let that have
;; effect in every buffer we search.
(let ((case-fold-search case-fold))
(or coding
;; Set CODING only if the current buffer locally
;; binds buffer-file-coding-system.
@ -1694,11 +1699,13 @@ See also `multi-occur'."
(when prefix-face
`(font-lock-face ,prefix-face))
`(occur-prefix t mouse-face (highlight)
;; Allow insertion of text at
;; the end of the prefix (for
;; Occur Edit mode).
front-sticky t rear-nonsticky t
occur-target ,marker follow-link t
;; Allow insertion of text
;; at the end of the prefix
;; (for Occur Edit mode).
front-sticky t
rear-nonsticky t
occur-target ,marker
follow-link t
help-echo "mouse-2: go to this occurrence"))))
(match-str
;; We don't put `mouse-face' on the newline,
@ -1717,7 +1724,8 @@ See also `multi-occur'."
(replace-regexp-in-string
"\n"
(if prefix-face
(propertize "\n :" 'font-lock-face prefix-face)
(propertize
"\n :" 'font-lock-face prefix-face)
"\n :")
match-str)
;; Add marker at eol, but no mouse props.
@ -1728,9 +1736,9 @@ See also `multi-occur'."
out-line
;; The complex multi-line display style.
(setq ret (occur-context-lines
out-line nlines keep-props begpt endpt
curr-line prev-line prev-after-lines
prefix-face))
out-line nlines keep-props begpt
endpt curr-line prev-line
prev-after-lines prefix-face))
;; Set first elem of the returned list to `data',
;; and the second elem to `prev-after-lines'.
(setq prev-after-lines (nth 1 ret))
@ -1755,8 +1763,9 @@ See also `multi-occur'."
(progn
;; Sum line numbers between first and last match lines.
(setq curr-line (+ curr-line (count-lines begpt endpt)
;; Add 1 for empty last match line since
;; count-lines returns 1 line less.
;; Add 1 for empty last match line
;; since count-lines returns one
;; line less.
(if (and (bolp) (eolp)) 1 0)))
;; On to the next match...
(forward-line 1))
@ -1793,7 +1802,8 @@ See also `multi-occur'."
;; and matches in case of 1 match per line.
(if (= lines matches)
"" (format " in %d line%s"
lines (if (= lines 1) "" "s")))
lines
(if (= lines 1) "" "s")))
;; Don't display regexp for multi-buffer.
(if (> (length buffers) 1)
"" (occur-regexp-descr regexp))
@ -1811,7 +1821,7 @@ See also `multi-occur'."
(goto-char (if finalpt
(setq occur--final-pos
(cl-incf finalpt (- end beg)))
(point-min)))))))))
(point-min))))))))))
;; Display total match count and regexp for multi-buffer.
(when (and (not (zerop global-lines)) (> (length buffers) 1))
(goto-char (point-min))