diff options
author | smihica <smihica@gmail.com> | 2013-08-16 15:16:45 +0900 |
---|---|---|
committer | smihica <smihica@gmail.com> | 2013-08-16 15:16:45 +0900 |
commit | 032950b54561c2d82ea35adb0b91bd029843bc55 (patch) | |
tree | 8f978e37f7585b3c3e839b57c5925d88e38eb242 | |
parent | a172db1fb8c63de5ae85ce48253baf69dca4b008 (diff) | |
download | emmet-mode-032950b54561c2d82ea35adb0b91bd029843bc55.tar.lz emmet-mode-032950b54561c2d82ea35adb0b91bd029843bc55.tar.xz emmet-mode-032950b54561c2d82ea35adb0b91bd029843bc55.zip |
Added settings that the cursor to be positioned between first empty quotes. issue #9.
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | emmet-mode.el | 20 | ||||
-rw-r--r-- | src/mode-def.el | 20 |
3 files changed, 45 insertions, 5 deletions
@@ -34,12 +34,20 @@ to auto-load on your sgml modes: And you can set default indent depth of HTML abbreviation. - (add-hook 'emmet-mode-hook (lambda () (setq emmet-indentation 2))) ;indent 2 spaces. + (add-hook 'emmet-mode-hook (lambda () (setq emmet-indentation 2))) ;; indent 2 spaces. Good to go: place point in a emmet snippet and press C-j to expand it (or alternatively, alias your preferred keystroke to M-x emmet-expand-line) and you'll transform your snippet into the appropriate tag structure. +If you want the cursor to be positioned between first empty quotes after expanding. + + (setq emmet-move-cursor-between-quotes t) ;; default nil + +If you don't want to move cursor after expanding itself. + + (setq emmet-move-cursor-after-expanding nil) ;; default t + ## HTML abbreviations #### Basic tags diff --git a/emmet-mode.el b/emmet-mode.el index fd9c6fa..673343e 100644 --- a/emmet-mode.el +++ b/emmet-mode.el @@ -3481,7 +3481,7 @@ See also `emmet-expand-line'." (when markup (delete-region (line-beginning-position) (overlay-end ovli)) (emmet-insert-and-flash markup) - (when (= (elt markup 0) ?<) + (when (and emmet-move-cursor-after-expanding (= (elt markup 0) ?<)) (let ((p (point))) (goto-char (+ (- p (length markup)) @@ -3497,7 +3497,11 @@ See also `emmet-expand-line'." (setq c (elt str i)) (case c (?\" (if (not (= last-c ?\\)) - (setq instring (not instring)))) + (progn (setq instring (not instring)) + (when (and emmet-move-cursor-between-quotes + (not instring) + (= last-c ?\")) + (return i))))) (?> (if (not instring) (if intag (if (= last-c ?/) (return (1+ i)) @@ -3538,6 +3542,18 @@ expansion after insertion." :type '(number :tag "Seconds") :group 'emmet) +(defcustom emmet-move-cursor-after-expanding t + "If non-nil the the cursor position is +moved to before the first closing tag when the exp was expanded." + :type 'boolean + :group 'emmet) + +(defcustom emmet-move-cursor-between-quotes nil + "If emmet-move-cursor-after-expands is non-nil and this is non-nil then +cursor position will be moved to after the first quote." + :type 'boolean + :group 'emmet) + (defun emmet-insert-and-flash (markup) (emmet-remove-flash-ovl (current-buffer)) (let ((here (point))) diff --git a/src/mode-def.el b/src/mode-def.el index 24ea9ff..35a820e 100644 --- a/src/mode-def.el +++ b/src/mode-def.el @@ -171,7 +171,7 @@ See also `emmet-expand-line'." (when markup (delete-region (line-beginning-position) (overlay-end ovli)) (emmet-insert-and-flash markup) - (when (= (elt markup 0) ?<) + (when (and emmet-move-cursor-after-expanding (= (elt markup 0) ?<)) (let ((p (point))) (goto-char (+ (- p (length markup)) @@ -187,7 +187,11 @@ See also `emmet-expand-line'." (setq c (elt str i)) (case c (?\" (if (not (= last-c ?\\)) - (setq instring (not instring)))) + (progn (setq instring (not instring)) + (when (and emmet-move-cursor-between-quotes + (not instring) + (= last-c ?\")) + (return i))))) (?> (if (not instring) (if intag (if (= last-c ?/) (return (1+ i)) @@ -228,6 +232,18 @@ expansion after insertion." :type '(number :tag "Seconds") :group 'emmet) +(defcustom emmet-move-cursor-after-expanding t + "If non-nil the the cursor position is +moved to before the first closing tag when the exp was expanded." + :type 'boolean + :group 'emmet) + +(defcustom emmet-move-cursor-between-quotes nil + "If emmet-move-cursor-after-expands is non-nil and this is non-nil then +cursor position will be moved to after the first quote." + :type 'boolean + :group 'emmet) + (defun emmet-insert-and-flash (markup) (emmet-remove-flash-ovl (current-buffer)) (let ((here (point))) |