mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
* replaced <tab> by TAB and fixed a small bug in $> indendation
This commit is contained in:
parent
a1a4bfc773
commit
63378d00b2
70
yasnippet.el
70
yasnippet.el
@ -93,7 +93,7 @@ representation using `read-kbd-macro'. "
|
|||||||
:type 'string
|
:type 'string
|
||||||
:group 'yasnippet)
|
:group 'yasnippet)
|
||||||
|
|
||||||
(defcustom yas/next-field-key "<tab>"
|
(defcustom yas/next-field-key "TAB"
|
||||||
"The key to navigate to next field when a snippet is active.
|
"The key to navigate to next field when a snippet is active.
|
||||||
|
|
||||||
Value is a string that is converted to the internal Emacs key
|
Value is a string that is converted to the internal Emacs key
|
||||||
@ -1705,39 +1705,41 @@ Meant to be called in a narrowed buffer, does various passes"
|
|||||||
(yas/indent snippet)))
|
(yas/indent snippet)))
|
||||||
|
|
||||||
(defun yas/indent (snippet)
|
(defun yas/indent (snippet)
|
||||||
;;; XXX: fixed indentation not working
|
;;; XXX: fixed indentation not working
|
||||||
(cond ((eq yas/indent-line 'fixed)
|
(save-excursion
|
||||||
(let ((fill-prefix (make-string yas/start-column ? )))
|
(cond ((eq yas/indent-line 'fixed)
|
||||||
(indent-region (point-min) (point-max))))
|
(let ((fill-prefix (make-string yas/start-column ? )))
|
||||||
((eq yas/indent-line 'auto)
|
(indent-region (point-min) (point-max))))
|
||||||
(let ((begin (point-min))
|
((eq yas/indent-line 'auto)
|
||||||
(end (point-max)))
|
(let ((begin (point-min))
|
||||||
(save-restriction
|
(end (point-max)))
|
||||||
(widen)
|
(save-restriction
|
||||||
(indent-region (line-beginning-position) (point-max))
|
(widen)
|
||||||
(when (yas/snippet-exit snippet)
|
(indent-region (line-beginning-position) (point-max))
|
||||||
(goto-char (yas/snippet-exit snippet))
|
(when (yas/snippet-exit snippet)
|
||||||
(indent-according-to-mode)
|
(goto-char (yas/snippet-exit snippet))
|
||||||
;; XXX: Here is the indent problem:
|
(indent-according-to-mode)
|
||||||
;;
|
;; XXX: Here is the indent problem:
|
||||||
;; `indent-according-to-mode' uses whatever
|
;;
|
||||||
;; `indent-line-function' is available. Some
|
;; `indent-according-to-mode' uses whatever
|
||||||
;; implementations of these functions delete text
|
;; `indent-line-function' is available. Some
|
||||||
;; before they insert. If there happens to be a marker
|
;; implementations of these functions delete text
|
||||||
;; just after the text being deleted, the insertion
|
;; before they insert. If there happens to be a marker
|
||||||
;; actually happens after the marker, which misplaces
|
;; just after the text being deleted, the insertion
|
||||||
;; it.
|
;; actually happens after the marker, which misplaces
|
||||||
;;
|
;; it.
|
||||||
;; This would also happen if we had used overlays with
|
;;
|
||||||
;; the `front-advance' property set to nil.
|
;; This would also happen if we had used overlays with
|
||||||
;;
|
;; the `front-advance' property set to nil.
|
||||||
(set-marker (yas/snippet-exit snippet) (point))))))
|
;;
|
||||||
(t
|
(set-marker (yas/snippet-exit snippet) (point))))))
|
||||||
nil))
|
(t
|
||||||
(while (re-search-forward "$>" nil t)
|
nil)))
|
||||||
(delete-region (match-beginning 0) (match-end 0))
|
(save-excursion
|
||||||
(when (not (eq yas/indent-line 'auto))
|
(while (re-search-forward "$>" nil t)
|
||||||
(indent-according-to-mode))))
|
(delete-region (match-beginning 0) (match-end 0))
|
||||||
|
(when (not (eq yas/indent-line 'auto))
|
||||||
|
(indent-according-to-mode)))))
|
||||||
|
|
||||||
|
|
||||||
(defun yas/escape-string (escaped)
|
(defun yas/escape-string (escaped)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user