]> git.nbdom.net Git - nb.git/commitdiff
etc/vim/source/functions.vim
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 11 Dec 2022 01:12:52 +0000 (02:12 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 11 Dec 2022 01:12:52 +0000 (02:12 +0100)
bin/shell-replace
etc/vim/source/functions.vim
etc/vim/source/vars.vim
lib/php/http.php
lib/php/mime.php
share/db/nb.db

index 28c2db0e6f14727915802804b86886d3da450cda..f16a5babb8f2ab9b21e2e5050d5bfc21f4e32fea 100755 (executable)
@@ -33,6 +33,7 @@ my %Opt = (
 get_options(\%Opt);
 #help() unless @ARGV;
 $main::_DATA_ = undef;
+$Opt{find} = 1 if $Opt{'find-only'};
 
 #################################################################################
 #
@@ -47,6 +48,7 @@ no warnings 'File::Find';
 
 #$_ = "nb_api '/pub/mime/ls/type,ext.php_hash' | sed \"s/^/\$(printf '\\t\\t')/\"";
 #$_ = "nb_api /pub/mime/ls/type,ext.php_hash";
+#die map {">$_"} &cmd($_);
 #warn &cmd($_);
 @ARGV = grep {&file_readable($_)} @ARGV if @ARGV;
 if (!@ARGV and !-t STDIN) {
@@ -68,6 +70,7 @@ if ($Opt{find}) {
        }, @ARGV);
        #exit;
        @ARGV = @WANTED_FILES;
+       exit if $Opt{'find-only'};
 }
 
 #
@@ -225,6 +228,7 @@ sub shell_replace {
                        if ($i==1) {
                                $cmd = $2;
                                push @lines, $line;
+                               #die $cmd;
                                push @lines, map{s/^/$blank/;$_} &cmd($cmd);
 
                        } elsif ($line =~ /^\s*.{1,3}<SHELL_REPLACE/) {
@@ -364,14 +368,15 @@ Description!
 
 =head1 OPTIONS
 
- -option[find|f!]      Search first files containing tags from args
- -option[extension|e=s] Copy original to a new file with this value as an extension
+ -option[find-only|fo!] Search first files containing tags from args without processing
+ -option[find|f!]       Search first files containing tags from args
+ -option[extension|e=s]  Copy original to a new file with this value as an extension
 
- -option[verbose|v+]   Verbose mode: increase the verbosity level.
- -option[debug+]         Debug mode: increase the verbosity level.
- -option[version|V]   Print version (default: $VERSION)
- -option[help|h|?]  Print a brief help message and exits.
- -option[man]           Print the manual page and exits.
+ -option[verbose|v+]    Verbose mode: increase the verbosity level.
+ -option[debug+]          Debug mode: increase the verbosity level.
+ -option[version|V]    Print version (default: $VERSION)
+ -option[help|h|?]   Print a brief help message and exits.
+ -option[man]            Print the manual page and exits.
 
 =cut
 
index 3cb75d4fa51e4051c80b8b930296ff2f3fef6383..030e90291dbd676adfc745a041403a2ac53d33ac 100644 (file)
@@ -142,6 +142,29 @@ func! FileCheck()
 
 endfunc
 
+func! MeNow()
+       return $USER_INITIALS . ' ' . strftime('%d.%m.%y')
+endfunc
+
+func! CommentToggle()
+       let curr_line = getline('.')
+       let c = g:mimeComment[&filetype]
+
+       " wipe out comment
+       "let exp = '^'.substitute(c,'\d\d\.\d\d\.\d\d','........','')
+
+       " Wipe out existing comment
+       let new_line = substitute(curr_line,'^\([\t ]*\)'.c.' .. \d\d\.\d\d\.\d\d ','\1','')
+
+       if new_line == curr_line
+         " Add comment
+  let v = ''
+         let new_line = substitute(curr_line,'^\([\t ]*\)','\1'.c.' '.MeNow().' ','')
+       endif
+
+       call setline('.',new_line)
+endfunc
+
 func! FileCommentToggle()
        let curr_line = getline('.')
 
index f4cf1cba738905e8575aafe7019bb9a54379dc88..958285463139b3d777f5211804a8ebb9e3fd79a1 100644 (file)
@@ -38,7 +38,7 @@ let mimeComment = {
        \,'lua'       : '--'
        \,'php'       : '#'
        \,'sql'       : '--'
-       \,'vim'       : '\"'
+       \,'vim'       : '"'
        \,'xhtml'     : '<!-- -->'
        \,'xml'       : '<!-- -->'
 \}
index e1f85b1d2c0b40ad3a092d4645d5fbc6d40d08a7..911d9798b014362542ad6407cd8de48001c99594 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 class Http {
   const Status = [
-#>SHELL_REPLACE dbq db=$NB_DB t=http_status rows.fields=id,name orderby=id f=php_hash | sed "s/^/\t/"
+#>SHELL_REPLACE dbq.php /$NB_DB/http_status/ls/id,name orderby=id format=php_hash preff=$'\t'
        "100" => "Continue",
        "101" => "Switching Protocols",
        "102" => "Processing",
index 4281854b5697075dc9f3b44958b79dbb0edb3e9a..549a565aafa78515568b3a1858cc52e51ae7e195 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 class Mime {
        const Types = [
-#>SHELL_REPLACE nb_api '/pub/mime/ls/type,ext.php_hash' | sed "s/^/$(printf '\t\t')/"
+#>SHELL_REPLACE nb_api "/pub/mime/ls/type,ext.php_hash?preff=%09%09"
                "application/applixware"                                                    => "aw",
                "application/atomcat+xml"                                                   => "atomcat",
                "application/atomsvc+xml"                                                   => "atomsvc",
index fabf51c70bf3ee46477bfb7d6e26dd1cca2950de..a0526b5864801c3103a5c85ef05d7870627af57e 100644 (file)
Binary files a/share/db/nb.db and b/share/db/nb.db differ