[comp.emacs] Character display

gaynor@paul.rutgers.edu (Silver) (12/01/89)

Suppose I were using a font that defined bit patters for all its characters,
not just the visible ascii characters.  How could I tell GNU Emacs 18.51 to
display these patterns instead of the usual caret-uppercase pair (the low boys)
or escaped octal triplets (the high boys)?  (I would prefer it that this were
possible.)

Regards, [Ag]

simon@viking.tub.UUCP (Simon Leinen) (12/04/89)

In article <Nov.30.19.28.59.1989.4073@paul.rutgers.edu>
gaynor@paul.rutgers.edu (Silver) writes:

   How could I tell GNU Emacs 18.51 to display these patterns instead
   of the usual caret-uppercase pair (the low boys) or escaped octal
   triplets (the high boys)?  (I would prefer it that this were
   possible.)

Just look at the file `xdisp.c' in the scr directory, lines 153 and
up.  I managed to have Emacs display umlauts and the like on the X
display by changing this file.  The problem is that you don't always
want this behaviour (at least other people won't), so you probably
create a user-settable LISP variable to control this.
-- 
Simon Leinen.

handa@etl.go.jp (Kenichi Handa) (12/06/89)

In article <SIMON.89Dec4112853@viking.tub.UUCP>
	simon@viking.tub.UUCP (Simon Leinen) writes:
|In article <Nov.30.19.28.59.1989.4073@paul.rutgers.edu>
|gaynor@paul.rutgers.edu (Silver) writes:
|   How could I tell GNU Emacs 18.51 to display these patterns instead
|   of the usual caret-uppercase pair (the low boys) or escaped octal
|   ...
|Just look at the file `xdisp.c' in the scr directory, lines 153 and
|up.  I managed to have Emacs display umlauts and the like on the X
|display by changing this file.

I think modifying xdisp.c is not enough.  You also have to
modify indent.c to move cursor to a correct column, don't you?

---
handa@etl.go.jp

cline@PROOF.ERGO.CS.CMU.EDU (Kenneth Cline) (12/07/89)

Incorporating the diffs for buffer.c, indent.c and xdisp.c below will
cause emacs to display 255 character fonts (newline is special) in
buffers with local variable ctl-arrow set to any value other than T or
NIL.

This change will be obsolete when version 19 is released, but it is
nonetheless useful for the time being.  It has been pointed out that
answering questions about the availability of version 19 takes time
away from writing the code, so please be patient.

By the way, I have been told that these diffs can not be automatically
incorporated into source files.  Forgive my ignorance of the proper
commands and be glad that the changes are small.

Ken (cline@cs.cmu.edu)

--------- cut here -----------
#
# type    sh /usrea0/cline/gnu/diff/diff   to unpack this archive.
#
echo extracting buffer.c.diff...
cat >buffer.c.diff <<'!E!O!F!'
1292c1292
<     "*t means display control chars with uparrow.\n\
---
>     "*Non-nil means display control chars with uparrow.\n\
1294,1297c1294
< Otherwise assume that control and meta chars are printable.\n\
< Automatically becomes local when set in any fashion.\n\
< \n\
< This is an Ergo local feature.");
---
> Automatically becomes local when set in any fashion.");
!E!O!F!
#
# type    sh /usrea0/cline/gnu/diff/diff   to unpack this archive.
#
echo extracting indent.c.diff...
cat >indent.c.diff <<'!E!O!F!'
69,70c69
<   int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
<                   + (EQ (bf_cur->ctl_arrow, Qt));
---
>   int ctl_arrow = !NULL (bf_cur->ctl_arrow);
110,111c109
< 	col += (ctl_arrow == 1 && c >= 0177) ? 1 :
< 	         (ctl_arrow && c < 0200) ? 2 : 4;
---
> 	col += (ctl_arrow && c < 0200) ? 2 : 4;
233,234c231
<   register int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
< 			   + (EQ (bf_cur->ctl_arrow, Qt));
---
>   register int ctl_arrow = !NULL (bf_cur->ctl_arrow);
259,260d255
<       else if (ctl_arrow == 1)
< 	0;
309,310c304
<   register int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
< 			   + (EQ (bf_cur->ctl_arrow, Qt));
---
>   register int ctl_arrow = !NULL (bf_cur->ctl_arrow);
374c368,369
< 	cpos += (ctl_arrow == 1) ? 1 : (ctl_arrow && c < 0200) ? 2 : 4;
---
> 	cpos += (ctl_arrow && c < 0200) ? 2 : 4;
> 
!E!O!F!
#
# type    sh /usrea0/cline/gnu/diff/diff   to unpack this archive.
#
echo extracting xdisp.c.diff...
cat >xdisp.c.diff <<'!E!O!F!'
1196,1197c1196
<   int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
<                   + (EQ (bf_cur->ctl_arrow, Qt));
---
>   int ctl_arrow = !NULL (bf_cur->ctl_arrow);
1313,1318d1311
<       else if (ctl_arrow == 1)
< 	{
< 	  if (p1 >= startp)
< 	    *p1 = c;
< 	  p1++;
< 	}
1912,1917d1904
< 	}
<       else if (buffer_defaults.ctl_arrow == 1)
< 	{
< 	  if (p1 >= start)
< 	    *p1 = c;
< 	  p1++;
!E!O!F!

jw@sics.se (Johan Widen) (12/08/89)

In article <7230@pt.cs.cmu.edu> cline@PROOF.ERGO.CS.CMU.EDU (Kenneth Cline) writes:
cline> Incorporating the diffs for buffer.c, indent.c and xdisp.c below will
cline> cause emacs to display 255 character fonts (newline is special) in
cline> buffers with local variable ctl-arrow set to any value other than T or
cline> NIL.

cline> By the way, I have been told that these diffs can not be automatically
cline> incorporated into source files.  Forgive my ignorance of the proper
cline> commands and be glad that the changes are small.

I applied the diff to emacs-18.55. Here is a context diff versus that version.

(Does anyone have a recipe for teaching emacs to read 8 bit characters
from the keyboard? How do I tell emacs that I want to enter an "umlaut a"
for instance?)

*** /tmp/,RCSt1a14606	Thu Dec  7 22:01:03 1989
--- buffer.c	Thu Dec  7 21:00:44 1989
***************
*** 1297,1305 ****
  Automatically becomes local when set in any fashion.");
  
    DEFVAR_PER_BUFFER ("ctl-arrow", &bf_cur->ctl_arrow,
!     "*Non-nil means display control chars with uparrow.\n\
  Nil means use backslash and octal digits.\n\
! Automatically becomes local when set in any fashion.");
  
    DEFVAR_PER_BUFFER ("truncate-lines", &bf_cur->truncate_lines,
      "*Non-nil means do not display continuation lines;\n\
--- 1297,1308 ----
  Automatically becomes local when set in any fashion.");
  
    DEFVAR_PER_BUFFER ("ctl-arrow", &bf_cur->ctl_arrow,
!     "*t means display control chars with uparrow.\n\
  Nil means use backslash and octal digits.\n\
! Otherwise assume that control and meta chars are printable.\n\
! Automatically becomes local when set in any fashion.\n\
! \n\
! This is an Ergo local feature.");
  
    DEFVAR_PER_BUFFER ("truncate-lines", &bf_cur->truncate_lines,
      "*Non-nil means do not display continuation lines;\n\
*** /tmp/,RCSt1a14611	Thu Dec  7 22:01:15 1989
--- indent.c	Thu Dec  7 21:12:42 1989
***************
*** 67,73 ****
    register int tab_seen;
    register int post_tab;
    register int tab_width = XINT (bf_cur->tab_width);
!   int ctl_arrow = !NULL (bf_cur->ctl_arrow);
  
    if (point == last_known_column_point
        && bf_modified == last_known_column_modified)
--- 67,74 ----
    register int tab_seen;
    register int post_tab;
    register int tab_width = XINT (bf_cur->tab_width);
!   int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
!                   + (EQ (bf_cur->ctl_arrow, Qt));
  
    if (point == last_known_column_point
        && bf_modified == last_known_column_modified)
***************
*** 109,115 ****
  	  tab_seen = 1;
  	}
        else
! 	col += (ctl_arrow && c < 0200) ? 2 : 4;
      }
  
    if (tab_seen)
--- 110,117 ----
  	  tab_seen = 1;
  	}
        else
! 	col += (ctl_arrow == 1 && c >= 0177) ? 1 :
! 	         (ctl_arrow && c < 0200) ? 2 : 4;
      }
  
    if (tab_seen)
***************
*** 231,237 ****
    register int goal;
    register int end = NumCharacters;
    register int tab_width = XINT (bf_cur->tab_width);
!   register int ctl_arrow = !NULL (bf_cur->ctl_arrow);
  
    Lisp_Object val;
  
--- 233,240 ----
    register int goal;
    register int end = NumCharacters;
    register int tab_width = XINT (bf_cur->tab_width);
!   register int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
! 			   + (EQ (bf_cur->ctl_arrow, Qt));
  
    Lisp_Object val;
  
***************
*** 258,263 ****
--- 261,268 ----
  	  col += tab_width - 1;
  	  col = col / tab_width * tab_width;
  	}
+       else if (ctl_arrow == 1)
+ 	continue;
        else if (ctl_arrow && (c < 040 || c == 0177))
          col++;
        else if (c < 040 || c >= 0177)
***************
*** 306,312 ****
    register int pos;
    register int c;
    register int tab_width = XFASTINT (bf_cur->tab_width);
!   register int ctl_arrow = !NULL (bf_cur->ctl_arrow);
    int selective
      = XTYPE (bf_cur->selective_display) == Lisp_Int
        ? XINT (bf_cur->selective_display)
--- 311,318 ----
    register int pos;
    register int c;
    register int tab_width = XFASTINT (bf_cur->tab_width);
!   register int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
! 			   + (EQ (bf_cur->ctl_arrow, Qt));
    int selective
      = XTYPE (bf_cur->selective_display) == Lisp_Int
        ? XINT (bf_cur->selective_display)
***************
*** 370,376 ****
  	    }
  	}
        else
! 	cpos += (ctl_arrow && c < 0200) ? 2 : 4;
  
        if (HPOS (cpos) >= width
  	  && (HPOS (cpos) > width
--- 376,382 ----
  	    }
  	}
        else
! 	cpos += (ctl_arrow == 1) ? 1 : (ctl_arrow && c < 0200) ? 2 : 4;
  
        if (HPOS (cpos) >= width
  	  && (HPOS (cpos) > width
*** /tmp/,RCSt1a14616	Thu Dec  7 22:01:38 1989
--- xdisp.c	Thu Dec  7 21:21:38 1989
***************
*** 1203,1209 ****
    register char *p1prev;
    register struct display_line *line;
    int tab_width = XINT (bf_cur->tab_width);
!   int ctl_arrow = !NULL (bf_cur->ctl_arrow);
    int width = XFASTINT (w->width) - 1
      - (XFASTINT (w->width) + XFASTINT (w->left) != screen_width);
    struct position val;
--- 1203,1210 ----
    register char *p1prev;
    register struct display_line *line;
    int tab_width = XINT (bf_cur->tab_width);
!   int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
!                   + (EQ (bf_cur->ctl_arrow, Qt));
    int width = XFASTINT (w->width) - 1
      - (XFASTINT (w->width) + XFASTINT (w->left) != screen_width);
    struct position val;
***************
*** 1319,1324 ****
--- 1320,1331 ----
  	    }
  	  break;
  	}
+       else if (ctl_arrow == 1)
+ 	{
+ 	  if (p1 >= startp)
+ 	    *p1 = c;
+ 	  p1++;
+ 	}
        else if (c < 0200 && ctl_arrow)
  	{
  	  if (p1 >= startp)
***************
*** 1917,1922 ****
--- 1924,1935 ----
  	      p1++;
  	    }
  	  while ((p1 - start + hscroll - (hscroll > 0)) % tab_width);
+ 	}
+       else if (buffer_defaults.ctl_arrow == 1)
+ 	{
+ 	  if (p1 >= start)
+ 	    *p1 = c;
+ 	  p1++;
  	}
        else if (c < 0200 && buffer_defaults.ctl_arrow)
  	{
--
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN	Internet: jw@sics.se
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30

jw@sics.se (Johan Widen) (12/29/89)

>>>>> In article <7230@pt.cs.cmu.edu>, cline@PROOF.ERGO.CS.CMU.EDU (Kenneth Cline) writes:

cline> Incorporating the diffs for buffer.c, indent.c and xdisp.c below will
cline> cause emacs to display 255 character fonts (newline is special) in
cline> buffers with local variable ctl-arrow set to any value other than T or
cline> NIL.

cline> This change will be obsolete when version 19 is released, but it is
cline> nonetheless useful for the time being.  It has been pointed out that
cline> answering questions about the availability of version 19 takes time
cline> away from writing the code, so please be patient.

There seems to be a problem with the patch: it lets control characters
get through. The following complete patch will display 8-bit characters as
themselves but will display control characters according to the ^C convention.

*** /tmp/,RCSt1a05022	Thu Dec 28 19:33:09 1989
--- buffer.c	Thu Dec  7 21:00:44 1989
***************
*** 1297,1305 ****
  Automatically becomes local when set in any fashion.");
  
    DEFVAR_PER_BUFFER ("ctl-arrow", &bf_cur->ctl_arrow,
!     "*Non-nil means display control chars with uparrow.\n\
  Nil means use backslash and octal digits.\n\
! Automatically becomes local when set in any fashion.");
  
    DEFVAR_PER_BUFFER ("truncate-lines", &bf_cur->truncate_lines,
      "*Non-nil means do not display continuation lines;\n\
--- 1297,1308 ----
  Automatically becomes local when set in any fashion.");
  
    DEFVAR_PER_BUFFER ("ctl-arrow", &bf_cur->ctl_arrow,
!     "*t means display control chars with uparrow.\n\
  Nil means use backslash and octal digits.\n\
! Otherwise assume that control and meta chars are printable.\n\
! Automatically becomes local when set in any fashion.\n\
! \n\
! This is an Ergo local feature.");
  
    DEFVAR_PER_BUFFER ("truncate-lines", &bf_cur->truncate_lines,
      "*Non-nil means do not display continuation lines;\n\
*** /tmp/,RCSt1a05027	Thu Dec 28 19:33:34 1989
--- indent.c	Wed Dec 27 10:56:26 1989
***************
*** 67,73 ****
    register int tab_seen;
    register int post_tab;
    register int tab_width = XINT (bf_cur->tab_width);
!   int ctl_arrow = !NULL (bf_cur->ctl_arrow);
  
    if (point == last_known_column_point
        && bf_modified == last_known_column_modified)
--- 67,74 ----
    register int tab_seen;
    register int post_tab;
    register int tab_width = XINT (bf_cur->tab_width);
!   int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
!                   + (EQ (bf_cur->ctl_arrow, Qt));
  
    if (point == last_known_column_point
        && bf_modified == last_known_column_modified)
***************
*** 109,115 ****
  	  tab_seen = 1;
  	}
        else
! 	col += (ctl_arrow && c < 0200) ? 2 : 4;
      }
  
    if (tab_seen)
--- 110,117 ----
  	  tab_seen = 1;
  	}
        else
! 	col += (ctl_arrow == 1 && c >= 0177) ? 1 :
! 	         (ctl_arrow && c < 0200) ? 2 : 4;
      }
  
    if (tab_seen)
***************
*** 231,237 ****
    register int goal;
    register int end = NumCharacters;
    register int tab_width = XINT (bf_cur->tab_width);
!   register int ctl_arrow = !NULL (bf_cur->ctl_arrow);
  
    Lisp_Object val;
  
--- 233,240 ----
    register int goal;
    register int end = NumCharacters;
    register int tab_width = XINT (bf_cur->tab_width);
!   register int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
! 			   + (EQ (bf_cur->ctl_arrow, Qt));
  
    Lisp_Object val;
  
***************
*** 258,263 ****
--- 261,268 ----
  	  col += tab_width - 1;
  	  col = col / tab_width * tab_width;
  	}
+       else if (ctl_arrow == 1 && c >= 040)
+ 	continue;
        else if (ctl_arrow && (c < 040 || c == 0177))
          col++;
        else if (c < 040 || c >= 0177)
***************
*** 306,312 ****
    register int pos;
    register int c;
    register int tab_width = XFASTINT (bf_cur->tab_width);
!   register int ctl_arrow = !NULL (bf_cur->ctl_arrow);
    int selective
      = XTYPE (bf_cur->selective_display) == Lisp_Int
        ? XINT (bf_cur->selective_display)
--- 311,318 ----
    register int pos;
    register int c;
    register int tab_width = XFASTINT (bf_cur->tab_width);
!   register int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
! 			   + (EQ (bf_cur->ctl_arrow, Qt));
    int selective
      = XTYPE (bf_cur->selective_display) == Lisp_Int
        ? XINT (bf_cur->selective_display)
***************
*** 370,376 ****
  	    }
  	}
        else
! 	cpos += (ctl_arrow && c < 0200) ? 2 : 4;
  
        if (HPOS (cpos) >= width
  	  && (HPOS (cpos) > width
--- 376,382 ----
  	    }
  	}
        else
! 	cpos += (ctl_arrow == 1 && c >= 040 ) ? 1 : (ctl_arrow && c < 0200) ? 2 : 4;
  
        if (HPOS (cpos) >= width
  	  && (HPOS (cpos) > width
*** /tmp/,RCSt1a05032	Thu Dec 28 19:33:45 1989
--- xdisp.c	Wed Dec 27 10:56:23 1989
***************
*** 1203,1209 ****
    register char *p1prev;
    register struct display_line *line;
    int tab_width = XINT (bf_cur->tab_width);
!   int ctl_arrow = !NULL (bf_cur->ctl_arrow);
    int width = XFASTINT (w->width) - 1
      - (XFASTINT (w->width) + XFASTINT (w->left) != screen_width);
    struct position val;
--- 1203,1210 ----
    register char *p1prev;
    register struct display_line *line;
    int tab_width = XINT (bf_cur->tab_width);
!   int ctl_arrow = (!NULL (bf_cur->ctl_arrow))
!                   + (EQ (bf_cur->ctl_arrow, Qt));
    int width = XFASTINT (w->width) - 1
      - (XFASTINT (w->width) + XFASTINT (w->left) != screen_width);
    struct position val;
***************
*** 1319,1324 ****
--- 1320,1331 ----
  	    }
  	  break;
  	}
+       else if (ctl_arrow == 1 && c >= 040)
+ 	{
+ 	  if (p1 >= startp)
+ 	    *p1 = c;
+ 	  p1++;
+ 	}
        else if (c < 0200 && ctl_arrow)
  	{
  	  if (p1 >= startp)
***************
*** 1917,1922 ****
--- 1924,1935 ----
  	      p1++;
  	    }
  	  while ((p1 - start + hscroll - (hscroll > 0)) % tab_width);
+ 	}
+       else if (buffer_defaults.ctl_arrow == 1 && c >= 040)
+ 	{
+ 	  if (p1 >= start)
+ 	    *p1 = c;
+ 	  p1++;
  	}
        else if (c < 0200 && buffer_defaults.ctl_arrow)
  	{
--
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN	Internet: jw@sics.se
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30