home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / emacs-15.0.3 / lisp / underline.el < prev    next >
Lisp/Scheme  |  1990-07-19  |  2KB  |  48 lines

  1. ;; Insert or remove underlining (done by overstriking) in Emacs.
  2. ;; Copyright (C) 1985 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of GNU Emacs.
  5.  
  6. ;; GNU Emacs is distributed in the hope that it will be useful,
  7. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  8. ;; accepts responsibility to anyone for the consequences of using it
  9. ;; or for whether it serves any particular purpose or works at all,
  10. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  11. ;; License for full details.
  12.  
  13. ;; Everyone is granted permission to copy, modify and redistribute
  14. ;; GNU Emacs, but only under the conditions described in the
  15. ;; GNU Emacs General Public License.   A copy of this license is
  16. ;; supposed to have been given to you along with GNU Emacs so you
  17. ;; can know your rights and responsibilities.  It should be in a
  18. ;; file named COPYING.  Among other things, the copyright notice
  19. ;; and this notice must be preserved on all copies.
  20.  
  21.  
  22. (defun underline-region (start end)
  23.   "Underline all nonblank characters in the region.
  24. Works by overstriking underscores.
  25. Called from program, takes two arguments START and END
  26. which specify the range to operate on."
  27.   (interactive "r")
  28.   (save-excursion
  29.    (let ((end1 (make-marker)))
  30.      (move-marker end1 (max start end))
  31.      (goto-char (min start end))
  32.      (while (< (point) end1)
  33.        (or (looking-at "[_\^@- ]")
  34.        (insert "_"))
  35.        (forward-char 1)))))
  36.  
  37. (defun ununderline-region (start end)
  38.   "Remove all underlining (overstruck underscores) in the region.
  39. Called from program, takes two arguments START and END
  40. which specify the range to operate on."
  41.   (interactive "r")
  42.   (save-excursion
  43.    (let ((end1 (make-marker)))
  44.      (move-marker end1 (max start end))
  45.      (goto-char (min start end))
  46.      (while (search-forward "_" end1 t)
  47.        (delete-char -2)))))
  48.