bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#43242: [PATCH] Fix CSS completion bug


From: Philip K.
Subject: bug#43242: [PATCH] Fix CSS completion bug
Date: Mon, 07 Sep 2020 00:15:06 +0200

Lars Ingebrigtsen <larsi@gnus.org> writes:

> "Philip K." <philipk@posteo.net> writes:
>
>> Oh, I wasn't familiar with that convention. I always save the match data
>> to avoid bugs bugs down the line. If it's wished for, I can resubmit the
>> patch without the save-match-data.
>
> Yes, please.

See below.

I also took the liberty to restructure the code a bit, hopefully
making it easier to read. Hope that's OK.

-- 
        Philip K.

>From 87244a9bfb9a285cf7df547465014527b2260027 Mon Sep 17 00:00:00 2001
From: Philip K <philipk@posteo.net>
Date: Sun, 6 Sep 2020 14:42:03 +0200
Subject: [PATCH] Allow CSS completion with multiple rules on one line

* css-mode.el (css--complete-property-value): Check for semi-colon
  when completing property values
---
 lisp/textmodes/css-mode.el | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index cc5879880c..9cddc17eaa 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -1356,21 +1356,17 @@ css--property-values
 
 (defun css--complete-property-value ()
   "Complete property value at point."
-  (let ((property
-         (save-excursion
-           (re-search-backward ":[^/]" (line-beginning-position) t)
-           (when (eq (char-after) ?:)
-             (let ((property-end (point)))
-               (skip-chars-backward "-[:alnum:]")
-               (let ((prop (buffer-substring (point) property-end)))
-                 (car (member prop css-property-ids))))))))
+  (let ((property (and (looking-back "\\([[:alnum:]-]+\\):[^/][^;]*"
+                                     (line-beginning-position) t)
+                       (member (match-string-no-properties 1)
+                               css-property-ids))))
     (when property
       (let ((end (point)))
         (save-excursion
           (skip-chars-backward "[:graph:]")
           (list (point) end
                 (append '("inherit" "initial" "unset")
-                        (css--property-values property))))))))
+                        (css--property-values (car property)))))))))
 
 (defvar css--html-tags (mapcar #'car html-tag-alist)
   "List of HTML tags.
-- 
2.26.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]