Changeset 6664


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

Try to use the right flavor of CURRENT-POINT.

File:
1 edited

Legend:

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

    r2094 r6664  
    123123  With prefix argument, do it that many times."
    124124  "Delete the P previous characters, expanding tabs into spaces."
    125   (let ((point (current-point))
    126         (n (or p 1)))
    127     (when (minusp n)
    128       (editor-error "Delete Previous Character Expanding Tabs only accepts ~
     125  (let* ((buffer (current-buffer))
     126         (region (hi::%buffer-current-region buffer)))
     127    (if region
     128      (delete-region region)
     129      (let ((point (current-point))
     130            (n (or p 1)))
     131        (when (minusp n)
     132          (editor-error "Delete Previous Character Expanding Tabs only accepts ~
    129133                     positive arguments."))
    130     ;; Pre-calculate the number of characters that need to be deleted
    131     ;; and any remaining white space filling, allowing modification to
    132     ;; be avoided if there are not enough characters to delete.
    133     (let ((errorp nil)
    134           (del 0)
    135           (fill 0))
    136       (with-mark ((mark point))
    137         (dotimes (i n)
    138           (if (> fill 0)
    139               (decf fill)
    140               (let ((prev (previous-character mark)))
    141                 (cond ((and prev (char= prev #\tab))
    142                        (let ((pos (mark-column mark)))
    143                         (mark-before mark)
    144                         (incf fill (- pos (mark-column mark) 1)))
    145                        (incf del))
    146                       ((mark-before mark)
    147                        (incf del))
    148                       (t
    149                        (setq errorp t)
    150                        (return)))))))
    151       (cond ((and (not errorp) (kill-characters point (- del)))
    152              (with-mark ((mark point :left-inserting))
    153                (dotimes (i fill)
    154                 (insert-character mark #\space))))
    155             (t
    156              (editor-error "There were not ~D characters before point." n))))))
     134        ;; Pre-calculate the number of characters that need to be deleted
     135        ;; and any remaining white space filling, allowing modification to
     136        ;; be avoided if there are not enough characters to delete.
     137        (let ((errorp nil)
     138              (del 0)
     139              (fill 0))
     140          (with-mark ((mark point))
     141            (dotimes (i n)
     142              (if (> fill 0)
     143                (decf fill)
     144                (let ((prev (previous-character mark)))
     145                  (cond ((and prev (char= prev #\tab))
     146                         (let ((pos (mark-column mark)))
     147                          (mark-before mark)
     148                          (incf fill (- pos (mark-column mark) 1)))
     149                         (incf del))
     150                        ((mark-before mark)
     151                         (incf del))
     152                        (t
     153                         (setq errorp t)
     154                         (return)))))))
     155          (cond ((and (not errorp) (kill-characters point (- del)))
     156                 (with-mark ((mark point :left-inserting))
     157                   (dotimes (i fill)
     158                    (insert-character mark #\space))))
     159                (t
     160                 (editor-error "There were not ~D characters before point." n))))))))
    157161
    158162
Note: See TracChangeset for help on using the changeset viewer.