Some fixes to follow coding conventions in files maintained by FSF.
[bpt/emacs.git] / lisp / textmodes / underline.el
CommitLineData
55535639 1;;; underline.el --- insert/remove underlining (done by overstriking) in Emacs
d501f516 2
58142744
ER
3;; Copyright (C) 1985 Free Software Foundation, Inc.
4
e5167999 5;; Maintainer: FSF
d7b4d18f 6;; Keywords: wp
e5167999 7
a2535589
JA
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
e5167999 12;; the Free Software Foundation; either version 2, or (at your option)
a2535589
JA
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
b578f267
EN
21;; along with GNU Emacs; see the file COPYING. If not, write to the
22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23;; Boston, MA 02111-1307, USA.
a2535589 24
c91c4e6d
ER
25;;; Commentary:
26
27;; This package deals with the primitive form of underlining
28;; consisting of prefixing each character with "_\^h". The entry
29;; point `underline-region' performs such underlining on a region.
30;; The entry point `ununderline-region' removes it.
31
e5167999 32;;; Code:
a2535589 33
f9f9507e 34;;;###autoload
a2535589
JA
35(defun underline-region (start end)
36 "Underline all nonblank characters in the region.
37Works by overstriking underscores.
38Called from program, takes two arguments START and END
39which specify the range to operate on."
8371c2f2 40 (interactive "*r")
a2535589
JA
41 (save-excursion
42 (let ((end1 (make-marker)))
43 (move-marker end1 (max start end))
44 (goto-char (min start end))
45 (while (< (point) end1)
46 (or (looking-at "[_\^@- ]")
af282089 47 (insert "_\b"))
a2535589
JA
48 (forward-char 1)))))
49
f9f9507e 50;;;###autoload
a2535589
JA
51(defun ununderline-region (start end)
52 "Remove all underlining (overstruck underscores) in the region.
53Called from program, takes two arguments START and END
54which specify the range to operate on."
8371c2f2 55 (interactive "*r")
a2535589
JA
56 (save-excursion
57 (let ((end1 (make-marker)))
58 (move-marker end1 (max start end))
59 (goto-char (min start end))
af282089 60 (while (re-search-forward "_\b\\|\b_" end1 t)
a2535589 61 (delete-char -2)))))
d501f516 62
896546cd
RS
63(provide 'underline)
64
d501f516 65;;; underline.el ends here