Article View: gnu.emacs.sources
Article #253overstrike
From: Mitchell N. Perilstein
Date: Thu, 24 Dec 1992 12:49
Date: Thu, 24 Dec 1992 12:49
58 lines
2497 bytes
2497 bytes
These three functions complement the standard distribution underline.el.
They will remove overstriking (a character, a backspace, and the
character again) from a region. Also, unattribute-region will remove
both underline and overstrike. underline.el already defines
underline-region and ununderline-region.
Dedicated to online readers of P1003.0.
(defun unoverstrike-region (start end)
"Remove all overstriking (character-backspace-character) in the region.
Called from program, takes two arguments START and END which specify the
range to operate on."
(interactive "r")
(save-excursion
(let ((end1 (make-marker)))
(move-marker end1 (max start end))
(goto-char (min start end))
(while (re-search-forward "\\(.\\)\\1" end1 t)
(delete-char -2)))))
(defun overstrike-region (start end)
"Overstrike (character-backspace-character) all nonblank characters in
the region. Called from program, takes two arguments START and END which
specify the range to operate on."
(interactive "r")
(save-excursion
(let ((end1 (make-marker)))
(move-marker end1 (max start end))
(goto-char (min start end))
(while (< (point) end1)
(or (looking-at "[_\^@- ]")
(insert (char-after (point)) 8))
(forward-char 1)))))
(defun unattribute-region (start end)
"Remove underlining and overstriking in the region. Called from a program,
takes two arguments START and END which specify the range to operate on."
(interactive "r")
(save-excursion
;; This is a piece of nuke-nroff-bs from standard `man.el'.
(goto-char (point-min))
(while (search-forward "\b" (max start end) t)
(let* ((preceding (char-after (- (point) 2)))
(following (following-char)))
(cond ((= preceding following)
;; x\bx
(delete-char -2))
((= preceding ?\_)
;; _\b
(delete-char -2))
((= following ?\_)
;; \b_
(delete-region (1- (point)) (1+ (point)))))))))
Happy/Merry,
---
Mitchell N. Perilstein CAD Language Systems, Inc. 410-992-5700 x225
Member, League for Programming Freedom. Mail lpf@uunet.uu.net for info.
Technical Details
Message-ID:
<MITCH.92Dec24124946@pollux.clsi>Path:
arc1-ca.pugleaf.net!sparky!uunet!clsi!mitchShow Full Headers
Complete Article Headers
Newsgroups: gnu.emacs.sources Path: arc1-ca.pugleaf.net!sparky!uunet!clsi!mitch From: mitch@clsi.COM (Mitchell N. Perilstein) Subject: overstrike Message-ID: <MITCH.92Dec24124946@pollux.clsi> Sender: usenet@clsi.COM Organization: CAD Language Systems, Inc. Distribution: gnu Date: 24 Dec 92 12:49:46 Lines: 58