unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Diff mode faces
@ 2005-06-17 11:47 Juri Linkov
  2005-06-17 13:11 ` Jason Rumney
                   ` (3 more replies)
  0 siblings, 4 replies; 59+ messages in thread
From: Juri Linkov @ 2005-06-17 11:47 UTC (permalink / raw)


The default diff face used to highlight changed lines on tty
(magenta/yellow bold italic) makes an indigestible fruit salad.
OTOH, the same face has no highlighting under X.  This makes
sense, because changed lines are the primary text in diff files
that doesn't need special highlighting.

I propose instead of highlighting whole lines on tty to use at least
the same approach as introduced recently for comments on tty to highlight
only comment delimiters in new face font-lock-comment-delimiter-face.
Similarly, only diff indicators (the first character of the line) could
be highlighted in diff buffers on tty.

The patch below adds three new faces for highlighting diff indicators.
On tty they inherit from font-lock-comment-delimiter-face, but on X
there is no highlighting which preserves the current default appearance.
These faces are useful not only on tty but even on window systems
where users might want to redefine them.

Also I noticed that unlike context hunk headers `--- 123 ---',
normal (i.e. neither context nor unified) hunk headers `---' are
not highlighted.  The same patch fixes that.

With -D option diff makes `#ifdef' format output with conditional
preprocessor directives.  Currently diff-mode.el uses hard-coded
font-lock-string-face to highlight them.  The patch adds a new face
to allow users to configure it.  By default, it inherits from
font-lock-preprocessor-face.

Index: lisp/diff-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/diff-mode.el,v
retrieving revision 1.75
diff -u -r1.75 diff-mode.el
--- lisp/diff-mode.el	14 Jun 2005 14:34:40 -0000	1.75
+++ lisp/diff-mode.el	17 Jun 2005 11:21:23 -0000
@@ -240,16 +240,34 @@
 (defvar diff-added-face 'diff-added)
 
 (defface diff-changed
-  '((((type tty pc) (class color) (background light))
-     :foreground "magenta" :weight bold :slant italic)
-    (((type tty pc) (class color) (background dark))
-     :foreground "yellow" :weight bold :slant italic))
+  nil
   "`diff-mode' face used to highlight changed lines."
   :group 'diff-mode)
 ;; backward-compatibility alias
 (put 'diff-changed-face 'face-alias 'diff-changed)
 (defvar diff-changed-face 'diff-changed)
 
+(defface diff-indicator-removed
+  '((t :inherit diff-indicator-changed))
+  "`diff-mode' face used to highlight indicator of removed lines (-, <)."
+  :group 'diff-mode
+  :version "22.1")
+(defvar diff-indicator-removed-face 'diff-indicator-removed)
+
+(defface diff-indicator-added
+  '((t :inherit diff-indicator-changed))
+  "`diff-mode' face used to highlight indicator of added lines (+, >)."
+  :group 'diff-mode
+  :version "22.1")
+(defvar diff-indicator-added-face 'diff-indicator-added)
+
+(defface diff-indicator-changed
+  '((((type tty pc) (class color)) :inherit font-lock-comment-delimiter-face))
+  "`diff-mode' face used to highlight indicator of changed lines."
+  :group 'diff-mode
+  :version "22.1")
+(defvar diff-indicator-changed-face 'diff-indicator-changed)
+
 (defface diff-function
   '((t :inherit diff-context))
   "`diff-mode' face used to highlight function names produced by \"diff -p\"."
@@ -274,6 +292,13 @@
 (put 'diff-nonexistent-face 'face-alias 'diff-nonexistent)
 (defvar diff-nonexistent-face 'diff-nonexistent)
 
+(defface diff-preprocessor
+  '((t :inherit  font-lock-preprocessor-face))
+  "`diff-mode' face used to highlight preprocessor lines staring with #."
+  :group 'diff-mode
+  :version "22.1")
+(defvar diff-preprocessor-face 'diff-preprocessor)
+
 (defconst diff-yank-handler '(diff-yank-function))
 (defun diff-yank-function (text)
   ;; FIXME: the yank-handler is now called separately on each piece of text
@@ -306,15 +331,16 @@
      (1 diff-hunk-header-face)
      (2 diff-function-face))
     ("^\\*\\*\\* .+ \\*\\*\\*\\*". diff-hunk-header-face) ;context
+    ("^---$" . diff-hunk-header-face) ; normal
     ("^\\(---\\|\\+\\+\\+\\|\\*\\*\\*\\) \\(\\S-+\\)\\(.*[^*-]\\)?\n"
      (0 diff-header-face) (2 diff-file-header-face prepend))
     ("^[0-9,]+[acd][0-9,]+$" . diff-hunk-header-face)
-    ("^!.*\n" (0 diff-changed-face))
-    ("^[+>].*\n" (0 diff-added-face))
-    ("^[-<].*\n" (0 diff-removed-face))
+    ("^\\([-<]\\)\\(.*\n\\)" (1 diff-indicator-removed-face) (2 diff-removed-face))
+    ("^\\([+>]\\)\\(.*\n\\)" (1 diff-indicator-added-face) (2 diff-added-face))
+    ("^\\(!\\)\\(.*\n\\)" (1 diff-indicator-changed-face) (2 diff-changed-face))
     ("^Index: \\(.+\\).*\n" (0 diff-header-face) (1 diff-index-face prepend))
     ("^Only in .*\n" . diff-nonexistent-face)
-    ("^#.*" . font-lock-string-face)
+    ("^#.*" . diff-preprocessor-face)
     ("^[^-=+*!<>].*\n" (0 diff-context-face))))
 
 (defconst diff-font-lock-defaults

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

end of thread, other threads:[~2005-07-16 11:17 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-17 11:47 Diff mode faces Juri Linkov
2005-06-17 13:11 ` Jason Rumney
2005-06-17 14:28 ` Stefan Monnier
2005-06-18 13:54   ` Juri Linkov
2005-06-17 14:34 ` Eli Zaretskii
2005-06-18 13:57   ` Juri Linkov
2005-06-18 15:27     ` Randal L. Schwartz
2005-06-18 16:46       ` Eli Zaretskii
2005-06-19 13:09         ` Juri Linkov
2005-06-19 19:58           ` Eli Zaretskii
2005-06-20  4:48             ` Juri Linkov
2005-06-20 20:18               ` Eli Zaretskii
2005-06-21 16:28                 ` Background mode (was: Diff mode faces) Juri Linkov
2005-06-27  0:03                   ` Background mode Juri Linkov
2005-06-27 16:46                     ` Richard M. Stallman
2005-06-27 23:52                       ` Juri Linkov
2005-06-28 18:47                         ` Richard M. Stallman
2005-06-29  3:55                           ` Stefan Monnier
2005-06-29 22:21                             ` Miles Bader
2005-06-30 17:45                               ` Stefan Monnier
2005-07-01  4:03                                 ` Richard M. Stallman
2005-07-01 15:01                                   ` Stefan Monnier
2005-06-27 23:55                     ` Juri Linkov
2005-06-19 13:05       ` Diff mode faces Juri Linkov
2005-06-19 17:10         ` Luc Teirlinck
2005-06-19 17:34           ` Randal L. Schwartz
2005-06-27 23:55           ` Juri Linkov
2005-06-28  4:57             ` Miles Bader
2005-07-01 23:59               ` Juri Linkov
2005-07-02  3:37                 ` Miles Bader
2005-07-05 19:11               ` Richard M. Stallman
2005-07-06 20:53                 ` Juri Linkov
2005-07-07  4:05                   ` Miles Bader
2005-07-07  6:03                     ` Juri Linkov
2005-07-07  4:42                   ` Eli Zaretskii
2005-07-09 20:56                     ` Juri Linkov
2005-07-10  3:34                       ` Eli Zaretskii
2005-07-11  0:06                         ` Juri Linkov
2005-07-11 13:43                           ` Stefan Monnier
2005-07-11 19:37                             ` Eli Zaretskii
2005-07-11 19:46                               ` Stefan Monnier
2005-07-12  3:33                                 ` Eli Zaretskii
2005-07-12  6:51                             ` Juri Linkov
2005-07-16 11:17                               ` Eli Zaretskii
2005-06-28 13:10             ` Randal L. Schwartz
2005-06-30 21:30             ` Richard M. Stallman
2005-06-30 21:30             ` Richard M. Stallman
2005-07-01 10:13               ` Eli Zaretskii
2005-07-01 23:59                 ` Juri Linkov
2005-07-03 18:56                   ` xterm colors (was: Diff mode faces) Gaëtan LEURENT
2005-07-04  5:59                     ` Eli Zaretskii
2005-07-04  6:17                     ` Richard M. Stallman
2005-07-01 23:59               ` Diff mode faces Juri Linkov
2005-06-20  0:25         ` Miles Bader
2005-06-18  2:21 ` Richard Stallman
2005-06-18 13:54   ` Juri Linkov
2005-06-19  3:51     ` Richard Stallman
2005-06-19 14:05       ` Juri Linkov
2005-06-20  3:50         ` Richard Stallman

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

	https://git.savannah.gnu.org/cgit/emacs.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).