Skip to content

Commit

Permalink
vgrep.py: decode as ascii
Browse files Browse the repository at this point in the history
  • Loading branch information
Vagn Johansen authored and Vagn Johansen committed Jan 3, 2018
1 parent c333008 commit c97cfcd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions vgrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import argparse
import re
import subprocess
import chardet

parser = argparse.ArgumentParser(description='Grep directories.')
parser.add_argument('-e', default=':code')
Expand Down Expand Up @@ -40,8 +41,14 @@ def grep(dir_):
shell_args.extend(filenames)
sys.stdout.flush()
try:
output = subprocess.check_output(shell_args, shell=True).decode('utf-8')
except:
rawdata = subprocess.check_output(shell_args, shell=True)
output = rawdata.decode('ascii', 'ignore')
except subprocess.CalledProcessError:
return count
except UnicodeEncodeError as ex:
print('UnicodeEncodeError Exception', dir_, ex)
except UnicodeDecodeError as ex:
print('UnicodeDecodeError Exception', dir_, ex)
return count

# python 3.5 can use
Expand Down
2 changes: 1 addition & 1 deletion vj-csharp.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(local-set-key (kbd "M-r i") 'omnisharp-find-implementations) ;Find *interface* implementations
(local-set-key (kbd "<f12>") 'omnisharp-go-to-definition)
(local-set-key (kbd "S-<f12>") 'omnisharp-find-usages)
(local-set-key (kbd "M-<f2>") 'omnisharp-build-in-emacs)
(local-set-key (kbd "M-<f3>") 'omnisharp-build-in-emacs)
;; Only enable omnisharp-mode if server is running
(let ((server-running nil))
(dolist (pid (list-system-processes))
Expand Down
2 changes: 1 addition & 1 deletion vj-full.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
(global-set-key [S-down] 'my-scroll-up-hook)


;; (global-set-key [M-f2] (lambda () (interactive) (vps-grep (current-word))))
(global-set-key [M-f2] (lambda () (interactive) (vps-grep (current-word))))
(global-set-key [pause] '(lambda() (interactive) (kill-buffer nil)))

(if (equal system-type 'windows-nt)
Expand Down
2 changes: 1 addition & 1 deletion vj-prog.el
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ that file will need to be in your path."
(if (memq major-mode '(c-mode))
(insert (concat "printf(\"" cw "= %s\\n\"," cw ");"))
(if (memq major-mode '(python-mode))
(insert (concat "print(\"" cw " =\", " cw ")")))))
(insert (concat "print('" cw "', " cw ")")))))
)))

;; (defun vjo-c++-mode-hook ()
Expand Down

0 comments on commit c97cfcd

Please sign in to comment.