qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs script.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs script.c
Date: Wed, 3 May 2017 04:10:56 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        17/05/03 04:10:56

Modified files:
        .              : script.c 

Log message:
        script: split script-mode into shell specific modes
        - add specific modes for sh, bash, csh, ksh, zsh and tcsh

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/script.c?cvsroot=qemacs&r1=1.22&r2=1.23

Patches:
Index: script.c
===================================================================
RCS file: /sources/qemacs/qemacs/script.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- script.c    28 Mar 2017 12:50:30 -0000      1.22
+++ script.c    3 May 2017 08:10:56 -0000       1.23
@@ -266,10 +266,16 @@
 
 static int shell_script_mode_probe(ModeDef *mode, ModeProbeData *p)
 {
+    /* Match on file extension, shbang line and .bashrc .bash_history... */
     if (match_extension(p->filename, mode->extensions)
     ||  match_shell_handler(cs8(p->buf), mode->shell_handlers)
-    ||  stristart(p->filename, ".bash", NULL)
-    ||  stristart(p->filename, ".profile", NULL)) {
+    ||  (*p->filename == '.'
+     &&  stristart(p->filename + 1, mode->extensions, NULL))) {
+        return 82;
+    }
+
+    if (stristart(p->filename, ".profile", NULL)) {
+        /* XXX: Should check the user login shell */
         return 80;
     }
 
@@ -283,10 +289,55 @@
 }
 
 /* XXX: should have shell specific variations */
-static ModeDef shell_script_mode = {
-    .name = "Shell-script",
-    .extensions = "sh|bash|csh|ksh|zsh",
-    .shell_handlers = "sh|bash|csh|ksh|zsh",
+static ModeDef sh_mode = {
+    .name = "sh",
+    .extensions = "sh",
+    .shell_handlers = "sh",
+    .mode_probe = shell_script_mode_probe,
+    .colorize_func = shell_script_colorize_line,
+    .keywords = shell_script_keywords,
+};
+
+static ModeDef bash_mode = {
+    .name = "bash",
+    .extensions = "bash",
+    .shell_handlers = "bash",
+    .mode_probe = shell_script_mode_probe,
+    .colorize_func = shell_script_colorize_line,
+    .keywords = shell_script_keywords,
+};
+
+static ModeDef csh_mode = {
+    .name = "csh",
+    .extensions = "csh",
+    .shell_handlers = "csh",
+    .mode_probe = shell_script_mode_probe,
+    .colorize_func = shell_script_colorize_line,
+    .keywords = shell_script_keywords,
+};
+
+static ModeDef ksh_mode = {
+    .name = "ksh",
+    .extensions = "ksh",
+    .shell_handlers = "ksh",
+    .mode_probe = shell_script_mode_probe,
+    .colorize_func = shell_script_colorize_line,
+    .keywords = shell_script_keywords,
+};
+
+static ModeDef zsh_mode = {
+    .name = "zsh",
+    .extensions = "zsh",
+    .shell_handlers = "zsh",
+    .mode_probe = shell_script_mode_probe,
+    .colorize_func = shell_script_colorize_line,
+    .keywords = shell_script_keywords,
+};
+
+static ModeDef tcsh_mode = {
+    .name = "tcsh",
+    .extensions = "tcsh",
+    .shell_handlers = "tcsh",
     .mode_probe = shell_script_mode_probe,
     .colorize_func = shell_script_colorize_line,
     .keywords = shell_script_keywords,
@@ -294,7 +345,12 @@
 
 static int shell_script_init(void)
 {
-    qe_register_mode(&shell_script_mode, MODEF_SYNTAX);
+    qe_register_mode(&sh_mode, MODEF_SYNTAX);
+    qe_register_mode(&bash_mode, MODEF_SYNTAX);
+    qe_register_mode(&csh_mode, MODEF_SYNTAX);
+    qe_register_mode(&ksh_mode, MODEF_SYNTAX);
+    qe_register_mode(&zsh_mode, MODEF_SYNTAX);
+    qe_register_mode(&tcsh_mode, MODEF_SYNTAX);
 
     return 0;
 }



reply via email to

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