qemacs-commit
[Top][All Lists]
Advanced

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

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


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs dired.c qe.c qe.h
Date: Wed, 15 Mar 2017 03:32:48 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        17/03/15 03:32:48

Modified files:
        .              : dired.c qe.c qe.h 

Log message:
        file: improve qe_load_file API
        - pass flags as bit mask for:
          kill_buffer, load_resource, cwd_relative, split_window
        - fix bug with multiple files on command line from different directories

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/dired.c?cvsroot=qemacs&r1=1.76&r2=1.77
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.250&r2=1.251
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.235&r2=1.236

Patches:
Index: dired.c
===================================================================
RCS file: /sources/qemacs/qemacs/dired.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -b -r1.76 -r1.77
--- dired.c     31 Dec 2016 11:29:38 -0000      1.76
+++ dired.c     15 Mar 2017 07:32:48 -0000      1.77
@@ -2,7 +2,7 @@
  * Directory editor mode for QEmacs.
  *
  * Copyright (c) 2001-2002 Fabrice Bellard.
- * Copyright (c) 2002-2016 Charlie Gordon.
+ * Copyright (c) 2002-2017 Charlie Gordon.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -1071,7 +1071,7 @@
      * new buffer as BF_PREVIEW, to trigger paging mode and so that it
      * will get freed if closed.
      */
-    rc = qe_load_file(e, filename, 0, 0, BF_PREVIEW);
+    rc = qe_load_file(e, filename, 0, BF_PREVIEW);
     if (rc >= 0) {
         /* disable wrapping to get nicer display */
         /* XXX: should wrap lines unless window is narrow */

Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.250
retrieving revision 1.251
diff -u -b -r1.250 -r1.251
--- qe.c        15 Mar 2017 07:24:31 -0000      1.250
+++ qe.c        15 Mar 2017 07:32:48 -0000      1.251
@@ -6609,8 +6609,7 @@
  * Return 2 if buffer was created for a new file.
  * Should take bits from enumeration instead of booleans.
  */
-int qe_load_file(EditState *s, const char *filename1,
-                 int kill_buffer, int load_resource, int bflags)
+int qe_load_file(EditState *s, const char *filename1, int lflags, int bflags)
 {
     u8 buf[4097];
     char filename[MAX_FILENAME_SIZE];
@@ -6623,14 +6622,24 @@
     EOLType eol_type = EOL_UNIX;
     QECharset *charset = &charset_utf8;
 
-    if (load_resource) {
+    if (lflags & LF_SPLIT_WINDOW) {
+        /* Split window if window large enough and not empty */
+        /* XXX: should check s->height units */
+        if (s->height > 10 && s->b->total_size > 0) {
+            do_split_window(s, 0);
+            s = s->qe_state->active_window;
+        }
+    }
+
+    if (lflags & LF_LOAD_RESOURCE) {
         if (find_resource_file(filename, sizeof(filename), filename1)) {
             put_status(s, "Cannot find resource file '%s'", filename1);
             return -1;
         }
     } else {
         /* compute full name */
-        canonicalize_absolute_path(s, filename, sizeof(filename), filename1);
+        canonicalize_absolute_path((lflags & LF_CWD_RELATIVE) ? NULL : s,
+                                   filename, sizeof(filename), filename1);
     }
 
 #ifndef CONFIG_TINY
@@ -6652,7 +6661,7 @@
     /* We are going to try and load a new file: potentially delete the
      * current buffer if requested.
      */
-    if (kill_buffer && s->b && !s->b->modified) {
+    if ((lflags & LF_KILL_BUFFER) && s->b && !s->b->modified) {
         s->b->flags |= BF_TRANSIENT;
     }
 
@@ -6802,28 +6811,22 @@
 
 void do_find_file(EditState *s, const char *filename, int bflags)
 {
-    qe_load_file(s, filename, 0, 0, bflags);
+    qe_load_file(s, filename, 0, bflags);
 }
 
 void do_find_file_other_window(EditState *s, const char *filename, int bflags)
 {
-    /* Split window if window large enough and not empty */
-    /* XXX: should check s->height units */
-    if (s->height > 10 && s->b->total_size > 0) {
-        do_split_window(s, 0);
-        s = s->qe_state->active_window;
-    }
-    qe_load_file(s, filename, 0, 0, bflags);
+    qe_load_file(s, filename, LF_SPLIT_WINDOW, bflags);
 }
 
 void do_find_alternate_file(EditState *s, const char *filename, int bflags)
 {
-    qe_load_file(s, filename, 1, 0, bflags);
+    qe_load_file(s, filename, LF_KILL_BUFFER, bflags);
 }
 
 void do_load_file_from_path(EditState *s, const char *filename, int bflags)
 {
-    qe_load_file(s, filename, 0, 1, bflags);
+    qe_load_file(s, filename, LF_LOAD_RESOURCE, bflags);
 }
 
 void do_insert_file(EditState *s, const char *filename)
@@ -8552,7 +8555,9 @@
                 col_num = strtol(p + 1, NULL, 10);
             arg = argv[i++];
         }
-        do_find_file(s, arg, 0);
+        /* load filename relative to qe current directory */
+        /* XXX: should split windows evenly */
+        qe_load_file(s, arg, LF_CWD_RELATIVE | LF_SPLIT_WINDOW, 0);
         s = qs->active_window;
         if (line_num)
             do_goto_line(s, line_num, col_num);

Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.235
retrieving revision 1.236
diff -u -b -r1.235 -r1.236
--- qe.h        1 Jan 2017 15:40:46 -0000       1.235
+++ qe.h        15 Mar 2017 07:32:48 -0000      1.236
@@ -1827,8 +1827,11 @@
 #endif
 
 /* file loading */
-int qe_load_file(EditState *s, const char *filename1,
-                 int kill_buffer, int load_resource, int bflags);
+#define LF_KILL_BUFFER    1
+#define LF_LOAD_RESOURCE  2
+#define LF_CWD_RELATIVE   4
+#define LF_SPLIT_WINDOW   8
+int qe_load_file(EditState *s, const char *filename, int lflags, int bflags);
 
 /* config file support */
 void do_load_config_file(EditState *e, const char *file);



reply via email to

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