From 9fcd958c43e6d4498763eec9502b0a0710d0a0e4 Mon Sep 17 00:00:00 2001 From: Dave Mayo Date: Sun, 24 Aug 2014 16:52:53 -0400 Subject: Fixes #40 --- src/mode-def.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mode-def.el b/src/mode-def.el index 3094498..8b60374 100644 --- a/src/mode-def.el +++ b/src/mode-def.el @@ -22,7 +22,8 @@ (last-gt (point))) (while char (cond ((member char '(?\} ?\] ?\))) - (backward-sexp) (setq char (char-before))) + (with-syntax-table (standard-syntax-table) + (backward-sexp) (setq char (char-before)))) ((eq char ?\>) (setq last-gt (point)) (backward-char) (setq char (char-before))) ((eq char ?\<) -- cgit v1.2.3 From b07898b62050eb08141c00fd1e8975f5ada0a197 Mon Sep 17 00:00:00 2001 From: flyingleafe Date: Sat, 23 Aug 2014 01:20:57 +0600 Subject: Fixed cursor positioning in css snippets --- src/mode-def.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mode-def.el b/src/mode-def.el index 8b60374..f2f8b2c 100644 --- a/src/mode-def.el +++ b/src/mode-def.el @@ -95,11 +95,14 @@ For more information see `emmet-mode'." (delete-region (second expr) (third expr)) (emmet-insert-and-flash markup) (let ((output-markup (buffer-substring-no-properties (second expr) (point)))) - (when (and emmet-move-cursor-after-expanding (emmet-html-text-p markup)) - (let ((p (point))) + (when emmet-move-cursor-after-expanding + (let ((p (point)) + (new-pos (if (emmet-html-text-p output-markup) + (emmet-html-next-insert-point output-markup) + (emmet-css-next-insert-point output-markup)))) (goto-char (+ (- p (length output-markup)) - (emmet-html-next-insert-point output-markup))))))))))))) + new-pos)))))))))))) (defvar emmet-mode-keymap (let @@ -229,6 +232,10 @@ See also `emmet-expand-line'." (emmet-aif (re-search-forward ".+ Date: Sat, 23 Aug 2014 01:34:30 +0600 Subject: Moved cursor repositioning logic in separate function --- src/mode-def.el | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/mode-def.el b/src/mode-def.el index f2f8b2c..31f9d23 100644 --- a/src/mode-def.el +++ b/src/mode-def.el @@ -66,6 +66,17 @@ e. g. without semicolons") (emmet-css-transform input) (emmet-html-transform input))) +(defun emmet-reposition-cursor (expr) + (let ((output-markup (buffer-substring-no-properties (second expr) (point)))) + (when emmet-move-cursor-after-expanding + (let ((p (point)) + (new-pos (if (emmet-html-text-p output-markup) + (emmet-html-next-insert-point output-markup) + (emmet-css-next-insert-point output-markup)))) + (goto-char + (+ (- p (length output-markup)) + new-pos)))))) + ;;;###autoload (defun emmet-expand-line (arg) "Replace the current line's emmet expression with the corresponding expansion. @@ -94,15 +105,7 @@ For more information see `emmet-mode'." (when markup (delete-region (second expr) (third expr)) (emmet-insert-and-flash markup) - (let ((output-markup (buffer-substring-no-properties (second expr) (point)))) - (when emmet-move-cursor-after-expanding - (let ((p (point)) - (new-pos (if (emmet-html-text-p output-markup) - (emmet-html-next-insert-point output-markup) - (emmet-css-next-insert-point output-markup)))) - (goto-char - (+ (- p (length output-markup)) - new-pos)))))))))))) + (emmet-reposition-cursor expr)))))))) (defvar emmet-mode-keymap (let @@ -215,12 +218,7 @@ See also `emmet-expand-line'." (when markup (delete-region (overlay-start ovli) (overlay-end ovli)) (emmet-insert-and-flash markup) - (let ((output-markup (buffer-substring-no-properties (line-beginning-position) (point)))) - (when (and emmet-move-cursor-after-expanding (emmet-html-text-p markup)) - (let ((p (point))) - (goto-char - (+ (- p (length output-markup)) - (emmet-html-next-insert-point output-markup)))))))))) + (emmet-reposition-cursor expr))))) (emmet-preview-abort)) (defun emmet-html-next-insert-point (str) -- cgit v1.2.3 From efa7783b16fc91737dd74863d3d91c15cb54510b Mon Sep 17 00:00:00 2001 From: flyingleafe Date: Sat, 23 Aug 2014 01:56:00 +0600 Subject: Added Sass abbrs proper cursor positioning --- src/mode-def.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mode-def.el b/src/mode-def.el index 31f9d23..3395909 100644 --- a/src/mode-def.el +++ b/src/mode-def.el @@ -231,8 +231,9 @@ See also `emmet-expand-line'." (length str)))) ; ok, just go to the end (defun emmet-css-next-insert-point (str) - (string-match ": *\\(;\\)$" str) - (or (match-beginning 1) (length str))) + (let ((regexp (if emmet-use-sass-syntax ": *\\($\\)" ": *\\(;\\)$"))) + (string-match regexp str) + (or (match-beginning 1) (length str)))) (defvar emmet-flash-ovl nil) (make-variable-buffer-local 'emmet-flash-ovl) -- cgit v1.2.3 From bedede7cd27015ad9bd19892bc49b3b9232c896f Mon Sep 17 00:00:00 2001 From: flyingleafe Date: Sun, 24 Aug 2014 16:07:41 +0600 Subject: Fixed very strange behavior in some cases --- src/mode-def.el | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mode-def.el b/src/mode-def.el index 3395909..be615db 100644 --- a/src/mode-def.el +++ b/src/mode-def.el @@ -232,6 +232,7 @@ See also `emmet-expand-line'." (defun emmet-css-next-insert-point (str) (let ((regexp (if emmet-use-sass-syntax ": *\\($\\)" ": *\\(;\\)$"))) + (set-match-data nil t) (string-match regexp str) (or (match-beginning 1) (length str)))) -- cgit v1.2.3 From ec4d63f31c41941af3e85f9493ebc5cfed8be90e Mon Sep 17 00:00:00 2001 From: Dave Mayo Date: Sun, 24 Aug 2014 17:12:24 -0400 Subject: Refs #38, Close #39. Save match data around css cursor positioning. --- src/mode-def.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mode-def.el b/src/mode-def.el index be615db..6a7f5aa 100644 --- a/src/mode-def.el +++ b/src/mode-def.el @@ -232,9 +232,10 @@ See also `emmet-expand-line'." (defun emmet-css-next-insert-point (str) (let ((regexp (if emmet-use-sass-syntax ": *\\($\\)" ": *\\(;\\)$"))) - (set-match-data nil t) - (string-match regexp str) - (or (match-beginning 1) (length str)))) + (save-match-data + (set-match-data nil t) + (string-match regexp str) + (or (match-beginning 1) (length str))))) (defvar emmet-flash-ovl nil) (make-variable-buffer-local 'emmet-flash-ovl) -- cgit v1.2.3