• modify format-alist to read .pyc file

    From songlining@gmail.com@21:1/5 to All on Thu Nov 30 18:58:38 2017
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Larry Song@21:1/5 to Larry Song on Thu Nov 30 20:02:20 2017
    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 :(

    On Friday, 1 December 2017 13:58:41 UTC+11, Larry Song wrote:
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)