home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.univie.ac.at!blekul11!cc11.kuleuven.ac.be!stud01
- Nntp-Posting-Host: 134.58.8.16
- Newsgroups: comp.emacs
- From: stud01@cc4.kuleuven.ac.be (Barbe Albert)
- Distribution: world
- References: 16H2IQINNC4I@DARKSTAR.UCSC.EDU
- Date: Saturday, 15 Aug 1992 00:08:31 +02
- Message-ID: <1992Aug15.000200@cc4.kuleuven.ac.be>
- Organization: K.U.Leuven - Academic Computing Center
- Subject: Re: Getting the functionality of the XEDIT "all" command in emacs
- Lines: 56
-
- In article 16H2IQINNC4I@DARKSTAR.UCSC.EDU, FRITZ@SCIPP.UCSC.EDU writes:
- > Does anyone know how to get the functionality of the XEDIT "all"
- > command inside emacs. You can use this command to narrow the focus of
- > what you are editing to any lines that match a general search
- > function. So if you were editing a program file and you did "all /else/"
- > only lines that had an "else" in them would be displayed. This is
- > very useful when editing programs and TeX files. And I would like to
- > be able to do this within emacs.
- > --
- > Frederick Staats
- > fritz@scipp.UCSC.EDU -- (408) 459-3575
- > Santa Cruz Institute for Particle Physics
- > University of California at Santa Cruz
- Here is my all-function.
- Of course it uses emacs patterns (regular expressions)
- and not XEDIT patterns .
- --------------------------------Cut Here----------------------
- ;;
- ;; all.el v1.00 Bert Barbe (stud01@cc4.kuleuven.ac.be)
- ;; use : type M-x all
- ;; then type the pattern ( or just enter to show all lines again)
- ;;
- ;; This function uses selective-display and hides lines by changing
- ;; the end of the line in control-M
- ;;
- ;; comments are allways welcome !
- (defun all ( patern )
- (interactive "sPattern: ")
- (setq selective-display t)
- (if (string-equal patern "")
- (unfold-all)
- (setq selective-display t)
- (let ((modp (buffer-modified-p)))
- (unwind-protect
- (save-excursion
- (subst-char-in-region (point-min) (point-max)
- ?\n ?\^m t)
- (goto-char 0)
- (or (char-equal ?\^m (char-after 1)) (insert-char ?\^m 1))
- (while (re-search-forward patern (point-max) t)
- (save-excursion
- (if (search-backward "\^m" (point-min) t)
- (progn
- (delete-char 1 )
- (insert-char ?\n 1))
- (message "Something went wrong.Pity.")))
- )
- )
-
- (set-buffer-modified-p modp)))))
- --------------------------------Cut Here----------------------
- --
- ------------------------------------------------------------------------
- Barbe Albert stud01@cc4.kuleuven.ac.be (AIX/370)
- FHGAA98@cc1.kuleuven.ac.be (VM/CMS)
- KUL - University of Leuven (Belgium / Europe)
-