Wednesday, May 27, 2009

Remove Line Breaks in Paragraphs in Emacs

Include the following in your .emacs, or somewhere else:
(defun remove-line-breaks ()
"Remove line endings in a paragraph."
(interactive)
(let ((fill-column 90002000))
(fill-paragraph nil)))

(defun remove-all-line-breaks ()
"Remove all single line-breaks in a document"
(interactive)
(while (not (= (point) (buffer-end 1)))
(remove-line-breaks)
(next-line 1)))

Then position your cursor at the top of a stretch of paragraphs that need to have line breaks removed, and do:
M-x remove-all-line-breaks RET
It will remove all line breaks between there and the end of the buffer.

Friday, January 30, 2009

Using py2exe for PyGTK apps

Here's a simple setup.py file that does most of the work (obviously, you'll have to edit the variables at the start):


from distutils.core import setup
import py2exe

appname = "Application Name"
appdescription = "A description of what the application does"
scriptname = "the-script-name.py" #the python script to compile
iconfile = "the-application-icon.ico" #must be a .ico

setup(
name = appname,
description = appdescription,
version = '1.0',

windows = [
{
'script': scriptname,
'icon_resources': [(1, iconfile)],
}
],

options = {
'py2exe': {
'packages':'encodings',
'includes': 'cairo, pango, pangocairo, atk, gobject'
}
}
)


When you've run it, copy the folders etc, lib, and share from your installation of GTK (not PyGTK) into the dist folder the script created. You can prune their contents judiciously if you know what you're doing, but this will let GTK find the theme and other files it needs.




EDIT: Note that py2exe seems to have problems with Python 2.6. I'd recommend sticking to 2.5 for whatever machine you build Windows executables.

Tuesday, January 27, 2009

LaTeX: Continue enumerating after a break

After your \documentclass{}:

\usepackage{enumitem}

Then, begin and end a list as usual, type the stuff that interrupts it, and continue the list with:

\begin{enumerate}[resume]

Your list will resume at the next number.