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