🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fa.editor-p
Article #282

Re: Extension languages

#282
From: utzoodecvaxharponpoivnpoisucbvax...
Date: Wed, 25 Aug 1982 03:19
72 lines
2965 bytes
>From Margolin.Multics@MIT-MULTICS Wed Aug 25 02:57:45 1982
Remailed-date: 25 Aug 1982 0014-PDT
Remailed-from: J.Q. Johnson <Admin.JQJ at SU-SCORE>
Remailed-to: Editor People: ;

While you are comparing Teco and Pascal, how about considering a Lisp
version?  Remember, Lisp interpreters are already known technology,
and much easier to implement than interpreters of strongly-typed
languages like Pascal.  The Pascal version was very nice looking, but
can you read that into a buffer, make a minor modification, type
esc-^C, and then be executing the new version right in the same Emacs
invocation?  Well, here's our code (Multics Emacs):

;;;
;;;	Query replace by Carl Hoffman
;;;


(defcom query-replace
        &arguments ((old &default
		     &eval (get-search-string "Query replace old string: "))
		(new &prompt "Query replace new string: " NL))
        (assert-minor-mode '|query replace|)
        (if (not (forward-search old))
	  (minibuffer-print "No occurrences of old string found.")
	  else
	  (query-replace-execute old new)
	  (minibuffer-print "Done."))
        (negate-minor-mode '|query replace|))

;  This function does all of the work.  When it is invoked, the point
;  is to the right of the first occurrence of the old string.

(defun query-replace-execute (old new)
       (catch (do-forever
	      (redisplay)
	      (query-replace-dispatch old new (get-char))
	      (if (not (forward-search old)) (stop-doing)))
	    done))

(defun query-replace-dispatch (old new response)
       (do-forever
         (cond ((= response #/,)
	      (query-replace-swap-strings old new)
	      (redisplay)
	      (stop-doing))
	     ((= response #/ )
	      (query-replace-swap-strings old new)
	      (stop-doing))			;don't redisplay 10/15/80
	     ((or (= response #^M)		;return = 15
		(= response 177))		;rubout = 177
	      (stop-doing))
	     ((= response #/!)		;! is replace to end
	      (query-replace-swap-strings old new)
	      (do-forever
	        (if (forward-search old) (query-replace-swap-strings old new)
		  else (throw t done))))
	     ((= response #/.)
	      (query-replace-swap-strings old new)
	      (throw t done))
	     ((or (= response #^G) (= response 33)) ;altmode
	      (throw t done))
	     ((= response #^J))		;newline = 12
	     (t (display-error-noabort "Unknown query replace response.")
	        (redisplay)))
         (setq response (get-char))))

(defun query-replace-swap-strings (old new)
       (with-mark m
	        (reverse-search old)
	        (without-saving (wipe-point-mark m))
	        (insert-string new)))
Technical Details
Message-ID: <bnews.ucb.1842>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
From: utzoo!decvax!harpo!npoiv!npois!ucbvax!ARPAVAX:C70:editor-people
Newsgroups: fa.editor-p
Title: Re: Extension languages
Article-I.D.: ucb.1842
Posted: Wed Aug 25 03:19:29 1982
Received: Tue Oct 12 03:56:33 1982
Subject: Re: Extension languages
Date: Wed, 25 Aug 1982 03:19:29 +0000
Message-ID: <bnews.ucb.1842>