]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/textmodes/css-mode.el (css-completion-at-point): Auto-insert
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 28 Feb 2017 14:29:06 +0000 (09:29 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 28 Feb 2017 14:29:06 +0000 (09:29 -0500)
": ;" after completing a property.

lisp/textmodes/css-mode.el

index cd86db639ab62d077ee82a101112f1ad2e11b11f..7a9454f7f3ca100516263ea6ca6683ab2b69c973 100644 (file)
@@ -696,7 +696,8 @@ cannot be completed sensibly: `custom-ident',
        ;; Even though pseudo-elements should be prefixed by ::, a
        ;; single colon is accepted for backward compatibility.
        "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
-                                       css-pseudo-element-ids) t)
+                                       css-pseudo-element-ids)
+                               t)
        "\\|\\::" (regexp-opt css-pseudo-element-ids t) "\\)"
        "\\(?:([^)]+)\\)?"
        (if (not sassy)
@@ -965,10 +966,22 @@ pseudo-elements, pseudo-classes, at-rules, and bang-rules."
       (seq-let (prop-beg prop-end prop-table) (css--complete-property)
         (seq-let (sel-beg sel-end sel-table) (css--complete-selector)
           (when (or prop-table sel-table)
+            ;; FIXME: If both prop-table and sel-table are set but
+            ;; prop-beg/prop-end is different from sel-beg/sel-end
+            ;; we have a problem!
             `(,@(if prop-table
                     (list prop-beg prop-end)
                   (list sel-beg sel-end))
-              ,(completion-table-merge prop-table sel-table)))))))
+              ,(completion-table-merge prop-table sel-table)
+              :exit-function
+              ,(lambda (string status)
+                 (and (eq status 'finished)
+                      prop-table
+                      (test-completion string prop-table)
+                      (not (and sel-table
+                                (test-completion string sel-table)))
+                      (progn (insert ": ;")
+                             (forward-char -1))))))))))
 
 ;;;###autoload
 (define-derived-mode css-mode prog-mode "CSS"