Commit | Line | Data |
---|---|---|
d501f516 ER |
1 | ;;; underline.el --- insert/remove underlining (done by overstriking) in Emacs. |
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 | |
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 | ||
c91c4e6d ER |
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 | ||
e5167999 | 31 | ;;; Code: |
a2535589 | 32 | |
f9f9507e | 33 | ;;;###autoload |
a2535589 JA |
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 | ||
f9f9507e | 49 | ;;;###autoload |
a2535589 JA |
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))))) | |
d501f516 ER |
61 | |
62 | ;;; underline.el ends here |