(ispell-point): Do nothing if there's no word at START.
[bpt/emacs.git] / lisp / textmodes / underline.el
1 ;;; underline.el --- insert/remove underlining (done by overstriking) in Emacs.
2
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
4
5 ;; Maintainer: FSF
6 ;; Keywords: wp
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 ;;; Commentary:
25
26 ;; This package deals with the primitive form of underlining
27 ;; consisting of prefixing each character with "_\^h". The entry
28 ;; point `underline-region' performs such underlining on a region.
29 ;; The entry point `ununderline-region' removes it.
30
31 ;;; Code:
32
33 ;;;###autoload
34 (defun underline-region (start end)
35 "Underline all nonblank characters in the region.
36 Works by overstriking underscores.
37 Called from program, takes two arguments START and END
38 which specify the range to operate on."
39 (interactive "r")
40 (save-excursion
41 (let ((end1 (make-marker)))
42 (move-marker end1 (max start end))
43 (goto-char (min start end))
44 (while (< (point) end1)
45 (or (looking-at "[_\^@- ]")
46 (insert "_\b"))
47 (forward-char 1)))))
48
49 ;;;###autoload
50 (defun ununderline-region (start end)
51 "Remove all underlining (overstruck underscores) in the region.
52 Called from program, takes two arguments START and END
53 which specify the range to operate on."
54 (interactive "r")
55 (save-excursion
56 (let ((end1 (make-marker)))
57 (move-marker end1 (max start end))
58 (goto-char (min start end))
59 (while (re-search-forward "_\b\\|\b_" end1 t)
60 (delete-char -2)))))
61
62 ;;; underline.el ends here