/usr/share/doc/pymacs/contrib/Giorgi/Pymacs/utility.py is in pymacs 0.23-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | # Copyright 2007 Giovanni Giorgi <jj@objectsroot.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
from Pymacs import lisp
import time
# Utility support functions
class EmacsLog:
def __init__(self,category):
self.logBuffer="*LogBuffer*" # "*Pymacs Log Buffer*"
self.category=category
self.startTime=time.time()
def show(self,level,msg):
start=int(time.time()-self.startTime)
mx=str(start)+" <"+level+"> PY "+self.category+" "+msg
lisp.message(mx)
#mx = mx + "\n"
#lisp.set_buffer(self.logBuffer)
#lisp.insert(mx)
def info(self, msg):
self.show("I",msg)
def debug(self,msg):
self.show("DEBUG",msg)
# Finest debugging
def debugf(self,msg):
self.show("DEBUG FINER",msg)
class BufferMan:
def __init__(self):
self.bufferName=lisp.buffer_name()
self.fname=lisp.buffer_file_name()
def getBufferAsText(self):
f=open(self.fname,"r")
text=f.read()
f.close()
return text
def writeBuffer(self,text):
f=open(self.fname,"w")
f.write(text)
f.close()
self.reloadBuffer()
def reloadBuffer(self):
# ;; (switch-to-buffer bname)
# ;; (revert-buffer 'IGNORE-AUTO 'NOCONFIRM)
lisp.switch_to_buffer(self.bufferName)
lisp.revert_buffer(lisp.IGNORE_AUTO, lisp.NOCONFIRM)
log=EmacsLog("main")
log.debugf("Pymacs.utility Loaded and happy to serve you")
|