all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* change faces interactively
@ 2012-01-20  7:41 ishi soichi
  2012-01-20 15:30 ` Drew Adams
  0 siblings, 1 reply; 7+ messages in thread
From: ishi soichi @ 2012-01-20  7:41 UTC (permalink / raw)
  To: help-gnu-emacs

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

I'm trying to develop an interactive function that changes faces.

For example, one way to change the face is


(define-generic-mode my-mode
  nil nil
  '(("think?\\w*\\|thought" . 'org-warning))  ;;changes face of "think",
"thinks", and "thought"
  nil nil)

But this changes the face according to the mode, not the interactive
command input.

Is there anyway to develop an interactive function like that ?

(defun change-face-to-one ()
  (interactive)
  ...
    )

Thanks in advance.

soichi

[-- Attachment #2: Type: text/html, Size: 822 bytes --]

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

* RE: change faces interactively
  2012-01-20  7:41 change faces interactively ishi soichi
@ 2012-01-20 15:30 ` Drew Adams
  2012-01-21  1:20   ` ishi soichi
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2012-01-20 15:30 UTC (permalink / raw)
  To: 'ishi soichi', help-gnu-emacs

> I'm trying to develop an interactive function that changes faces. 
> For example, one way to change the face is
>
> ;;changes face of "think", "thinks", and "thought"
> (define-generic-mode my-mode
>   nil nil
>   '(("think?\\w*\\|thought" . 'org-warning)) nil nil)
>
> But this changes the face according to the mode, not the
> interactive command input.
>
> Is there anyway to develop an interactive function like that ?
> (defun change-face-to-one () (interactive) ...)

Not quite sure what you're asking.  Do you just want to modify a set of faces FS
so they look the same as some given face G?

If so, you can define a command that reads the names of the faces to modify (FS)
and the face to copy (G), and then, in the body of the function, call
`copy-face' to modify each of the former (each F in FS).





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

* Re: change faces interactively
  2012-01-20 15:30 ` Drew Adams
@ 2012-01-21  1:20   ` ishi soichi
  2012-01-21  2:07     ` Drew Adams
  2012-01-23 18:05     ` Michael Heerdegen
  0 siblings, 2 replies; 7+ messages in thread
From: ishi soichi @ 2012-01-21  1:20 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs

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

Sorry for my poor explanation.
What I want is an interactive function that turns on/off face changes by
command.

Say, a buffer is in "my-mode".  The above (define-generic-mode ... ) will
AUTOMATICALLY apply the face definitions to all characters as soon as the
buffer is opened (assuming the mode definition recognizes its file
extension).
I would rather develop a function that applies the faces AT WILL even after
the buffer is opened IN THAT MODE.
For example, a buffer is in "my-mode" but none of the words in that buffer
is applied with any faces.
Now I will implement a function, (defun my-mode-face-1 ()
 (interactive)...), then a certain set of words in that buffer is
bold-faced.  After that, I will implement another function, (defun
my-mode-face-2 () (interactive) ...), then another set of the words in that
buffer is italic-faced. And so on...

If it does not make sense, please ask me again.  I appreciate it.

soichi


2012/1/21 Drew Adams <drew.adams@oracle.com>

> > I'm trying to develop an interactive function that changes faces.
> > For example, one way to change the face is
> >
> > ;;changes face of "think", "thinks", and "thought"
> > (define-generic-mode my-mode
> >   nil nil
> >   '(("think?\\w*\\|thought" . 'org-warning)) nil nil)
> >
> > But this changes the face according to the mode, not the
> > interactive command input.
> >
> > Is there anyway to develop an interactive function like that ?
> > (defun change-face-to-one () (interactive) ...)
>
> Not quite sure what you're asking.  Do you just want to modify a set of
> faces FS
> so they look the same as some given face G?
>
> If so, you can define a command that reads the names of the faces to
> modify (FS)
> and the face to copy (G), and then, in the body of the function, call
> `copy-face' to modify each of the former (each F in FS).
>
>
>

[-- Attachment #2: Type: text/html, Size: 2451 bytes --]

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

* RE: change faces interactively
  2012-01-21  1:20   ` ishi soichi
@ 2012-01-21  2:07     ` Drew Adams
  2012-01-23 10:51       ` Andreas Röhler
  2012-01-23 18:05     ` Michael Heerdegen
  1 sibling, 1 reply; 7+ messages in thread
From: Drew Adams @ 2012-01-21  2:07 UTC (permalink / raw)
  To: 'ishi soichi'; +Cc: help-gnu-emacs

> Sorry for my poor explanation. 
> What I want is an interactive function that turns on/off
> face changes by command.
> 
> Say, a buffer is in "my-mode".  The above
> (define-generic-mode ... ) will AUTOMATICALLY apply the face
> definitions to all characters as soon as the buffer is
> opened (assuming the mode definition recognizes its file extension).
> I would rather develop a function that applies the faces 
> AT WILL even after the buffer is opened IN THAT MODE.  
> For example, a buffer is in "my-mode" but none of the words
> in that buffer is applied with any faces.
> Now I will implement a function, (defun my-mode-face-1 ()  
> (interactive)...), then a certain set of words in that
> buffer is bold-faced.  After that, I will implement another
> function, (defun my-mode-face-2 () (interactive) ...), then
> another set of the words in that buffer is italic-faced. And so on...
> 
> If it does not make sense, please ask me again.  I appreciate it.

Sorry, I don't have much time right now - perhaps someone else can help.

If you just want to highlight stuff then perhaps have a look here:
http://www.emacswiki.org/emacs/FaceMenuPlus
http://www.emacswiki.org/emacs/HighlightLibrary




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

* Re: change faces interactively
  2012-01-21  2:07     ` Drew Adams
@ 2012-01-23 10:51       ` Andreas Röhler
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2012-01-23 10:51 UTC (permalink / raw)
  To: help-gnu-emacs

Am 21.01.2012 03:07, schrieb Drew Adams:
>> Sorry for my poor explanation.
>> What I want is an interactive function that turns on/off
>> face changes by command.
>>
>> Say, a buffer is in "my-mode".  The above
>> (define-generic-mode ... ) will AUTOMATICALLY apply the face
>> definitions to all characters as soon as the buffer is
>> opened (assuming the mode definition recognizes its file extension).
>> I would rather develop a function that applies the faces
>> AT WILL even after the buffer is opened IN THAT MODE.
>> For example, a buffer is in "my-mode" but none of the words
>> in that buffer is applied with any faces.
>> Now I will implement a function, (defun my-mode-face-1 ()
>> (interactive)...), then a certain set of words in that
>> buffer is bold-faced.  After that, I will implement another
>> function, (defun my-mode-face-2 () (interactive) ...), then
>> another set of the words in that buffer is italic-faced. And so on...
>>
>> If it does not make sense, please ask me again.  I appreciate it.
>
> Sorry, I don't have much time right now - perhaps someone else can help.
>
> If you just want to highlight stuff then perhaps have a look here:
> http://www.emacswiki.org/emacs/FaceMenuPlus
> http://www.emacswiki.org/emacs/HighlightLibrary
>
>
>


here an example from python-mode.el which sets a `py-number-face' 
depending from a `boolean py-use-number-face-p'

(when py-use-number-face-p
   (add-to-list 'python-font-lock-keywords 
'("\\([0-9]+\\([eE][+-]?[0-9]*\\)?\\|0[xX][0-9a-fA-F]+\\)" 1 
py-number-face)))

You can put such into a command, calling font-lock-fontify-buffer afterwards

HTH,


Andreas

--
http://launchpad.net/python-mode
http://launchpad.net/s-x-emacs-werkstatt/






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

* Re: change faces interactively
  2012-01-21  1:20   ` ishi soichi
  2012-01-21  2:07     ` Drew Adams
@ 2012-01-23 18:05     ` Michael Heerdegen
  2012-01-25  6:44       ` ishi soichi
  1 sibling, 1 reply; 7+ messages in thread
From: Michael Heerdegen @ 2012-01-23 18:05 UTC (permalink / raw)
  To: ishi soichi; +Cc: help-gnu-emacs

Hello,

if you want a low-level solution, you can use `highlight-regexp' from
"hi-lock.el", which is part of vanilla Emacs.

If you want the highlighting to be performed automatically when you
visit the file, you can use `eval' in the file local variable
declarations.  Simple example (just create a file with this content to
try):

--8<---------------cut here---------------start------------->8---
I use Emacs, because Emacs is really cool!

Local Variables:
eval: (highlight-regexp "Emacs" "bold")
End:
--8<---------------cut here---------------end--------------->8---

There are different solutions, depending on what you want to do
specifically.  If you want syntactical highlighting, it's better to use
font-lock, like in the example from Andreas.


Regards,

Michael.



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

* Re: change faces interactively
  2012-01-23 18:05     ` Michael Heerdegen
@ 2012-01-25  6:44       ` ishi soichi
  0 siblings, 0 replies; 7+ messages in thread
From: ishi soichi @ 2012-01-25  6:44 UTC (permalink / raw)
  To: help-gnu-emacs, michael_heerdegen

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

Thanks for the info!
It will help.

soichi

2012/1/24 Michael Heerdegen <michael_heerdegen@web.de>

> Hello,
>
> if you want a low-level solution, you can use `highlight-regexp' from
> "hi-lock.el", which is part of vanilla Emacs.
>
> If you want the highlighting to be performed automatically when you
> visit the file, you can use `eval' in the file local variable
> declarations.  Simple example (just create a file with this content to
> try):
>
> --8<---------------cut here---------------start------------->8---
> I use Emacs, because Emacs is really cool!
>
> Local Variables:
> eval: (highlight-regexp "Emacs" "bold")
> End:
> --8<---------------cut here---------------end--------------->8---
>
> There are different solutions, depending on what you want to do
> specifically.  If you want syntactical highlighting, it's better to use
> font-lock, like in the example from Andreas.
>
>
> Regards,
>
> Michael.
>

[-- Attachment #2: Type: text/html, Size: 1329 bytes --]

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

end of thread, other threads:[~2012-01-25  6:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-20  7:41 change faces interactively ishi soichi
2012-01-20 15:30 ` Drew Adams
2012-01-21  1:20   ` ishi soichi
2012-01-21  2:07     ` Drew Adams
2012-01-23 10:51       ` Andreas Röhler
2012-01-23 18:05     ` Michael Heerdegen
2012-01-25  6:44       ` ishi soichi

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.