Mercurial > hg > xemacs-beta
comparison lisp/replace.el @ 1476:d824841064f3
[xemacs-hg @ 2003-05-12 05:12:10 by youngs]
2003-05-11 Simon Josefsson <jas@extundo.com>
* replace.el (delete-non-matching-lines, kill-non-matching-lines)
(copy-non-matching-lines, delete-matching-lines)
(kill-matching-lines, copy-matching-lines): Don't message.
author | youngs |
---|---|
date | Mon, 12 May 2003 05:12:10 +0000 |
parents | 1b0339b048ce |
children | 16738b49b833 |
comparison
equal
deleted
inserted
replaced
1475:2ff4323490b9 | 1476:d824841064f3 |
---|---|
1 ;;; replace.el --- search and replace commands for XEmacs. | 1 ;;; replace.el --- search and replace commands for XEmacs. |
2 | 2 |
3 ;; Copyright (C) 1985-7, 1992, 1994, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1985-7, 1992, 1994, 1997, 2003 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Maintainer: XEmacs Development Team | 5 ;; Maintainer: XEmacs Development Team |
6 ;; Keywords: dumped, matching | 6 ;; Keywords: dumped, matching |
7 | 7 |
8 ;; This file is part of XEmacs. | 8 ;; This file is part of XEmacs. |
298 (count nil)) | 298 (count nil)) |
299 (when (region-active-p) | 299 (when (region-active-p) |
300 (setq beg (region-beginning)) | 300 (setq beg (region-beginning)) |
301 (setq end (region-end))) | 301 (setq end (region-end))) |
302 (setq count (operate-on-non-matching-lines regexp t nil beg end)) | 302 (setq count (operate-on-non-matching-lines regexp t nil beg end)) |
303 (message "%i lines deleted" count))) | 303 (when (interactive-p) |
304 (message "%i lines deleted" count)))) | |
304 | 305 |
305 (defun kill-non-matching-lines (regexp) | 306 (defun kill-non-matching-lines (regexp) |
306 "Delete the lines that do not match REGEXP, from point to the end of | 307 "Delete the lines that do not match REGEXP, from point to the end of |
307 the buffer (or within the region, if it is active). The deleted lines | 308 the buffer (or within the region, if it is active). The deleted lines |
308 are placed in the kill ring as one block of text." | 309 are placed in the kill ring as one block of text." |
314 (count nil)) | 315 (count nil)) |
315 (when (region-active-p) | 316 (when (region-active-p) |
316 (setq beg (region-beginning)) | 317 (setq beg (region-beginning)) |
317 (setq end (region-end))) | 318 (setq end (region-end))) |
318 (setq count (operate-on-non-matching-lines regexp t t beg end)) | 319 (setq count (operate-on-non-matching-lines regexp t t beg end)) |
319 (message "%i lines killed" count))) | 320 (when (interactive-p) |
321 (message "%i lines killed" count)))) | |
320 | 322 |
321 (defun copy-non-matching-lines (regexp) | 323 (defun copy-non-matching-lines (regexp) |
322 "Find all lines that do not match REGEXP from point to the end of the | 324 "Find all lines that do not match REGEXP from point to the end of the |
323 buffer (or within the region, if it is active), and place them in the | 325 buffer (or within the region, if it is active), and place them in the |
324 kill ring as one block of text." | 326 kill ring as one block of text." |
330 (count nil)) | 332 (count nil)) |
331 (when (region-active-p) | 333 (when (region-active-p) |
332 (setq beg (region-beginning)) | 334 (setq beg (region-beginning)) |
333 (setq end (region-end))) | 335 (setq end (region-end))) |
334 (setq count (operate-on-non-matching-lines regexp nil t beg end)) | 336 (setq count (operate-on-non-matching-lines regexp nil t beg end)) |
335 (message "%i lines copied" count))) | 337 (when (interactive-p) |
338 (message "%i lines copied" count)))) | |
336 | 339 |
337 (defun operate-on-matching-lines (regexp delete kill &optional beg end) | 340 (defun operate-on-matching-lines (regexp delete kill &optional beg end) |
338 "Internal function used by delete-matching-lines, kill-matching-lines, | 341 "Internal function used by delete-matching-lines, kill-matching-lines, |
339 and copy-matching-lines. | 342 and copy-matching-lines. |
340 | 343 |
391 (count nil)) | 394 (count nil)) |
392 (when (region-active-p) | 395 (when (region-active-p) |
393 (setq beg (region-beginning)) | 396 (setq beg (region-beginning)) |
394 (setq end (region-end))) | 397 (setq end (region-end))) |
395 (setq count (operate-on-matching-lines regexp t nil beg end)) | 398 (setq count (operate-on-matching-lines regexp t nil beg end)) |
396 (message "%i lines deleted" count))) | 399 (when (interactive-p) |
400 (message "%i lines deleted" count)))) | |
397 | 401 |
398 (defun kill-matching-lines (regexp) | 402 (defun kill-matching-lines (regexp) |
399 "Delete the lines that match REGEXP, from point to the end of the | 403 "Delete the lines that match REGEXP, from point to the end of the |
400 buffer (or within the region, if it is active). The deleted lines are | 404 buffer (or within the region, if it is active). The deleted lines are |
401 placed in the kill ring as one block of text." | 405 placed in the kill ring as one block of text." |
407 (count nil)) | 411 (count nil)) |
408 (when (region-active-p) | 412 (when (region-active-p) |
409 (setq beg (region-beginning)) | 413 (setq beg (region-beginning)) |
410 (setq end (region-end))) | 414 (setq end (region-end))) |
411 (setq count (operate-on-matching-lines regexp t t beg end)) | 415 (setq count (operate-on-matching-lines regexp t t beg end)) |
412 (message "%i lines killed" count))) | 416 (when (interactive-p) |
417 (message "%i lines killed" count)))) | |
413 | 418 |
414 (defun copy-matching-lines (regexp) | 419 (defun copy-matching-lines (regexp) |
415 "Find all lines that match REGEXP from point to the end of the | 420 "Find all lines that match REGEXP from point to the end of the |
416 buffer (or within the region, if it is active), and place them in the | 421 buffer (or within the region, if it is active), and place them in the |
417 kill ring as one block of text." | 422 kill ring as one block of text." |
423 (count nil)) | 428 (count nil)) |
424 (when (region-active-p) | 429 (when (region-active-p) |
425 (setq beg (region-beginning)) | 430 (setq beg (region-beginning)) |
426 (setq end (region-end))) | 431 (setq end (region-end))) |
427 (setq count (operate-on-matching-lines regexp nil t beg end)) | 432 (setq count (operate-on-matching-lines regexp nil t beg end)) |
428 (message "%i lines copied" count))) | 433 (when (interactive-p) |
434 (message "%i lines copied" count)))) | |
429 | 435 |
430 (define-function 'how-many 'count-matches) | 436 (define-function 'how-many 'count-matches) |
431 (defun count-matches (regexp) | 437 (defun count-matches (regexp) |
432 "Print number of matches for REGEXP following point." | 438 "Print number of matches for REGEXP following point." |
433 (interactive (list (read-from-minibuffer | 439 (interactive (list (read-from-minibuffer |