annotate lisp/packages/underline.el @ 10:49a24b4fd526 r19-15b6

Import from CVS: tag r19-15b6
author cvs
date Mon, 13 Aug 2007 08:47:52 +0200
parents ac2d302a0011
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; underline.el --- insert/remove underlining (done by overstriking) in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: wp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
23 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
25 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; This package deals with the primitive form of underlining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; consisting of prefixing each character with "_\^h". The entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; point `underline-region' performs such underlining on a region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; The entry point `ununderline-region' removes it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defun underline-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "Underline all nonblank characters in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Works by overstriking underscores.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 Called from program, takes two arguments START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 which specify the range to operate on."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
42 ;; XEmacs: FSF doesn't use a '*', a bug? -sb
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (let ((end1 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (move-marker end1 (max start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (goto-char (min start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (while (< (point) end1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (or (looking-at "[_\^@- ]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (insert "_\b"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (forward-char 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defun ununderline-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 "Remove all underlining (overstruck underscores) in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 Called from program, takes two arguments START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 which specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (let ((end1 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (move-marker end1 (max start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (goto-char (min start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (while (re-search-forward "_\b\\|\b_" end1 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (delete-char -2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
66 ;; XEmacs: The rest of these functions are not in FSF. I don't see any
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
67 ;; point in removing them. -sb
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
68
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (defun unoverstrike-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 "Remove all overstriking (character-backspace-character) in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 Called from program, takes two arguments START and END which specify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (let ((end1 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (move-marker end1 (max start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (goto-char (min start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (while (re-search-forward "\\(.\\)\b\\1" end1 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (delete-char -2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defun overstrike-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 "Overstrike (character-backspace-character) all nonblank characters in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 the region. Called from program, takes two arguments START and END which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (let ((end1 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (move-marker end1 (max start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (goto-char (min start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (while (< (point) end1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (or (looking-at "[_\^@- ]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (insert (char-after (point)) 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (forward-char 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defun ununderline-and-unoverstrike-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 "Remove underlining and overstriking in the region. Called from a program,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 takes two arguments START and END which specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; This is a piece of nuke-nroff-bs from standard `man.el'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (while (search-forward "\b" (max start end) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (let* ((preceding (char-after (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (following (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (cond ((= preceding following)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; x\bx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (delete-char -2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ((= preceding ?\_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; _\b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (delete-char -2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ((= following ?\_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; \b_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (delete-region (1- (point)) (1+ (point)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;; underline.el ends here