home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / emacs / 2871 < prev    next >
Encoding:
Text File  |  1992-08-15  |  2.5 KB  |  69 lines

  1. Path: sparky!uunet!news.univie.ac.at!blekul11!cc11.kuleuven.ac.be!stud01
  2. Nntp-Posting-Host: 134.58.8.16
  3. Newsgroups: comp.emacs
  4. From: stud01@cc4.kuleuven.ac.be (Barbe Albert)
  5. Distribution: world
  6. References:  16H2IQINNC4I@DARKSTAR.UCSC.EDU
  7. Date: Saturday, 15 Aug 1992 00:08:31 +02
  8. Message-ID: <1992Aug15.000200@cc4.kuleuven.ac.be>
  9. Organization: K.U.Leuven - Academic Computing Center
  10. Subject: Re: Getting the functionality of the XEDIT "all" command in emacs
  11. Lines: 56
  12.  
  13. In article 16H2IQINNC4I@DARKSTAR.UCSC.EDU, FRITZ@SCIPP.UCSC.EDU writes:
  14. > Does anyone know how to get the functionality of the XEDIT "all"
  15. > command inside emacs.  You can use this command to narrow the focus of
  16. > what you are editing to any lines that match a general search
  17. > function.  So if you were editing a program file and you did "all /else/"
  18. > only lines that had an "else" in them would be displayed.  This is
  19. > very useful when editing programs and TeX files.  And I would like to
  20. > be able to do this within emacs.
  21. > --
  22. > Frederick Staats
  23. > fritz@scipp.UCSC.EDU -- (408) 459-3575
  24. > Santa Cruz Institute for Particle Physics
  25. > University of California at Santa Cruz
  26. Here is my all-function.
  27. Of course it uses emacs patterns (regular expressions)
  28.   and not XEDIT patterns .
  29. --------------------------------Cut Here----------------------
  30. ;;
  31. ;; all.el v1.00   Bert Barbe   (stud01@cc4.kuleuven.ac.be)
  32. ;; use : type          M-x all
  33. ;;       then type the pattern ( or just enter to show all lines again)
  34. ;;
  35. ;; This function uses selective-display and hides lines by changing
  36. ;;  the end of the line in control-M
  37. ;;
  38. ;; comments are allways welcome !
  39. (defun all ( patern )
  40.   (interactive "sPattern: ")
  41.   (setq selective-display t)
  42.   (if (string-equal patern "")
  43.       (unfold-all)
  44.     (setq selective-display t)
  45.     (let ((modp (buffer-modified-p)))
  46.       (unwind-protect
  47.       (save-excursion
  48.         (subst-char-in-region (point-min) (point-max)
  49.                   ?\n ?\^m  t)
  50.         (goto-char 0)
  51.         (or (char-equal ?\^m (char-after 1)) (insert-char ?\^m 1))
  52.         (while  (re-search-forward patern (point-max) t)
  53.           (save-excursion
  54.         (if (search-backward "\^m" (point-min) t)
  55.             (progn
  56.               (delete-char 1 )
  57.               (insert-char ?\n 1))
  58.           (message "Something went wrong.Pity.")))
  59.         )
  60.       )
  61.     
  62.     (set-buffer-modified-p modp)))))
  63. --------------------------------Cut Here----------------------
  64. --
  65. ------------------------------------------------------------------------
  66. Barbe Albert       stud01@cc4.kuleuven.ac.be   (AIX/370)
  67.                    FHGAA98@cc1.kuleuven.ac.be  (VM/CMS)
  68. KUL - University of Leuven (Belgium / Europe)
  69.