qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs buffer.c html.c qe.c qeconfig.h variable...


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs buffer.c html.c qe.c qeconfig.h variable...
Date: Tue, 21 Jan 2014 00:01:22 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        14/01/21 00:01:22

Modified files:
        .              : buffer.c html.c qe.c qeconfig.h variables.c 
                         clang.c makemode.c qe.h shell.c 

Log message:
        improve consistency in buffer variables
        
        * change tab-size to tab-width
        * make tab-width a buffer variable
        * add fill-column buffer variable
        * add set-fill-column on C-x f
        * add default-tab-width and default-fill-column global variables
        * force indent-tabs-mode in makefile mode
        * force tab-width to 8 in shell output buffers

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.63&r2=1.64
http://cvs.savannah.gnu.org/viewcvs/qemacs/html.c?cvsroot=qemacs&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.131&r2=1.132
http://cvs.savannah.gnu.org/viewcvs/qemacs/qeconfig.h?cvsroot=qemacs&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/qemacs/variables.c?cvsroot=qemacs&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/qemacs/makemode.c?cvsroot=qemacs&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.127&r2=1.128
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.79&r2=1.80

Patches:
Index: buffer.c
===================================================================
RCS file: /sources/qemacs/qemacs/buffer.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -b -r1.63 -r1.64
--- buffer.c    19 Jan 2014 17:25:02 -0000      1.63
+++ buffer.c    21 Jan 2014 00:01:20 -0000      1.64
@@ -484,7 +484,8 @@
     b->save_log = ((flags & BF_SAVELOG) != 0);
 
     /* initialize default mode stuff */
-    b->tab_size = 8;    /* CG: not finished */
+    b->tab_width = qs->default_tab_width;
+    b->fill_column = qs->default_fill_column;
 
     /* add buffer in global buffer list (at end for system buffers) */
     pb = &qs->first_buffer;

Index: html.c
===================================================================
RCS file: /sources/qemacs/qemacs/html.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- html.c      20 Jan 2014 18:04:01 -0000      1.26
+++ html.c      21 Jan 2014 00:01:21 -0000      1.27
@@ -791,7 +791,6 @@
     if (!saved_data) {
         memset(s, 0, SAVED_DATA_SIZE);
         s->insert = 1;
-        s->tab_size = 8;
         s->indent_size = 4;
         s->default_style = QE_STYLE_DEFAULT;
         s->wrap = WRAP_LINE;

Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -b -r1.131 -r1.132
--- qe.c        20 Jan 2014 18:04:01 -0000      1.131
+++ qe.c        21 Jan 2014 00:01:21 -0000      1.132
@@ -572,8 +572,6 @@
     do_kill(s, start, s->offset, dir);
 }
 
-#define PARAGRAPH_WIDTH 76
-
 void do_fill_paragraph(EditState *s)
 {
     int par_start, par_end, col;
@@ -629,7 +627,7 @@
         } else {
             /* insert space single space then word */
             if (offset == par_end ||
-                (col + 1 + word_size > PARAGRAPH_WIDTH)) {
+                (col + 1 + word_size > s->b->fill_column)) {
                 eb_delete_uchar(s->b, chunk_start);
                 chunk_start += eb_insert_uchar(s->b, chunk_start, '\n');
                 if (offset < par_end) {
@@ -2045,7 +2043,7 @@
 void do_set_tab_width(EditState *s, int tab_width)
 {
     if (tab_width > 1)
-        s->tab_size = tab_width;
+        s->b->tab_width = tab_width;
 }
 
 void do_set_indent_width(EditState *s, int indent_width)
@@ -2059,6 +2057,12 @@
     s->indent_tabs_mode = (val != 0);
 }
 
+void do_set_fill_column(EditState *s, int fill_column)
+{
+    if (fill_column > 1)
+        s->b->fill_column = fill_column;
+}
+
 /* compute string for the first part of the mode line (flags,
    filename, modename) */
 void basic_mode_line(EditState *s, buf_t *out, int c1)
@@ -2425,7 +2429,7 @@
     s->eol_width = max(s->eol_width, glyph_width(e->screen, font, '$'));
     s->default_line_height = font->ascent + font->descent;
     s->space_width = glyph_width(e->screen, font, ' ');
-    s->tab_width = s->space_width * e->tab_size;
+    s->tab_width = s->space_width * e->b->tab_width;
     s->width = e->width - s->eol_width;
     s->height = e->height;
     s->hex_mode = e->hex_mode;
@@ -7135,7 +7139,6 @@
     if (!saved_data) {
         memset(s, 0, SAVED_DATA_SIZE);
         s->insert = 1;
-        s->tab_size = 8;
         s->indent_size = 4;
         s->default_style = QE_STYLE_DEFAULT;
         s->wrap = WRAP_LINE;
@@ -7879,6 +7882,8 @@
     qs->argv = argv;
 
     qs->hilite_region = 1;
+    qs->default_tab_width = 8;
+    qs->default_fill_column = 70;
     qs->mmap_threshold = MIN_MMAP_SIZE;
     qs->max_load_size = MAX_LOAD_SIZE;
 

Index: qeconfig.h
===================================================================
RCS file: /sources/qemacs/qemacs/qeconfig.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- qeconfig.h  19 Jan 2014 15:33:56 -0000      1.42
+++ qeconfig.h  21 Jan 2014 00:01:21 -0000      1.43
@@ -384,6 +384,9 @@
     CMD2( KEY_NONE, KEY_NONE,
           "set-indent-tabs-mode", do_set_indent_tabs_mode, ESi,
           "ui{Indent tabs mode (0 or 1): }")
+    CMD2( KEY_CTRLX('f'), KEY_NONE,
+          "set-fill-column", do_set_fill_column, ESi,
+          "ui{Fill column: }")
 
     /* other stuff */
     CMD2( KEY_NONE, KEY_NONE,

Index: variables.c
===================================================================
RCS file: /sources/qemacs/qemacs/variables.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- variables.c 4 Jan 2014 17:28:36 -0000       1.10
+++ variables.c 21 Jan 2014 00:01:21 -0000      1.11
@@ -45,7 +45,8 @@
     S_VAR( "mmap-threshold", mmap_threshold, VAR_NUMBER, VAR_RW )
     S_VAR( "max-load-size", max_load_size, VAR_NUMBER, VAR_RW )
     S_VAR( "show-unicode", show_unicode, VAR_NUMBER, VAR_RW )
-
+    S_VAR( "default-tab-width", default_tab_width, VAR_NUMBER, VAR_RW )
+    S_VAR( "default-fill-column", default_fill_column, VAR_NUMBER, VAR_RW )
 
     //B_VAR( "screen-charset", charset, VAR_NUMBER, VAR_RW )
 
@@ -53,10 +54,11 @@
     B_VAR( "bufsize", total_size, VAR_NUMBER, VAR_RO )
     B_VAR( "bufname", name, VAR_CHARS, VAR_RO )
     B_VAR( "filename", filename, VAR_CHARS, VAR_RO )
+    B_VAR( "tab-width", tab_width, VAR_NUMBER, VAR_RW )
+    B_VAR( "fill-column", fill_column, VAR_NUMBER, VAR_RW )
 
     W_VAR( "point", offset, VAR_NUMBER, VAR_RW )
-    W_VAR( "tab-size", tab_size, VAR_NUMBER, VAR_RW )
-    W_VAR( "indent-size", indent_size, VAR_NUMBER, VAR_RW )
+    W_VAR( "indent-width", indent_size, VAR_NUMBER, VAR_RW )
     W_VAR( "indent-tabs-mode", indent_tabs_mode, VAR_NUMBER, VAR_RW )
     W_VAR( "default-style", default_style, VAR_NUMBER, VAR_RW )
     W_VAR( "region-style", region_style, VAR_NUMBER, VAR_RW )

Index: clang.c
===================================================================
RCS file: /sources/qemacs/qemacs/clang.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- clang.c     20 Jan 2014 18:04:00 -0000      1.44
+++ clang.c     21 Jan 2014 00:01:21 -0000      1.45
@@ -293,7 +293,7 @@
     for (;;) {
         c = *p++ & CHAR_MASK;
         if (c == '\t')
-            pos += s->tab_size - (pos % s->tab_size);
+            pos += s->b->tab_width - (pos % s->b->tab_width);
         else if (c == ' ')
             pos++;
         else
@@ -310,7 +310,7 @@
     for (i = 0; i < size; i++) {
         c = buf[i] & CHAR_MASK;
         if (c == '\t')
-            pos += s->tab_size - (pos % s->tab_size);
+            pos += s->b->tab_width - (pos % s->b->tab_width);
         else
             pos++;
     }
@@ -333,9 +333,9 @@
 
     /* insert tabs */
     if (s->indent_tabs_mode) {
-        while (i >= s->tab_size) {
+        while (i >= s->b->tab_width) {
             offset += eb_insert_uchar(s->b, offset, '\t');
-            i -= s->tab_size;
+            i -= s->b->tab_width;
         }
     }
 

Index: makemode.c
===================================================================
RCS file: /sources/qemacs/qemacs/makemode.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- makemode.c  5 Jan 2014 23:42:54 -0000       1.7
+++ makemode.c  21 Jan 2014 00:01:21 -0000      1.8
@@ -161,6 +161,14 @@
 
 static ModeDef makefile_mode;
 
+static int makefile_mode_init(EditState *s, __unused__ ModeSavedData 
*saved_data)
+{
+    text_mode_init(s, saved_data);
+    s->b->tab_width = 8;
+    s->indent_tabs_mode = 1;
+    return 0;
+}
+
 static int makefile_init(void)
 {
     /* Makefile mode is almost like the text mode, so we copy and patch it */
@@ -168,6 +176,7 @@
     makefile_mode.name = "Makefile";
     makefile_mode.extensions = "mk|mak";
     makefile_mode.mode_probe = makefile_mode_probe;
+    makefile_mode.mode_init = makefile_mode_init;
     makefile_mode.colorize_func = makefile_colorize_line;
 
     qe_register_mode(&makefile_mode);

Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -b -r1.127 -r1.128
--- qe.h        20 Jan 2014 18:04:00 -0000      1.127
+++ qe.h        21 Jan 2014 00:01:21 -0000      1.128
@@ -798,7 +798,9 @@
 
     /* default mode stuff when buffer is detached from window */
     int offset;         /* used in eval.c */
-    int tab_size;
+
+    int tab_width;
+    int fill_column;
 
     EditBuffer *next; /* next editbuffer in qe_state buffer list */
 
@@ -1013,7 +1015,7 @@
     int cur_rtl;     /* TRUE if the cursor on over RTL chars */
     enum WrapType wrap;
     int line_numbers;
-    int tab_size;    /* the tab width for the window in chars */
+    /* XXX: these should be buffer specific rather than window specific */
     int indent_size;
     int indent_tabs_mode; /* if true, use tabs to indent */
     int interactive; /* true if interaction is done instead of editing
@@ -1295,6 +1297,8 @@
     int hilite_region;  /* hilite the current region when selecting */
     int mmap_threshold; /* minimum file size for mmap */
     int max_load_size;  /* maximum file size for loading in memory */
+    int default_tab_width;      /* 8 */
+    int default_fill_column;    /* 70 */
 };
 
 extern QEmacsState qe_state;

Index: shell.c
===================================================================
RCS file: /sources/qemacs/qemacs/shell.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- shell.c     15 Jan 2014 19:44:26 -0000      1.79
+++ shell.c     21 Jan 2014 00:01:21 -0000      1.80
@@ -1817,7 +1817,7 @@
 static int shell_mode_init(EditState *s, __unused__ ModeSavedData *saved_data)
 {
     text_mode_init(s, saved_data);
-    s->tab_size = 8;
+    s->b->tab_width = 8;
     s->wrap = WRAP_TRUNCATE;
     s->interactive = 1;
     return 0;
@@ -1826,7 +1826,7 @@
 static int pager_mode_init(EditState *s, __unused__ ModeSavedData *saved_data)
 {
     text_mode_init(s, saved_data);
-    s->tab_size = 8;
+    s->b->tab_width = 8;
     s->wrap = WRAP_TRUNCATE;
     return 0;
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]