help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About the history of Emacs


From: WJ
Subject: Re: About the history of Emacs
Date: 14 Dec 2012 23:49:25 GMT
User-agent: XanaNews/1.18.1.6

Pascal J. Bourguignon wrote:

> Here is an emacs macro (TECO emacs):
> http://pdp-10.trailing-edge.com/mit_emacs_170_teco_1220/index.html
> 
> !& Abstract Macro:! !S Abstract a single macro.
> Inserts the full name of the specified macro,
> and all of its documentation, and then a blank line.
> Give the macro name string pointer as a numeric argument.!
>     M(M.M&_MACRO_NAME)[0          !* Get full name of macro in q0!
>     g0 .i 15.i 12.i               !* Put it, and CRLF, in buffer.!
>     .[1 g(m.m~DOC~_0)     !* Insert its documentation on the buffer.!
>     0@f"n i                       !* Put in a CRLF at end if there is none.!
> '
>     fsz-.f[vz
>       q1j s_ q1,.k                !* Flush the macro class.!
>       < 9i l .-z;>                !* Insert a tab before each line of doc.!
>       q1j < :s; -d>              !* Delete all the ^\'s from the doc 
> strings.!
>       zj f]vz
>     
> 
> 
> 
> Here is another emacs macro (GNU emacs):
> 
> (defun insert-string (&rest args)
>   "Mocklisp-compatibility insert function.
> Like the function `insert' except that any argument that is a number
> is converted into a string by expressing it in decimal."
>   (dolist (el args)
>     (insert (if (integerp el) (number-to-string el) el))))

Here's a version that handles floating-point numbers and
symbols:

(defun insert-string (&rest args)
  (insert (with-output-to-string
    (dolist (el args)
      (princ el)))))


Here's another interesting function:

(defun string-scan (regexp str)
  (let ((start 0) result)
    (while (string-match regexp str start)
      (push (apply #'substring str (last (match-data) 2)) result)
      (setq start (match-end 0)))
    (reverse result)))

Let's use it to extract the TECO comments:

(mapc (lambda (s) (princ s) (terpri) (terpri))
  (string-scan "!\\([^!]+\\)!"
"!& Abstract Macro:! !S Abstract a single macro.
Inserts the full name of the specified macro,
and all of its documentation, and then a blank line.
Give the macro name string pointer as a numeric argument.!
    M(M.M&_MACRO_NAME)[0            !* Get full name of macro in q0!
    g0 .i 15.i 12.i                 !* Put it, and CRLF, in buffer.!
    .[1 g(m.m~DOC~_0)       !* Insert its documentation on the buffer.!
    0@f\"n i                        !* Put in a CRLF at end if there is none.!
'
    fsz-.f[vz
      q1j s_ q1,.k                  !* Flush the macro class.!
      < 9i l .-z;>                  !* Insert a tab before each line of doc.!
      q1j < :s^[; -d>               !* Delete all the ^\'s from the doc 
strings.!
      zj f]vz" ))

& Abstract Macro:

S Abstract a single macro.
Inserts the full name of the specified macro,
and all of its documentation, and then a blank line.
Give the macro name string pointer as a numeric argument.

* Get full name of macro in q0

* Put it, and CRLF, in buffer.

* Insert its documentation on the buffer.

* Put in a CRLF at end if there is none.

* Flush the macro class.

* Insert a tab before each line of doc.

* Delete all the ^'s from the doc strings.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]