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

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

bug#10633: Please mark invalid "; !important;" in CSS


From: Lennart Borgman
Subject: bug#10633: Please mark invalid "; !important;" in CSS
Date: Sun, 29 Jan 2012 01:10:57 +0100

On Sun, Jan 29, 2012 at 00:52, Lennart Borgman
<lennart.borgman@gmail.com> wrote:
> On Sun, Jan 29, 2012 at 00:26, Lennart Borgman
> <lennart.borgman@gmail.com> wrote:
>> On Sun, Jan 29, 2012 at 00:18, Juanma Barranquero <lekktu@gmail.com> wrote:
>>> On Sat, Jan 28, 2012 at 23:01, Lennart Borgman
>>> <lennart.borgman@gmail.com> wrote:
>>>
>>>> One of my most common mistakes when editing CSS files is that I leave
>>>> a ";" before "!important", like this:
>>>>
>>>>   width: 500px; !important;
>>>>
>>>> This should have been
>>>>
>>>>   width: 500px !important;
>>>>
>>>> Could Emacs please help me with this?;-)
>>>
>>> Sure. Use hi-lock-mode, add a "; +!important" regexp as a file
>>> pattern, set the mode in the css-mode-hook, and for added simplicity
>>> do also
>>>
>>> (setq hi-lock-file-patterns-policy (lambda (patterns)
>>>                                            (if (eq major-mode 'css-mode)
>>>                                                t
>>>                                              (y-or-n-p "Add patterns
>>> from this buffer to hi-lock? "))))
>>>
>>> Look, ma, no hands.
>>
>> Thanks, it is a great tip until it is fixed!
>
> Though it was a bit unpractical. It would be easier to just add it to
> css-mode-hook and forget hi-lock-mode. Since isearch does it without
> hi-lock-mode that is doable. Anyone remember how to do it offhand? (Or
> do I have to search the isearch code... ?;-)

Here is a way to do it:

- In isearch-forward-regexp do M-s-h-r to hilight the pattern.
- Then use hi-lock-write-interactive-patterns to write it down in the
buffer for the moment (so you do not have to think about it...;-)
- Now to css-mode-hook add something like this (hi-lock-face-buffer ";
+!important;" 'hi-my-face)

In my .emacs I added:

(add-hook 'css-mode-hook 'my-hilock-css-important-errors)
(defun my-hilock-css-important-errors()
  (hi-lock-face-buffer "; +!important;" 'hi-my-magenta))





reply via email to

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