🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gnu.emacs.sources
1 messages
1 total messages Started by Mitchell N. Perilstein Thu, 24 Dec 1992 12:49
overstrike
#253
Author: Mitchell N. Perilstein
Date: Thu, 24 Dec 1992 12:49
58 lines
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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads