annotate lisp/packages/underline.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; This package deals with the primitive form of underlining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; consisting of prefixing each character with "_\^h". The entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; point `underline-region' performs such underlining on a region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; The entry point `ununderline-region' removes it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (defun underline-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 "Underline all nonblank characters in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 Works by overstriking underscores.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Called from program, takes two arguments START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 which specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (let ((end1 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (move-marker end1 (max start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (goto-char (min start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (while (< (point) end1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (or (looking-at "[_\^@- ]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (insert "_\b"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (forward-char 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defun ununderline-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "Remove all underlining (overstruck underscores) in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 Called from program, takes two arguments START and END
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 which specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (let ((end1 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (move-marker end1 (max start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (goto-char (min start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (while (re-search-forward "_\b\\|\b_" end1 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (delete-char -2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defun unoverstrike-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "Remove all overstriking (character-backspace-character) in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 Called from program, takes two arguments START and END which specify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (let ((end1 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (move-marker end1 (max start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (goto-char (min start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (while (re-search-forward "\\(.\\)\b\\1" end1 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (delete-char -2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defun overstrike-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 "Overstrike (character-backspace-character) all nonblank characters in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 the region. Called from program, takes two arguments START and END which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (let ((end1 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (move-marker end1 (max start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (goto-char (min start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (while (< (point) end1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (or (looking-at "[_\^@- ]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (insert (char-after (point)) 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (forward-char 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defun ununderline-and-unoverstrike-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "Remove underlining and overstriking in the region. Called from a program,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 takes two arguments START and END which specify the range to operate on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; This is a piece of nuke-nroff-bs from standard `man.el'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (while (search-forward "\b" (max start end) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (let* ((preceding (char-after (- (point) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (following (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (cond ((= preceding following)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; x\bx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (delete-char -2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ((= preceding ?\_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; _\b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (delete-char -2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ((= following ?\_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; \b_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (delete-region (1- (point)) (1+ (point)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; underline.el ends here