Changeset 6665


Ignore:
Timestamp:
Jun 3, 2007, 2:58:06 AM (17 years ago)
Author:
Gary Byers
Message:

New selection-stream scheme.
Macroexpand prints to listener output stream.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ide-1.0/ccl/hemlock/src/listener.lisp

    r6572 r6665  
    7373        :buffer buffer
    7474        :value (copy-mark point :right-inserting))
     75      (defhvar "Buffer Output Mark"
     76        "Mark used for Listener Mode output."
     77        :buffer buffer
     78        :value (copy-mark point :left-inserting))
    7579      (defhvar "Interactive History"
    7680        "A ring of the regions input to an interactive mode (Eval or Typescript)."
     
    121125         (output-end (region-end output-region)))
    122126    (hi::with-active-font-region (buffer output-region)
    123       (insert-string output-end string)
     127      (with-mark ((output-mark output-end :left-inserting))
     128        ;(setf (mark-charpos output-mark) 0)
     129        (insert-string output-mark string))
    124130      (move-mark (variable-value 'buffer-input-mark :buffer buffer)
    125131                 output-end))))
     
    486492                    (path (buffer-pathname (current-buffer))))
    487493  (evaluate-input-selection
    488    (ccl::make-input-selection
    489     :package package
    490     :source-file path
    491     :string-stream (make-string-input-stream
    492                     (region-to-string region)))))                   
     494   (list package path (region-to-string region))))
    493495       
    494496                                       
     
    540542       (message "Evaluation returned ~S" (eval form))))))
    541543
    542 (defcommand "Editor Macroexpand Expression" (p)
     544(defun macroexpand-expression (expander)
     545  (let* ((out (hi::top-listener-output-stream)))
     546    (when out
     547      (let* ((point (buffer-point (current-buffer)))
     548             (region (if (region-active-p)
     549                       (current-region)
     550                       (with-mark ((start point))
     551                         (pre-command-parse-check start)
     552                         (with-mark ((end start))
     553                           (unless (form-offset end 1) (editor-error))
     554                           (region start end)))))
     555             (expr (with-input-from-region (s region)
     556                           (read s))))
     557        (let* ((*print-pretty* t))
     558          (format out "~&~s~&" (funcall expander expr)))))))
     559
     560(defcommand "Editor Macroexpand-1 Expression" (p)
    543561  "Show the macroexpansion of the current expression in the null environment.
    544562   With an argument, use MACROEXPAND instead of MACROEXPAND-1."
    545563  "Show the macroexpansion of the current expression in the null environment.
    546564   With an argument, use MACROEXPAND instead of MACROEXPAND-1."
    547   (let ((point (buffer-point (current-buffer))))
    548     (with-mark ((start point))
    549       (pre-command-parse-check start)
    550       (with-mark ((end start))
    551         (unless (form-offset end 1) (editor-error))
    552         (in-lisp
    553          (with-pop-up-display (rts)
    554            (write-string (with-input-from-region (s (region start end))
    555                            (prin1-to-string (funcall (if p
    556                                                          'macroexpand
    557                                                          'macroexpand-1)
    558                                                      (read s))))
    559                          rts)))))))
     565  (macroexpand-expression (if p 'macroexpand 'macroexpand-1)))
     566
     567(defcommand "Editor Macroexpand Expression" (p)
     568  "Show the macroexpansion of the current expression in the null environment.
     569   With an argument, use MACROEXPAND-1 instead of MACROEXPAND."
     570  "Show the macroexpansion of the current expression in the null environment.
     571   With an argument, use MACROEXPAND-1 instead of MACROEXPAND."
     572  (macroexpand-expression (if p 'macroexpand-1 'macroexpand)))
     573
    560574
    561575(defcommand "Editor Evaluate Expression" (p)
Note: See TracChangeset for help on using the changeset viewer.