[slime-devel] Re: Not exactly 'presentation types for emacs' but useful anyway

Alan Ruttenberg alanr-l at mumble.net
Wed May 18 15:41:31 UTC 2005


Well, this isn't exactly elegant, but I think it has the desired 
behavior of making the thing act as an unmodifiable unit. A command 
that deletes, executed in the middle of the unit deletes the whole unit 
as does forward delete at the beginning and backward delete at the end. 
Insertion commands in the middle don't do anything.

Might need to add some more 'action-type properties. Beware that if an 
error occurs in the command hook, it is removed. So if it stops working 
then that's what happened.

(defun slime-setup-command-hooks ()
   "Setup a buffer-local `pre-command-hook' to call 
`slime-pre-command-hook'."
   (make-local-hook 'pre-command-hook)
   (make-local-hook 'post-command-hook)
   (add-hook 'pre-command-hook 'slime-pre-command-hook)
   (add-hook 'post-command-hook 'slime-post-command-hook)
   (add-hook 'pre-command-hook 'slime-presentation-command-hook)) ;; 
this is the new one

(defun slime-presentation-command-hook ()
   (let* ((props-here (text-properties-at (point)))
          (props-before (text-properties-at (1- (point))))
          (inside (and (getf props-here 'slime-repl-old-output)))
          (at-beginning (and inside (not (getf props-before 
'slime-repl-old-output))))
          (at-end (and (or (= (point) (point-max)) (not (getf props-here 
'slime-repl-old-output)))
                       (getf props-before 'slime-repl-old-output)))
          (start (cond (at-beginning (point))
                       (inside (previous-single-property-change (point) 
'slime-repl-old-output))
                       (at-end (previous-single-property-change (1- 
(point)) 'slime-repl-old-output))))
          (end (cond (at-beginning (or (next-single-property-change 
(point) 'slime-repl-old-output) (point-max)))
                     (inside (or (next-single-property-change (point) 
'slime-repl-old-output) (point-max)))
                     (at-end (point)))))
     (when (and (or inside at-end) start end (> end start))
       (let ((kind (get this-command 'action-type)))
         (cond ((and (eq kind 'inserts) inside (not at-beginning))
                (setq this-command 'ignore-event))
               ((and (eq kind 'deletes-forward) inside (not at-end))
                (kill-region start end)
                (setq this-command 'ignore-event))
               ((and (eq kind 'deletes-backward) (or inside at-end))
                (kill-region start end)
                (setq this-command 'ignore-event)))))))

(put 'self-insert-command 'action-type 'inserts)
(put 'yank 'action-type 'inserts)
(put 'kill-word 'action-type 'deletes-forward)
(put 'delete-char 'action-type 'deletes-forward)
(put 'kill-sexp 'action-type 'deletes-forward)
(put 'backward-kill-sexp 'action-type 'deletes-backward)
(put 'backward-delete-char 'action-type 'deletes-backward)
(put 'backward-kill-word 'action-type 'deletes-backward)
(put 'backward-delete-char-untabify 'action-type 'deletes-backward)
(put 'slime-repl-newline-and-indent 'action-type 'inserts)

On May 18, 2005, at 6:19 AM, Marco Baringer wrote:

> Antonio Menezes Leitao <aml at gia.ist.utl.pt> writes:
>
>> Hi,
>>
>> I made a quick hack that allows the Slime listener to use Lisp objects
>> that were returned from the Common Lisp environment.  We already can
>> do this using *, **, and *** variables but, to me, is not enough.  I
>> have an hard time remembering the number of stars that I should write
>> and, moreover, I prefer to 'point' to a value that is presented in the
>> listener and I use it in the construction of next expression, just
>> like in Symbolics Lisp machines.  For those who never saw the
>> Symbolics environment, let me give you a description of what I can do
>> with this patch to Slime:
>
> ok, i just commited this with the following changes:
>
> 1) we don't attempt to add a slime-repl-result-face property if
>    there's no result in slime-repl-insert-prompt.
>
> 2) renamed *current-id* to the (imho) more emacs-ish
>    slime-current-output-id and added a defvar so repl shortucts don't
>    break.
>
> 3) inserting a previous output now moves point past the inserted text
>    (previously the pint was being left in the middle of the text).
>
> 4) inserted output is still undeleteable :( i tried messing with the
>    intagible and modification-hooks properties but don't have enough
>    emacs-foo to figure this out.
>
> 5) attempting (via M-p or similar) to access an output which has been
>    cleared (via C-c C-t or similar) signals a error with a message
>    explaining what's happened.
>
> -- 
> -Marco
> Ring the bells that still can ring.
> Forget the perfect offering.
> There is a crack in everything.
> That's how the light gets in.
> 	-Leonard Cohen
>
> _______________________________________________
> slime-devel site list
> slime-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/slime-devel




More information about the slime-devel mailing list