all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Philip K." <philipk@posteo.net>
To: 43242@debbugs.gnu.org
Subject: bug#43242: [PATCH] Fix CSS completion bug
Date: Sun, 06 Sep 2020 14:51:03 +0200	[thread overview]
Message-ID: <87mu239ih4.fsf@posteo.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 688 bytes --]


Hi,

I like to write CSS rules on one line, but Emacs completion-at-point
system always seems to fail if there is more than one rule per line. It
seems the reason was that css--complete-property-value as part of
css-completion-at-point falsely reported a match, because it ignored the
semi-colon. This means that in situations like these

            color: red; padd
                            ^
                        point here

the CAPF backend assumed a "color" value should be completed, even
though the user probably wants the "padd" string to be completed.

The patch below fixes this by making sure css--complete-property-value
doesn't ignore the semi-colon.

-- 
	Philip K.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-CSS-completion-with-multiple-rules-on-one-line.patch --]
[-- Type: text/x-patch, Size: 1439 bytes --]

From d452cd225845000f278e39c02796cf323f931925 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 | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index cc5879880c..d0882c68d0 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -1357,13 +1357,11 @@ 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))))))))
+         (save-match-data
+           (and (looking-back "\\([[:alnum:]-]+\\):[^/][^;]*"
+                              (line-beginning-position) t)
+                (car (member (match-string-no-properties 1)
+                             css-property-ids))))))
     (when property
       (let ((end (point)))
         (save-excursion
-- 
2.26.2


             reply	other threads:[~2020-09-06 12:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-06 12:51 Philip K. [this message]
2020-09-06 19:30 ` bug#43242: [PATCH] Fix CSS completion bug Lars Ingebrigtsen
2020-09-06 21:40   ` Philip K.
2020-09-06 21:46     ` Lars Ingebrigtsen
2020-09-06 21:55       ` Philip K.
2020-09-06 21:57         ` Lars Ingebrigtsen
2020-09-06 22:15           ` Philip K.
2020-09-06 22:17             ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mu239ih4.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=43242@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.