comparison lisp/replace.el @ 91327:606f2d163a64

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-312
author Miles Bader <miles@gnu.org>
date Wed, 09 Jan 2008 01:21:15 +0000
parents 56a72e2bd635 107ccd98fa12
children c70e45a7acfd
comparison
equal deleted inserted replaced
91326:b1a63d7fa09c 91327:606f2d163a64
1 ;;; replace.el --- replace commands for Emacs 1 ;;; replace.el --- replace commands for Emacs
2 2
3 ;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1996, 1997, 2000, 2001, 3 ;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1996, 1997, 2000, 2001,
4 ;; 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 4 ;; 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 5
6 ;; Maintainer: FSF 6 ;; Maintainer: FSF
7 7
8 ;; This file is part of GNU Emacs. 8 ;; This file is part of GNU Emacs.
9 9
1244 (propertize "\n" 'occur-target marker))) 1244 (propertize "\n" 'occur-target marker)))
1245 (data 1245 (data
1246 (if (= nlines 0) 1246 (if (= nlines 0)
1247 ;; The simple display style 1247 ;; The simple display style
1248 out-line 1248 out-line
1249 ;; The complex multi-line display 1249 ;; The complex multi-line display style.
1250 ;; style. Generate a list of lines, 1250 (occur-context-lines out-line nlines keep-props)
1251 ;; concatenate them all together. 1251 )))
1252 (apply #'concat
1253 (nconc
1254 (occur-engine-add-prefix (nreverse (cdr (occur-accumulate-lines (- (1+ (abs nlines))) keep-props))))
1255 (list out-line)
1256 (if (> nlines 0)
1257 (occur-engine-add-prefix
1258 (cdr (occur-accumulate-lines (1+ nlines) keep-props)))))))))
1259 ;; Actually insert the match display data 1252 ;; Actually insert the match display data
1260 (with-current-buffer out-buf 1253 (with-current-buffer out-buf
1261 (let ((beg (point)) 1254 (let ((beg (point))
1262 (end (progn (insert data) (point)))) 1255 (end (progn (insert data) (point))))
1263 (unless (= nlines 0) 1256 (unless (= nlines 0)
1291 ;; buffer. 1284 ;; buffer.
1292 (set-buffer-file-coding-system coding)) 1285 (set-buffer-file-coding-system coding))
1293 ;; Return the number of matches 1286 ;; Return the number of matches
1294 globalcount))) 1287 globalcount)))
1295 1288
1289 ;; Generate context display for occur.
1290 ;; OUT-LINE is the line where the match is.
1291 ;; NLINES and KEEP-PROPS are args to occur-engine.
1292 ;; Generate a list of lines, add prefixes to all but OUT-LINE,
1293 ;; then concatenate them all together.
1294 (defun occur-context-lines (out-line nlines keep-props)
1295 (apply #'concat
1296 (nconc
1297 (occur-engine-add-prefix
1298 (nreverse (cdr (occur-accumulate-lines
1299 (- (1+ (abs nlines))) keep-props))))
1300 (list out-line)
1301 (if (> nlines 0)
1302 (occur-engine-add-prefix
1303 (cdr (occur-accumulate-lines (1+ nlines) keep-props)))))))
1296 1304
1297 ;; It would be nice to use \\[...], but there is no reasonable way 1305 ;; It would be nice to use \\[...], but there is no reasonable way
1298 ;; to make that display both SPC and Y. 1306 ;; to make that display both SPC and Y.
1299 (defconst query-replace-help 1307 (defconst query-replace-help
1300 "Type Space or `y' to replace one match, Delete or `n' to skip to next, 1308 "Type Space or `y' to replace one match, Delete or `n' to skip to next,