Lisp HUG Maillist Archive

Editor point in deleted text?

In an editor command, if the text surrounding a point is deleted, the point is deleted. Can I tell that's happened? Can I make a new point where the text was deleted?

Here's the context:

(defcommand "Indent Defun" (p)
     "Moves to the beginning of the current defun and indents it"
     "Indents current defun"
  (declare (ignore p))
  (let ((point (current-point)))
    (with-point ((old-point point :after-insert))
      (beginning-of-defun-command)
      (indent-form-command)
      (move-point point old-point))))

This lets me put point anywhere in a defun and indent it. Unfortunately, if old-point was in a stretch of space that got deleted by indent-form-command, I get an error. How can I avoid that and return point to its original location?

BTW, my previous version of this command stopped working in LW 6 because (indent-form-command 1) now indents the previous form instead of the form following point. I removed the argument and it works properly. Is that a bug?

 - Stoney

-- 
Stonewall Ballard 
stoney@sb.org           http://stoney.sb.org/


Updated at: 2020-12-10 08:40 UTC