scheme interaction mode
[bpt/emacs.git] / lisp / textmodes / underline.el
CommitLineData
55535639 1;;; underline.el --- insert/remove underlining (done by overstriking) in Emacs
d501f516 2
ba318903 3;; Copyright (C) 1985, 2001-2014 Free Software Foundation, Inc.
58142744 4
34dc21db 5;; Maintainer: emacs-devel@gnu.org
d7b4d18f 6;; Keywords: wp
e5167999 7
a2535589
JA
8;; This file is part of GNU Emacs.
9
1fecc8fe 10;; GNU Emacs is free software: you can redistribute it and/or modify
a2535589 11;; it under the terms of the GNU General Public License as published by
1fecc8fe
GM
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
a2535589
JA
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
1fecc8fe 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
a2535589 22
c91c4e6d
ER
23;;; Commentary:
24
25;; This package deals with the primitive form of underlining
26;; consisting of prefixing each character with "_\^h". The entry
27;; point `underline-region' performs such underlining on a region.
28;; The entry point `ununderline-region' removes it.
29
e5167999 30;;; Code:
a2535589 31
f9f9507e 32;;;###autoload
a2535589
JA
33(defun underline-region (start end)
34 "Underline all nonblank characters in the region.
35Works by overstriking underscores.
36Called from program, takes two arguments START and END
37which specify the range to operate on."
8371c2f2 38 (interactive "*r")
a2535589
JA
39 (save-excursion
40 (let ((end1 (make-marker)))
41 (move-marker end1 (max start end))
42 (goto-char (min start end))
43 (while (< (point) end1)
44 (or (looking-at "[_\^@- ]")
af282089 45 (insert "_\b"))
a2535589
JA
46 (forward-char 1)))))
47
f9f9507e 48;;;###autoload
a2535589
JA
49(defun ununderline-region (start end)
50 "Remove all underlining (overstruck underscores) in the region.
51Called from program, takes two arguments START and END
52which specify the range to operate on."
8371c2f2 53 (interactive "*r")
a2535589
JA
54 (save-excursion
55 (let ((end1 (make-marker)))
56 (move-marker end1 (max start end))
57 (goto-char (min start end))
af282089 58 (while (re-search-forward "_\b\\|\b_" end1 t)
a2535589 59 (delete-char -2)))))
d501f516 60
896546cd
RS
61(provide 'underline)
62
d501f516 63;;; underline.el ends here