unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* defface not defining a face?
@ 2014-03-09 18:08 lee
  2014-03-09 18:16 ` Juanma Barranquero
  0 siblings, 1 reply; 7+ messages in thread
From: lee @ 2014-03-09 18:08 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

what´s wrong with


[...]
(defgroup lsl-faces nil
  "Faces for lsl-mode."
  :group 'lsl-faces
  :group 'faces)


(defface lsl-global-variable
  '((((background dark)) (:background "pink" :foreground "black"))
    (t (:background "pink")))
  "Face to highlight global variables"
  :group 'lsl-faces)


(defun lsl-hi-lock-global-variable ()
  "add a hi-lock-mode pattern to highlight something that is a
global variable"
  (interactive)
  (lsl-hi-lock-add lsl-global-variable))
[...]


That gives me "reference to free variable `lsl-global-variable'" when
byte-compiling, and "lsl-hi-lock-global-variable: Symbol's value as
variable is void: lsl-global-variable" when calling
(lsl-hi-lock-global-variable).

Apparently the face is not defined.  How come?

See https://github.com/Ratany/lsl-repo/tree/master/emacs --- I´m trying
to add some face definitions.


-- 
Knowledge is volatile and fluid.  Software is power.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: defface not defining a face?
  2014-03-09 18:08 defface not defining a face? lee
@ 2014-03-09 18:16 ` Juanma Barranquero
  2014-03-09 18:21   ` Drew Adams
  2014-03-09 20:57   ` lee
  0 siblings, 2 replies; 7+ messages in thread
From: Juanma Barranquero @ 2014-03-09 18:16 UTC (permalink / raw)
  To: Emacs Help List

On Sun, Mar 9, 2014 at 7:08 PM, lee <lee@yun.yagibdah.de> wrote:

> (defface lsl-global-variable
>   '((((background dark)) (:background "pink" :foreground "black"))
>     (t (:background "pink")))
>   "Face to highlight global variables"
>   :group 'lsl-faces)

> Apparently the face is not defined.  How come?

Oh, yes, it is defined. Try (facep 'lsl-global-variable)

But a face is not a variable, so (boundp 'lsl-global-variable) is nil.

    J



^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: defface not defining a face?
  2014-03-09 18:16 ` Juanma Barranquero
@ 2014-03-09 18:21   ` Drew Adams
  2014-03-09 20:50     ` lee
  2014-03-09 20:57   ` lee
  1 sibling, 1 reply; 7+ messages in thread
From: Drew Adams @ 2014-03-09 18:21 UTC (permalink / raw)
  To: Juanma Barranquero, Emacs Help List

> > Apparently the face is not defined.  How come?
> 
> Oh, yes, it is defined. Try (facep 'lsl-global-variable)
> But a face is not a variable, so (boundp 'lsl-global-variable) is nil.

In addition, do not use the group you are defining as a parent group:

(defgroup lsl-faces nil
  "Faces for lsl-mode."
  :group 'lsl-faces ; <=========== REMOVE THIS
  :group 'faces)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: defface not defining a face?
  2014-03-09 18:21   ` Drew Adams
@ 2014-03-09 20:50     ` lee
  0 siblings, 0 replies; 7+ messages in thread
From: lee @ 2014-03-09 20:50 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams <drew.adams@oracle.com> writes:

>> > Apparently the face is not defined.  How come?
>> 
>> Oh, yes, it is defined. Try (facep 'lsl-global-variable)
>> But a face is not a variable, so (boundp 'lsl-global-variable) is nil.
>
> In addition, do not use the group you are defining as a parent group:
>
> (defgroup lsl-faces nil
>   "Faces for lsl-mode."
>   :group 'lsl-faces ; <=========== REMOVE THIS
>   :group 'faces)

Thank you, I didn´t notice ...  It seems I´ll have to look into setting
up a group for the mode, since there are more things that can be
customized ...


-- 
Knowledge is volatile and fluid.  Software is power.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: defface not defining a face?
  2014-03-09 18:16 ` Juanma Barranquero
  2014-03-09 18:21   ` Drew Adams
@ 2014-03-09 20:57   ` lee
  2014-03-09 21:40     ` Michael Heerdegen
  2014-03-12 16:45     ` Jambunathan K
  1 sibling, 2 replies; 7+ messages in thread
From: lee @ 2014-03-09 20:57 UTC (permalink / raw)
  To: help-gnu-emacs

Juanma Barranquero <lekktu@gmail.com> writes:

> On Sun, Mar 9, 2014 at 7:08 PM, lee <lee@yun.yagibdah.de> wrote:
>
>> (defface lsl-global-variable
>>   '((((background dark)) (:background "pink" :foreground "black"))
>>     (t (:background "pink")))
>>   "Face to highlight global variables"
>>   :group 'lsl-faces)
>
>> Apparently the face is not defined.  How come?
>
> Oh, yes, it is defined. Try (facep 'lsl-global-variable)
>
> But a face is not a variable, so (boundp 'lsl-global-variable) is nil.

So I would need to define a variable like it is done in font-lock.el?
Because those work --- and font-lock.el says I shouldn´t define a
variable for it ...  But using 'lsl-global-variable instead of
lsl-global-variable works fine :)


-- 
Knowledge is volatile and fluid.  Software is power.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: defface not defining a face?
  2014-03-09 20:57   ` lee
@ 2014-03-09 21:40     ` Michael Heerdegen
  2014-03-12 16:45     ` Jambunathan K
  1 sibling, 0 replies; 7+ messages in thread
From: Michael Heerdegen @ 2014-03-09 21:40 UTC (permalink / raw)
  To: help-gnu-emacs

lee <lee@yun.yagibdah.de> writes:

> So I would need to define a variable like it is done in font-lock.el?
> Because those work --- and font-lock.el says I shouldn´t define a
> variable for it ...  But using 'lsl-global-variable instead of
> lsl-global-variable works fine :)

No, that's perfectly fine.  The error was just the missing quote - which
caused Emacs to interpret and evaluate it as a variable (which it isn't,
the symbol isn't bound to a value, it's just the name of a face).

Michael.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: defface not defining a face?
  2014-03-09 20:57   ` lee
  2014-03-09 21:40     ` Michael Heerdegen
@ 2014-03-12 16:45     ` Jambunathan K
  1 sibling, 0 replies; 7+ messages in thread
From: Jambunathan K @ 2014-03-12 16:45 UTC (permalink / raw)
  To: help-gnu-emacs


This one is right from my .emacs.  The default values of highlight faces
is not to my taste.  I have some 8-9 faces which are defined like this.

(defface highlight-1
  '((((min-colors 88) (background dark))
     (:background "yellow1" :foreground "black"))
    (((background dark)) (:background "yellow" :foreground "black"))
    (((min-colors 88)) (:background "yellow1"))
    (t (:background "yellow")))
  "Default face for hi-lock mode."
  :group 'highlight-faces)

(defface highlight-2
  '((((background dark)) (:background "pink" :foreground "black"))
    (t (:background "pink")))
  "Face for hi-lock mode."
  :group 'highlight-faces)

(defface highlight-3
  '((((min-colors 88) (background dark))
     (:background "green1" :foreground "black"))
    (((background dark)) (:background "green" :foreground "black"))
    (((min-colors 88)) (:background "green1"))
    (t (:background "green")))
  "Face for hi-lock mode."
  :group 'highlight-faces)

(defvar hi-lock-face-regexp "\\`highlight-.*")

(setq hi-lock-face-defaults
      ((lambda (regexp)
	 "List of faces that match REGEXP."
	 (delq nil
	       (mapcar (lambda (f)
			 (let ((s (symbol-name f)))
			   (when (string-match regexp s) s)))
		       (reverse (face-list)))))
       hi-lock-face-regexp))



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-03-12 16:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-09 18:08 defface not defining a face? lee
2014-03-09 18:16 ` Juanma Barranquero
2014-03-09 18:21   ` Drew Adams
2014-03-09 20:50     ` lee
2014-03-09 20:57   ` lee
2014-03-09 21:40     ` Michael Heerdegen
2014-03-12 16:45     ` Jambunathan K

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).