* added `yas/also-auto-indent-first-line' defcustom

* added `yas/minor-mode-menu' defvar to prevent possible backtrace
   (reported by Christoph Conrad)
This commit is contained in:
capitaomorte 2009-07-26 15:27:26 +00:00
parent 3b6e9dda59
commit 1aadcfae8a

View File

@ -151,6 +151,13 @@ applies)."
(const :tag "Auto" auto)) (const :tag "Auto" auto))
:group 'yasnippet) :group 'yasnippet)
(defcustom yas/also-auto-indent-first-line nil
"Non-nil means also auto indent first line according to mode.
Naturally this is only valid when `yas/indent-line' is `auto'"
:type 'boolean
:group 'yasnippet)
(defcustom yas/snippet-revival t (defcustom yas/snippet-revival t
"Non-nil means re-activate snippet fields after undo/redo." "Non-nil means re-activate snippet fields after undo/redo."
:type 'boolean :type 'boolean
@ -437,6 +444,9 @@ Here's an example:
(defvar yas/minor-mode-map (make-sparse-keymap) (defvar yas/minor-mode-map (make-sparse-keymap)
"The keymap used when function `yas/minor-mode' is active.") "The keymap used when function `yas/minor-mode' is active.")
(defvar yas/minor-mode-menu (make-sparse-keymap)
"Holds the YASnippet menu. For use with `easy-menu-define'.")
(defun yas/init-keymap-and-menu () (defun yas/init-keymap-and-menu ()
(easy-menu-define yas/minor-mode-menu (easy-menu-define yas/minor-mode-menu
yas/minor-mode-map yas/minor-mode-map
@ -2287,6 +2297,7 @@ Meant to be called in a narrowed buffer, does various passes"
(insert indent)))) (insert indent))))
((eq yas/indent-line 'auto) ((eq yas/indent-line 'auto)
(let ((end (set-marker (make-marker) (point-max))) (let ((end (set-marker (make-marker) (point-max)))
(indent-first-line-p yas/also-auto-indent-first-line)
(snippet-markers (yas/collect-snippet-markers snippet))) (snippet-markers (yas/collect-snippet-markers snippet)))
(save-restriction (save-restriction
(widen) (widen)
@ -2303,7 +2314,11 @@ Meant to be called in a narrowed buffer, does various passes"
;; This would also happen if we had used overlays with ;; This would also happen if we had used overlays with
;; the `front-advance' property set to nil. ;; the `front-advance' property set to nil.
;; ;;
(while (and (zerop (forward-line 1)) (while (and (zerop (if indent-first-line-p
(prog1
(forward-line 0)
(setq indent-first-line-p nil))
(forward-line 1)))
(not (eobp)) (not (eobp))
(<= (point) end)) (<= (point) end))
(goto-char (yas/real-line-beginning)) (goto-char (yas/real-line-beginning))