home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / emacs / help / 3856 < prev    next >
Encoding:
Text File  |  1992-08-26  |  1.8 KB  |  56 lines

  1. Newsgroups: gnu.emacs.help
  2. Path: sparky!uunet!cis.ohio-state.edu!math.ep.utexas.EDU!jerry
  3. From: jerry@math.ep.utexas.EDU (Jerry)
  4. Subject: Re: Wanted: el code for highlighting region
  5. Message-ID: <9208262058.AA12972@banach.math.ep.utexas.edu>
  6. Sender: daemon@cis.ohio-state.edu
  7. Organization: Department of Mathematical Sciences--University of Texas at El Paso
  8. References: <9208261609.AA19232@next.agsm.ucla.edu>
  9. Date: Wed, 26 Aug 1992 20:58:09 GMT
  10. Lines: 44
  11.  
  12. Ivo Welch on August 26 wrote:
  13. -> 
  14. -> Interestingly enough, on a NeXT/native-NeXTSTEP-Emacs, your code  
  15. -> highlights some area close to the region, but not the entire region.
  16. -> 
  17. -> Just thought you would find this interesting.
  18.  
  19. I noticed this problem, too, and I think I have a fix.  Try this and
  20. see if it highlights only the current region.  Also, it is no longer
  21. destructive.  Thanks to Kyle (kyle@wendy-fate.uu.net) for the example
  22. from vm-highlight-headers which I used (here modified).
  23.  
  24. -Jerry
  25.  
  26. ;; ---------------- highlight-region.el ----------------------------
  27.  
  28. (defun highlight-region (p1 p2)
  29.   "Highlight the current region in reverse video."
  30.   (interactive "r")
  31.   (save-excursion
  32.     (save-restriction
  33.       (goto-char (if (> p1 p2) p2 p1))
  34.       (narrow-to-region (point-min) (point))
  35.       (sit-for 0)
  36.       (let ((inverse-video t))
  37.     (goto-char (point-min))
  38.     (widen)
  39.     (narrow-to-region (point) (if (> p1 p2) p1 p2))
  40.     (sit-for 0)))))
  41.  
  42. (defun unhighlight-region (p1 p2)
  43.   "Unhighlight the current region.  If region is displayed in reverse
  44. video, then it no longer will be."
  45.   (interactive "r")
  46.   (save-excursion
  47.     (save-restriction
  48.       (goto-char (if (> p1 p2) p2 p1))
  49.       (narrow-to-region (point-min) (point))
  50.       (sit-for 0)
  51.       (let ((inverse-video nil))
  52.     (goto-char (point-min))
  53.     (widen)
  54.     (narrow-to-region (point) (if (> p1 p2) p1 p2))
  55.     (sit-for 0)))))
  56.