emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Highlight special string
@ 2010-11-24  8:21 Karl Maihofer
  2010-11-26 13:52 ` Darlan Cavalcante Moreira
       [not found] ` <29926_1290779567_oAQDqlho000818_4cefbbaa.1245960a.7fe6.7855@mx.google.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Karl Maihofer @ 2010-11-24  8:21 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I don't know if this is an Org- or Emacs-Question. For highlighting  
special strings in AucTeX I used a variable  
"font-latex-user-keyword-classes" so I thought there may be an  
org-specific variable to achieve what I want in orgmode.

I'd like to highlight the strings "(ok)" and "(fail)" in my  
Org-document. Ok should get a green background, fail a red one. I  
think highlighting in emacs should last, but it would be great to have  
these strings highlighted in HTML-export, too, if this is no problem.

Could anybody give me a hint how to define highlighting for special  
strings in orgmode?

Thanks a lot!
Karl

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

* Re: Highlight special string
  2010-11-24  8:21 Highlight special string Karl Maihofer
@ 2010-11-26 13:52 ` Darlan Cavalcante Moreira
       [not found] ` <29926_1290779567_oAQDqlho000818_4cefbbaa.1245960a.7fe6.7855@mx.google.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Darlan Cavalcante Moreira @ 2010-11-26 13:52 UTC (permalink / raw)
  To: Karl Maihofer; +Cc: emacs-orgmode


Not exactly what you want, but for temporary highlights (useful for
instance to see if you are repeating the same word too much in a text) you
can use hi-lock-mode.

Turn hi-lock-mode on with M-x hi-lock-mode. Then you can highlight a word
with "C-x w h" (highlight-regexp) or a the line containing a word with "C-x
w l" (highlight-lines-matching-regexp). Remove highlights with "C-x w r".

--
Darlan


At Wed, 24 Nov 2010 09:21:00 +0100,
Karl Maihofer <ignoramus@gmx.de> wrote:
> 
> Hi,
> 
> I don't know if this is an Org- or Emacs-Question. For highlighting  
> special strings in AucTeX I used a variable  
> "font-latex-user-keyword-classes" so I thought there may be an  
> org-specific variable to achieve what I want in orgmode.
> 
> I'd like to highlight the strings "(ok)" and "(fail)" in my  
> Org-document. Ok should get a green background, fail a red one. I  
> think highlighting in emacs should last, but it would be great to have  
> these strings highlighted in HTML-export, too, if this is no problem.
> 
> Could anybody give me a hint how to define highlighting for special  
> strings in orgmode?
> 
> Thanks a lot!
> Karl
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Highlight special string
       [not found] ` <29926_1290779567_oAQDqlho000818_4cefbbaa.1245960a.7fe6.7855@mx.google.com>
@ 2010-11-26 18:08   ` Karl Maihofer
       [not found]     ` <20101126190854.93661hlkuwyoopno-2RFepEojUI1937y/D5i71g@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Karl Maihofer @ 2010-11-26 18:08 UTC (permalink / raw)
  To: Darlan Cavalcante Moreira; +Cc: emacs-orgmode

Hi Darlan!

Thanks a lot! That's a good solution.

Regards,
Karl

Darlan Cavalcante Moreira <darcamo@gmail.com> schrieb:

>
> Not exactly what you want, but for temporary highlights (useful for
> instance to see if you are repeating the same word too much in a text) you
> can use hi-lock-mode.
>
> Turn hi-lock-mode on with M-x hi-lock-mode. Then you can highlight a word
> with "C-x w h" (highlight-regexp) or a the line containing a word with "C-x
> w l" (highlight-lines-matching-regexp). Remove highlights with "C-x w r".
>
> --
> Darlan
>
>
> At Wed, 24 Nov 2010 09:21:00 +0100,
> Karl Maihofer <ignoramus@gmx.de> wrote:
>>
>> Hi,
>>
>> I don't know if this is an Org- or Emacs-Question. For highlighting
>> special strings in AucTeX I used a variable
>> "font-latex-user-keyword-classes" so I thought there may be an
>> org-specific variable to achieve what I want in orgmode.
>>
>> I'd like to highlight the strings "(ok)" and "(fail)" in my
>> Org-document. Ok should get a green background, fail a red one. I
>> think highlighting in emacs should last, but it would be great to have
>> these strings highlighted in HTML-export, too, if this is no problem.
>>
>> Could anybody give me a hint how to define highlighting for special
>> strings in orgmode?
>>
>> Thanks a lot!

>

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

* Re: Highlight special string
       [not found]     ` <20101126190854.93661hlkuwyoopno-2RFepEojUI1937y/D5i71g@public.gmane.org>
@ 2010-11-27  8:41       ` Sébastien Vauban
  0 siblings, 0 replies; 4+ messages in thread
From: Sébastien Vauban @ 2010-11-27  8:41 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Karl,

Karl Maihofer wrote:
> Darlan Cavalcante Moreira <darcamo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> schrieb:
>> Karl Maihofer <ignoramus-Mmb7MZpHnFY@public.gmane.org> wrote:
>>> I'd like to highlight the strings "(ok)" and "(fail)" in my Org-document.
>>> Ok should get a green background, fail a red one. I think highlighting in
>>> emacs should last, but it would be great to have these strings highlighted
>>> in HTML-export, too, if this is no problem.
>>
>> Not exactly what you want, but for temporary highlights (useful for
>> instance to see if you are repeating the same word too much in a text) you
>> can use hi-lock-mode.
>>
>> Turn hi-lock-mode on with M-x hi-lock-mode. Then you can highlight a word
>> with "C-x w h" (highlight-regexp) or a the line containing a word with "C-x
>> w l" (highlight-lines-matching-regexp). Remove highlights with "C-x w r".

Please find the *lasting* solution that I'm using, hence IMHO better than
hi-lock.

The only thing you would still miss is the ability to get those highlighted
words exported to HTML or PDF.

#+begin_src emacs-lisp
      ;; special words
      (setq my/keywords-error-pattern
            "\\(BUG\\|FIXME\\|XXX\\|TODO\\|[Ee]rror\\|ERROR\\|[Ww]arning\\|[Mm]issing\\|[Ii]nvalid\\|[Ff]ailed\\|[Cc]orrupted\\|[Ff]atal\\|FATAL\\|[Uu]ndefined\\|[Dd]enied\\)")

      (make-face 'my/keywords-error-face)
      (GNUEmacs (set-face-attribute 'my/keywords-error-face nil
                                    ;; :family "Serif"
                                    ;; :height 0.9
                                    :weight 'normal :slant 'normal
                                    :box '(:line-width 1 :color "#CC0000")
                                    :foreground "#CC0000"
                                    :background "#FFFF88"
                                    ))

      (setq my/keywords-org-error-pattern
            "\\(BUG\\|FIXME\\|XXX\\|[^*] TODO\\|[Ee]rror\\|[Ww]arning\\|[Mm]issing\\|[Ii]nvalid\\|[Ff]ailed\\|[Cc]orrupted\\|[Ff]atal\\|[Uu]ndefined\\)")
                                        ; smaller subset of keywords for
                                        ; ensuring no conflict with Org mode
                                        ; TODO keywords
      ;; FIXME Highlighting all special keywords but "TODO" in Org mode is
      ;; already a good step. Though, a nicer integration would be that "TODO"
      ;; strings in the headings are not touched by this code, and that only
      ;; "TODO" strings in the text body would be. Don't know (yet) how to do
      ;; that...

      ;; FIXME TODO should be highlighted in Org, even when at beginning of
      ;; line -- of course, without * in front of it.

      ;; set up highlighting of special words for proper selected major modes
      ;; only
      (dolist (mode '(fundamental-mode
                      svn-log-view-mode
                      text-mode))
                                        ; no interference with Org mode (which
                                        ; derives from text-mode)
        (font-lock-add-keywords
         mode
         `((,my/keywords-error-pattern 1 'my/keywords-error-face prepend))))

      ;; set up highlighting of special words for Org mode only
      (dolist (mode '(org-mode))
        (font-lock-add-keywords
         mode
         `((,my/keywords-org-error-pattern 1 'my/keywords-error-face prepend))))

      ;; add fontification patterns (even in comments) to a selected major
      ;; mode *and* all major modes derived from it
      (defun fontify-keywords ()
        (interactive)
        ;;   (font-lock-mode -1)
        ;;   (font-lock-mode 1)
        (font-lock-add-keywords
         nil
         `((,my/keywords-error-pattern 1 'my/keywords-error-face prepend))))
      ;; FIXME                         0                          t

      ;; set up highlighting of special words for selected major modes *and*
      ;; all major modes derived from them
      (dolist (hook '(c++-mode-hook
                      c-mode-hook
                      change-log-mode-hook
                      cperl-mode-hook
                      css-mode-hook
                      emacs-lisp-mode-hook
                      html-mode-hook
                      java-mode-hook
                      latex-mode-hook
                      lisp-mode-hook
                      makefile-mode-hook
                      message-mode-hook
                      php-mode-hook
                      python-mode-hook
                      sh-mode-hook
                      shell-mode-hook ;; works in *shell* buffers!
                      ssh-config-mode-hook))
        (add-hook hook 'fontify-keywords))
#+end_src

As signaled in my comments, the only problem I have is that when such a word
appears in a Org heading, the Org heading fontification is disabled -- only
for that single line!

Would someone be able to fix that last tiny feature...

Best regards,
  Seb

-- 
Sébastien Vauban


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2010-11-27  8:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-24  8:21 Highlight special string Karl Maihofer
2010-11-26 13:52 ` Darlan Cavalcante Moreira
     [not found] ` <29926_1290779567_oAQDqlho000818_4cefbbaa.1245960a.7fe6.7855@mx.google.com>
2010-11-26 18:08   ` Karl Maihofer
     [not found]     ` <20101126190854.93661hlkuwyoopno-2RFepEojUI1937y/D5i71g@public.gmane.org>
2010-11-27  8:41       ` Sébastien Vauban

Code repositories for project(s) associated with this public inbox

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

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).