]> git.rmz.io Git - dotfiles.git/blobdiff - weechat/python/grep.py
weechat: update scripts and settings
[dotfiles.git] / weechat / python / grep.py
index 6d08ecdc1063961ac09b267700c2cb761e320172..30bf2a6c2f0adfdd06d8cf734346f74056e51be7 100644 (file)
 #
 #
 #   History:
 #
 #
 #   History:
+#
+#   2016-06-23, mickael9
+#   version 0.7.7: fix get_home function
+#
+#   2015-11-26
+#   version 0.7.6: fix a typo
+#
+#   2015-01-31, Nicd-
+#   version 0.7.5:
+#   '~' is now expaned to the home directory in the log file path so
+#   paths like '~/logs/' should work.
+#
+#   2015-01-14, nils_2
+#   version 0.7.4: make q work to quit grep buffer (requested by: gb)
+#
 #   2014-03-29, Felix Eckhofer <felix@tribut.de>
 #   version 0.7.3: fix typo
 #
 #   2014-03-29, Felix Eckhofer <felix@tribut.de>
 #   version 0.7.3: fix typo
 #
@@ -191,7 +206,7 @@ except ImportError:
 
 SCRIPT_NAME    = "grep"
 SCRIPT_AUTHOR  = "Elián Hanisch <lambdae2@gmail.com>"
 
 SCRIPT_NAME    = "grep"
 SCRIPT_AUTHOR  = "Elián Hanisch <lambdae2@gmail.com>"
-SCRIPT_VERSION = "0.7.3"
+SCRIPT_VERSION = "0.7.7"
 SCRIPT_LICENSE = "GPL3"
 SCRIPT_DESC    = "Search in buffers and logs"
 SCRIPT_COMMAND = "grep"
 SCRIPT_LICENSE = "GPL3"
 SCRIPT_DESC    = "Search in buffers and logs"
 SCRIPT_COMMAND = "grep"
@@ -405,7 +420,9 @@ def get_config_log_filter():
 
 def get_home():
     home = weechat.config_string(weechat.config_get('logger.file.path'))
 
 def get_home():
     home = weechat.config_string(weechat.config_get('logger.file.path'))
-    return home.replace('%h', weechat.info_get('weechat_dir', ''))
+    home = home.replace('%h', weechat.info_get('weechat_dir', ''))
+    home = path.abspath(path.expanduser(home))
+    return home
 
 def strip_home(s, dir=''):
     """Strips home dir from the begging of the log path, this makes them sorter."""
 
 def strip_home(s, dir=''):
     """Strips home dir from the begging of the log path, this makes them sorter."""
@@ -1144,7 +1161,7 @@ def buffer_update():
         note = ' (last %s lines shown)' %len(matched_lines)
     else:
         note = ''
         note = ' (last %s lines shown)' %len(matched_lines)
     else:
         note = ''
-    title = "Search in %s%s%s %s matches%s | pattern \"%s%s%s\"%s %s | %.4f seconds (%.2f%%)" \
+    title = "'q': close buffer | Search in %s%s%s %s matches%s | pattern \"%s%s%s\"%s %s | %.4f seconds (%.2f%%)" \
             %(color_title, matched_lines, color_reset, matched_lines.get_matches_count(), note,
               color_title, pattern_tmpl, color_reset, invert and ' (inverted)' or '', format_options(),
               time_total, time_grep_pct)
             %(color_title, matched_lines, color_reset, matched_lines.get_matches_count(), note,
               color_title, pattern_tmpl, color_reset, invert and ' (inverted)' or '', format_options(),
               time_total, time_grep_pct)
@@ -1239,6 +1256,9 @@ def buffer_input(data, buffer, input_data):
         cmd_grep_stop(buffer, input_data)
     except:
         return WEECHAT_RC_OK
         cmd_grep_stop(buffer, input_data)
     except:
         return WEECHAT_RC_OK
+    if input_data in ('q', 'Q'):
+        weechat.buffer_close(buffer)
+        return weechat.WEECHAT_RC_OK
 
     global search_in_buffers, search_in_files
     global pattern
 
     global search_in_buffers, search_in_files
     global pattern
@@ -1626,7 +1646,7 @@ if __name__ == '__main__' and import_ok and \
                  If used with 'log <file>' search in all logs that matches <file>.
     -b --buffer: Search only in buffers, not in file logs.
      -c --count: Just count the number of matched lines instead of showing them.
                  If used with 'log <file>' search in all logs that matches <file>.
     -b --buffer: Search only in buffers, not in file logs.
      -c --count: Just count the number of matched lines instead of showing them.
- -m --matchcase: Don't do case insensible search.
+ -m --matchcase: Don't do case insensitive search.
    -H --hilight: Colour exact matches in output buffer.
 -o --only-match: Print only the matching part of the line (unique matches).
  -v -i --invert: Print lines that don't match the regular expression.
    -H --hilight: Colour exact matches in output buffer.
 -o --only-match: Print only the matching part of the line (unique matches).
  -v -i --invert: Print lines that don't match the regular expression.