Fixed the bug of not indenting well in narrowed region (Issue 46).

This commit is contained in:
Zhang Chiyuan 2008-12-12 05:19:03 +00:00
parent 709463d19e
commit 1c0d664d65

View File

@ -782,19 +782,21 @@ will be deleted before inserting template."
,key ,key
,snippet))) ,snippet)))
;; Step 13: Do necessary indenting ;; Step 13: remove the trigger key
(save-excursion
(let ((ovst (overlay-start (yas/snippet-overlay snippet))))
(when ovst
(goto-char ovst)
(while (re-search-forward "$>" nil t)
(replace-match "")
(indent-according-to-mode)))))
;; Step 14: remove the trigger key
(widen) (widen)
(delete-char length) (delete-char length)
;; Step 14: Do necessary indenting
(save-excursion
(let ((ovst (overlay-start (yas/snippet-overlay snippet)))
(oven (copy-marker
(1+ (overlay-end (yas/snippet-overlay snippet))))))
(when (and ovst oven)
(goto-char ovst)
(while (re-search-forward "$>" oven t)
(replace-match "")
(indent-according-to-mode)))))
;; Step 15: Restore undo information, and also save it for future use. ;; Step 15: Restore undo information, and also save it for future use.
(setf (yas/snippet-saved-buffer-undo-list snippet) original-undo-list) (setf (yas/snippet-saved-buffer-undo-list snippet) original-undo-list)
(setq buffer-undo-list original-undo-list) (setq buffer-undo-list original-undo-list)