Mercurial > emacs
annotate lisp/textmodes/underline.el @ 79519:1039328362ed
*** empty log message ***
| author | Glenn Morris <rgm@gnu.org> |
|---|---|
| date | Sat, 01 Dec 2007 21:30:32 +0000 |
| parents | b6d25790aab2 |
| children | dc100f64b2b7 f55f9811f5d7 |
| rev | line source |
|---|---|
|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Jan?k <Pavel@Janik.cz>
parents:
24970
diff
changeset
|
1 ;;; underline.el --- insert/remove underlining (done by overstriking) in Emacs |
|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
2 |
| 74509 | 3 ;; Copyright (C) 1985, 2001, 2002, 2003, 2004, 2005, |
| 75347 | 4 ;; 2006, 2007 Free Software Foundation, Inc. |
| 841 | 5 |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
6 ;; Maintainer: FSF |
|
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: wp |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
8 |
| 36 | 9 ;; This file is part of GNU Emacs. |
| 10 | |
| 11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 12 ;; it under the terms of the GNU General Public License as published by | |
|
78225
b6d25790aab2
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75347
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
| 36 | 14 ;; any later version. |
| 15 | |
| 16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 ;; GNU General Public License for more details. | |
| 20 | |
| 21 ;; You should have received a copy of the GNU General Public License | |
| 14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
| 64084 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 24 ;; Boston, MA 02110-1301, USA. | |
| 36 | 25 |
|
2319
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
26 ;;; Commentary: |
|
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
27 |
|
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
28 ;; This package deals with the primitive form of underlining |
|
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
29 ;; consisting of prefixing each character with "_\^h". The entry |
|
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
30 ;; point `underline-region' performs such underlining on a region. |
|
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
31 ;; The entry point `ununderline-region' removes it. |
|
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
32 |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
33 ;;; Code: |
| 36 | 34 |
| 258 | 35 ;;;###autoload |
| 36 | 36 (defun underline-region (start end) |
| 37 "Underline all nonblank characters in the region. | |
| 38 Works by overstriking underscores. | |
| 39 Called from program, takes two arguments START and END | |
| 40 which specify the range to operate on." | |
|
24970
3796fd32e28d
(underline-region, ununderline-region): Add * to interactive spec.
Dave Love <fx@gnu.org>
parents:
18383
diff
changeset
|
41 (interactive "*r") |
| 36 | 42 (save-excursion |
| 43 (let ((end1 (make-marker))) | |
| 44 (move-marker end1 (max start end)) | |
| 45 (goto-char (min start end)) | |
| 46 (while (< (point) end1) | |
| 47 (or (looking-at "[_\^@- ]") | |
|
6340
e9c46ef0a877
(underline-region, ununderline-region): Use printable escapes instead of
Karl Heuer <kwzh@gnu.org>
parents:
2319
diff
changeset
|
48 (insert "_\b")) |
| 36 | 49 (forward-char 1))))) |
| 50 | |
| 258 | 51 ;;;###autoload |
| 36 | 52 (defun ununderline-region (start end) |
| 53 "Remove all underlining (overstruck underscores) in the region. | |
| 54 Called from program, takes two arguments START and END | |
| 55 which specify the range to operate on." | |
|
24970
3796fd32e28d
(underline-region, ununderline-region): Add * to interactive spec.
Dave Love <fx@gnu.org>
parents:
18383
diff
changeset
|
56 (interactive "*r") |
| 36 | 57 (save-excursion |
| 58 (let ((end1 (make-marker))) | |
| 59 (move-marker end1 (max start end)) | |
| 60 (goto-char (min start end)) | |
|
6340
e9c46ef0a877
(underline-region, ununderline-region): Use printable escapes instead of
Karl Heuer <kwzh@gnu.org>
parents:
2319
diff
changeset
|
61 (while (re-search-forward "_\b\\|\b_" end1 t) |
| 36 | 62 (delete-char -2))))) |
|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
63 |
| 18383 | 64 (provide 'underline) |
| 65 | |
| 52401 | 66 ;;; arch-tag: e7b48582-c3ea-4386-987a-87415f3c372a |
|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
67 ;;; underline.el ends here |
