Mercurial > emacs
comparison lisp/replace.el @ 48276:3a5bc7e171a5
(occur-engine): Set buffer-file-coding-system of
OUT-BUF to that of one of BUFFERS if they locally bind that
variable.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 13 Nov 2002 07:06:07 +0000 |
parents | b0db4f794e73 |
children | e88404e8f2cf |
comparison
equal
deleted
inserted
replaced
48275:481dbc5a687e | 48276:3a5bc7e171a5 |
---|---|
771 | 771 |
772 (defun occur-engine (regexp buffers out-buf nlines case-fold-search | 772 (defun occur-engine (regexp buffers out-buf nlines case-fold-search |
773 title-face prefix-face match-face keep-props) | 773 title-face prefix-face match-face keep-props) |
774 (with-current-buffer out-buf | 774 (with-current-buffer out-buf |
775 (setq buffer-read-only nil) | 775 (setq buffer-read-only nil) |
776 (let ((globalcount 0)) | 776 (let ((globalcount 0) |
777 (coding nil)) | |
777 ;; Map over all the buffers | 778 ;; Map over all the buffers |
778 (dolist (buf buffers) | 779 (dolist (buf buffers) |
779 (when (buffer-live-p buf) | 780 (when (buffer-live-p buf) |
780 (let ((matches 0) ;; count of matched lines | 781 (let ((matches 0) ;; count of matched lines |
781 (lines 1) ;; line count | 782 (lines 1) ;; line count |
787 (marker nil) | 788 (marker nil) |
788 (curstring "") | 789 (curstring "") |
789 (headerpt (with-current-buffer out-buf (point)))) | 790 (headerpt (with-current-buffer out-buf (point)))) |
790 (save-excursion | 791 (save-excursion |
791 (set-buffer buf) | 792 (set-buffer buf) |
793 (or coding | |
794 ;; Set CODING only if the current buffer locally | |
795 ;; binds buffer-file-coding-system. | |
796 (not (local-variable-p 'buffer-file-coding-system)) | |
797 (setq coding buffer-file-coding-system)) | |
792 (save-excursion | 798 (save-excursion |
793 (goto-char (point-min)) ;; begin searching in the buffer | 799 (goto-char (point-min)) ;; begin searching in the buffer |
794 (while (not (eobp)) | 800 (while (not (eobp)) |
795 (setq origpt (point)) | 801 (setq origpt (point)) |
796 (when (setq endpt (re-search-forward regexp nil t)) | 802 (when (setq endpt (re-search-forward regexp nil t)) |
876 (append | 882 (append |
877 (when title-face | 883 (when title-face |
878 `(font-lock-face ,title-face)) | 884 `(font-lock-face ,title-face)) |
879 `(occur-title ,buf)))) | 885 `(occur-title ,buf)))) |
880 (goto-char (point-min))))))) | 886 (goto-char (point-min))))))) |
887 (if coding | |
888 ;; CODING is buffer-file-coding-system of the first buffer | |
889 ;; that locally binds it. Let's use it also for the output | |
890 ;; buffer. | |
891 (set-buffer-file-coding-system coding)) | |
881 ;; Return the number of matches | 892 ;; Return the number of matches |
882 globalcount))) | 893 globalcount))) |
883 | 894 |
884 | 895 |
885 ;; It would be nice to use \\[...], but there is no reasonable way | 896 ;; It would be nice to use \\[...], but there is no reasonable way |