qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs dired.c variables.h


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs dired.c variables.h
Date: Fri, 19 Jun 2015 14:09:31 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        15/06/19 14:09:31

Modified files:
        .              : dired.c variables.h 

Log message:
        added variables to control the display of hidden files
        
        * dired-show-dot-files: show files and directories starting with '.', 
default 1
        * dired-ds-store: show .DS_Store files on Mac OS/X, default 0

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/dired.c?cvsroot=qemacs&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/qemacs/variables.h?cvsroot=qemacs&r1=1.3&r2=1.4

Patches:
Index: dired.c
===================================================================
RCS file: /sources/qemacs/qemacs/dired.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- dired.c     9 May 2015 22:25:05 -0000       1.51
+++ dired.c     19 Jun 2015 14:09:31 -0000      1.52
@@ -20,6 +20,7 @@
  */
 
 #include "qe.h"
+#include "variables.h"
 
 #include <grp.h>
 #include <pwd.h>
@@ -57,6 +58,11 @@
 
 static int dired_signature;
 
+static int dired_show_dot_files = 1;
+#ifdef CONFIG_DARWIN
+static int dired_show_ds_store = 0;
+#endif
+
 typedef struct DiredState {
     void *signature;
     StringArray items;
@@ -753,6 +759,13 @@
         if (strequal(p, ".") || strequal(p, ".."))
             continue;
 #endif
+        if (!dired_show_dot_files && *p == '.')
+            continue;
+
+#ifdef CONFIG_DARWIN
+        if (!dired_show_ds_store && strequal(p, ".DS_Store"))
+            continue;
+#endif
         pstrcpy(line, sizeof(line), p);
         if (S_ISDIR(st.st_mode)) {
             ds->ndirs++;
@@ -871,7 +884,8 @@
     if (e) {
         do_find_file(e, filename);
         /* disable wrapping to get nicer display */
-        e->wrap = WRAP_TRUNCATE;
+        /* XXX: should wrap lines unless window is narrow */
+        //e->wrap = WRAP_TRUNCATE;
         b = e->b;
         if (!b) {
             b = eb_new("*scratch*", BF_SAVELOG | BF_UTF8);
@@ -1023,18 +1037,17 @@
 static void dired_colorize_line(QEColorizeContext *cp,
                                 unsigned int *str, int n, ModeDef *syn)
 {
-    const unsigned int *p;
     int i = 0, start = i, style;
 
-    if (ustrstart(str + start, "  Directory of ", &p)) {
-        i = p - (str + start);
+    if (ustrstart(str + start, "  Directory of ", &i)) {
+        i += start;
         SET_COLOR(str, start, i, DIRED_STYLE_HEADER);
         style = DIRED_STYLE_DIRECTORY;
         start = i;
         i = n;
         SET_COLOR(str, start, i, style);
     } else
-    if (n >= 6 && ustrstart(str + n - 6, " bytes", &p)) {
+    if (n >= 6 && ustrstart(str + n - 6, " bytes", NULL)) {
         style = DIRED_STYLE_HEADER;
         i = n;
         SET_COLOR(str, start, i, style);
@@ -1157,6 +1170,13 @@
     CMD_DEF_END,
 };
 
+static VarDef dired_variables[] = {
+    G_VAR( "dired-show-dot-files", dired_show_dot_files, VAR_NUMBER, VAR_RW )
+#ifdef CONFIG_DARWIN
+    G_VAR( "dired-show-ds-store", dired_show_ds_store, VAR_NUMBER, VAR_RW )
+#endif
+};
+
 static int dired_init(void)
 {
     /* inherit from list mode */
@@ -1172,6 +1192,7 @@
     /* first register mode */
     qe_register_mode(&dired_mode, /* MODEF_DATATYPE | */ MODEF_MAJOR | 
MODEF_VIEW);
 
+    qe_register_variables(dired_variables, countof(dired_variables));
     qe_register_cmd_table(dired_commands, &dired_mode);
     qe_register_cmd_table(dired_global_commands, NULL);
 

Index: variables.h
===================================================================
RCS file: /sources/qemacs/qemacs/variables.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- variables.h 29 Apr 2008 18:55:15 -0000      1.3
+++ variables.h 19 Jun 2015 14:09:31 -0000      1.4
@@ -60,8 +60,8 @@
 
 #define U_VAR(name, type) \
     { (name), VAR_SELF, type, VAR_RW, 0, { .num = 0 }, NULL },
-#define G_VAR(name,ptr,type,rw) \
-    { (name), VAR_GLOBAL, type, rw, 0, { (void*)&(ptr) }, NULL },
+#define G_VAR(name,var,type,rw) \
+    { (name), VAR_GLOBAL, type, rw, 0, { .ptr = (void*)&(var) }, NULL },
 #define S_VAR(name,fld,type,rw) \
     { (name), VAR_STATE, type, rw, sizeof(((QEmacsState*)0)->fld), { .offset = 
offsetof(QEmacsState, fld) }, NULL },
 #define B_VAR(name,fld,type,rw) \



reply via email to

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