Discussion:
modify format-alist to read .pyc file
(too old to reply)
s***@gmail.com
2017-12-01 02:58:38 UTC
Permalink
Hi,

I am running GNU Emacs 25.3 (9.0).

Trying to open a .pyc file (compiled python) while uncompile (using uncompyle2) it to the buffer.

Modified format-alist like this but it didn't work while I open a .pyc file, it still shows the binary.

(add-to-list 'format-alist '(pyc ; name
"" ; doc-str
"\\u03f30d0a" ; regexp
"/usr/local/bin/uncompyle2" ; from-fn
nil ; to-fn
nil ; modify
nil ; mode-fn
nil)) ; preserve

03f30d0a is the magic code of the .pyc file which I have double checked. However, I am not sure if "\\u03f30d0a" is right way to do the regex on hex.

Not much sample code I can look around, any help would be highly appreciated!

Thanks,

Larry
Larry Song
2017-12-01 04:02:20 UTC
Permalink
Did some debugging, I believe the regex doesn't trigger at all. An empty string in the place of regexp will trigger, however uncompyle2 doesn't accept input from stdin :(
Post by s***@gmail.com
Hi,
I am running GNU Emacs 25.3 (9.0).
Trying to open a .pyc file (compiled python) while uncompile (using uncompyle2) it to the buffer.
Modified format-alist like this but it didn't work while I open a .pyc file, it still shows the binary.
(add-to-list 'format-alist '(pyc ; name
"" ; doc-str
"\\u03f30d0a" ; regexp
"/usr/local/bin/uncompyle2" ; from-fn
nil ; to-fn
nil ; modify
nil ; mode-fn
nil)) ; preserve
03f30d0a is the magic code of the .pyc file which I have double checked. However, I am not sure if "\\u03f30d0a" is right way to do the regex on hex.
Not much sample code I can look around, any help would be highly appreciated!
Thanks,
Larry
Loading...