Fix some uses of switch-to-buffer.
[emacs.git] / lisp / textmodes / underline.el
blob2adac5a106a09c329e9b27f760be1b24d2662cd1
1 ;;; underline.el --- insert/remove underlining (done by overstriking) in Emacs
3 ;; Copyright (C) 1985, 2001-2011 Free Software Foundation, Inc.
5 ;; Maintainer: FSF
6 ;; Keywords: wp
8 ;; This file is part of GNU Emacs.
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 3 of the License, or
13 ;; (at your option) any later version.
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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
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.
30 ;;; Code:
32 ;;;###autoload
33 (defun underline-region (start end)
34 "Underline all nonblank characters in the region.
35 Works by overstriking underscores.
36 Called from program, takes two arguments START and END
37 which specify the range to operate on."
38 (interactive "*r")
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 "[_\^@- ]")
45 (insert "_\b"))
46 (forward-char 1)))))
48 ;;;###autoload
49 (defun ununderline-region (start end)
50 "Remove all underlining (overstruck underscores) in the region.
51 Called from program, takes two arguments START and END
52 which specify the range to operate on."
53 (interactive "*r")
54 (save-excursion
55 (let ((end1 (make-marker)))
56 (move-marker end1 (max start end))
57 (goto-char (min start end))
58 (while (re-search-forward "_\b\\|\b_" end1 t)
59 (delete-char -2)))))
61 (provide 'underline)
63 ;;; underline.el ends here