Annotation of 43BSDReno/contrib/emacs-18.55/lisp/cmacexp.el, revision 1.1.1.1

1.1       root        1: 
                      2: (defun c-macro-expand (beg end)
                      3:   "Display the result of expanding all C macros occurring in the region.
                      4: The expansion is entirely correct because it uses the C preprocessor."
                      5:   (interactive "r")
                      6:   (let ((outbuf (get-buffer-create "*Macroexpansion*"))
                      7:        (tempfile "%%macroexpand%%")
                      8:        process
                      9:        last-needed)
                     10:     (save-excursion
                     11:       (set-buffer outbuf)
                     12:       (erase-buffer))
                     13:     (setq process (start-process "macros" outbuf "/lib/cpp"))
                     14:     (set-process-sentinel process '(lambda (&rest x)))
                     15:     (save-restriction
                     16:       (widen)
                     17:       (save-excursion
                     18:        (goto-char beg)
                     19:        (beginning-of-line)
                     20:        (setq last-needed (point))
                     21:        (if (re-search-backward "^[ \t]*#" nil t)
                     22:            (progn
                     23:              ;; Skip continued lines.
                     24:              (while (progn (end-of-line) (= (preceding-char) ?\\))
                     25:                (forward-line 1))
                     26:              ;; Skip the last line of the macro definition we found.
                     27:              (forward-line 1)
                     28:              (setq last-needed (point)))))
                     29:       (write-region (point-min) last-needed tempfile nil 'nomsg)
                     30:       (process-send-string process (concat "#include \"" tempfile "\"\n"))
                     31:       (process-send-string process "\n")
                     32:       (process-send-region process beg end)
                     33:       (process-send-string process "\n")
                     34:       (process-send-eof process))
                     35:     (while (eq (process-status process) 'run)
                     36:       (accept-process-output))
                     37:     (delete-file tempfile)
                     38:     (save-excursion
                     39:       (set-buffer outbuf)
                     40:       (goto-char (point-max))
                     41:       (re-search-backward "\n# [12] \"\"")
                     42:       (forward-line 2)
                     43:       (while (eolp) (delete-char 1))
                     44:       (delete-region (point-min) (point)))
                     45:     (display-buffer outbuf)))

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.