home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.help
- Path: sparky!uunet!cis.ohio-state.edu!math.ep.utexas.EDU!jerry
- From: jerry@math.ep.utexas.EDU (Jerry)
- Subject: Re: Wanted: el code for highlighting region
- Message-ID: <9208262058.AA12972@banach.math.ep.utexas.edu>
- Sender: daemon@cis.ohio-state.edu
- Organization: Department of Mathematical Sciences--University of Texas at El Paso
- References: <9208261609.AA19232@next.agsm.ucla.edu>
- Date: Wed, 26 Aug 1992 20:58:09 GMT
- Lines: 44
-
- Ivo Welch on August 26 wrote:
- ->
- -> Interestingly enough, on a NeXT/native-NeXTSTEP-Emacs, your code
- -> highlights some area close to the region, but not the entire region.
- ->
- -> Just thought you would find this interesting.
-
- I noticed this problem, too, and I think I have a fix. Try this and
- see if it highlights only the current region. Also, it is no longer
- destructive. Thanks to Kyle (kyle@wendy-fate.uu.net) for the example
- from vm-highlight-headers which I used (here modified).
-
- -Jerry
-
- ;; ---------------- highlight-region.el ----------------------------
-
- (defun highlight-region (p1 p2)
- "Highlight the current region in reverse video."
- (interactive "r")
- (save-excursion
- (save-restriction
- (goto-char (if (> p1 p2) p2 p1))
- (narrow-to-region (point-min) (point))
- (sit-for 0)
- (let ((inverse-video t))
- (goto-char (point-min))
- (widen)
- (narrow-to-region (point) (if (> p1 p2) p1 p2))
- (sit-for 0)))))
-
- (defun unhighlight-region (p1 p2)
- "Unhighlight the current region. If region is displayed in reverse
- video, then it no longer will be."
- (interactive "r")
- (save-excursion
- (save-restriction
- (goto-char (if (> p1 p2) p2 p1))
- (narrow-to-region (point-min) (point))
- (sit-for 0)
- (let ((inverse-video nil))
- (goto-char (point-min))
- (widen)
- (narrow-to-region (point) (if (> p1 p2) p1 p2))
- (sit-for 0)))))
-